-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
180 lines (166 loc) · 4.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
'use strict';
/**
* @name emis-resource
* @module emis-resource
* @description A representation of item(i.e materials, services, staff,
* assets etc.) and it stock that may be consumed or made available in
* emergency(or disaster) management(or event).
*
* @see {@link https://en.wikipedia.org/wiki/Resource}
* @see {@link https://en.wikipedia.org/wiki/Inventory}
* @see {@link https://en.wikipedia.org/wiki/Resource_management}
* @see {@link https://en.wikipedia.org/wiki/Disaster}
* @see {@link https://www.fema.gov/media-library/assets/documents/89520}
* @see {@link https://www.doa.la.gov/osp/Vendorcenter/docs/unitofmeasurecodes.pdf}
* @see {@link https://www.urmc.rochester.edu/purchasing/documents/um.pdf}
*
* @author lally elias <[email protected]>
* @license MIT
* @since 1.0.0
* @version 0.1.0
* @public
*
* @example
*
* const { app } = require('@codetanzania/emis-resource');
* app.start(error => { ... });
*
*/
/* dependencies */
const _ = require('lodash');
const { include } = require('@lykmapipo/include');
const { app, mount } = require('@lykmapipo/express-common');
const { Feature: Warehouse } = require('@codetanzania/emis-feature');
/* includes */
const pkg = include(__dirname, 'package.json');
const Item = include(__dirname, 'lib', 'item.model');
const Stock = include(__dirname, 'lib', 'stock.model');
const Adjustment = include(__dirname, 'lib', 'adjustment.model');
const warehouseRouter = include(__dirname, 'lib', 'warehouse.http.router');
const itemRouter = include(__dirname, 'lib', 'item.http.router');
const stockRouter = include(__dirname, 'lib', 'stock.http.router');
const adjustmentRouter = include(__dirname, 'lib', 'adjustment.http.router');
/**
* @name info
* @description package information
* @type {Object}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.info = _.merge(
{},
_.pick(pkg, [
'name',
'description',
'version',
'license',
'homepage',
'repository',
'bugs',
'sandbox',
'contributors',
])
);
/**
* @name Warehouse
* @description Warehouse model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.Warehouse = Warehouse;
/**
* @name Item
* @description Item model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.Item = Item;
/**
* @name Stock
* @description Stock model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.Stock = Stock;
/**
* @name Adjustment
* @description Adjustment model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.Adjustment = Adjustment;
/**
* @name warehouseRouter
* @description warehouse http router
* @type {express.Router}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.warehouseRouter = warehouseRouter;
/**
* @name itemRouter
* @description item http router
* @type {express.Router}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.itemRouter = itemRouter;
/**
* @name stockRouter
* @description stock http router
* @type {express.Router}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.stockRouter = stockRouter;
/**
* @name adjustmentRouter
* @description adjustment http router
* @type {express.Router}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.adjustmentRouter = adjustmentRouter;
/**
* @name apiVersion
* @description http router api version
* @type {String}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.apiVersion = itemRouter.version;
/* export app */
Object.defineProperty(exports, 'app', {
get() {
/* @todo bind oauth middlewares authenticate, token, authorize */
mount(exports.warehouseRouter);
mount(exports.itemRouter);
mount(exports.stockRouter);
mount(exports.adjustmentRouter);
return app;
},
});