-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
218 lines (187 loc) · 4.51 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
'use strict';
/**
* @module Assessment
* @name Assessment
* @description WIP
*
* @author lally elias <[email protected]>
* @licence MIT
* @since 0.1.0
* @version 0.1.0
* @example
*
* const { app } = require('@codetanzania/emis-assessment');
* app.start();
*
*/
/* dependencies */
const path = require('path');
const _ = require('lodash');
const app = require('@lykmapipo/express-common');
const mongoose = require('mongoose');
const pkg = require(path.join(__dirname, 'package.json'));
require('mongoose-schema-jsonschema')(mongoose);
const Indicator = require(path.join(__dirname, 'lib', 'indicator.model'));
const Question = require(path.join(__dirname, 'lib', 'question.model'));
const Questionnaire = require(path.join(__dirname, 'lib', 'questionnaire.model'));
const Assessment = require(path.join(__dirname, 'lib', 'assessment.model'));
/*jshint -W079 */
const Response = require(path.join(__dirname, 'lib', 'response.model'));
const Observation = require(path.join(__dirname, 'lib', 'observation.model'));
const indicatorRouter =
require(path.join(__dirname, 'lib', 'indicator.http.router'));
const questionRouter =
require(path.join(__dirname, 'lib', 'question.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 Indicator
* @description Indicator model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.Indicator = Indicator;
/**
* @name Question
* @description Question model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.Question = Question;
/**
* @name Questionnaire
* @description Questionnaire model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.Questionnaire = Questionnaire;
/**
* @name Observation
* @description Observation model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.Observation = Observation;
/**
* @name Response
* @description Response model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.Response = Response;
/**
* @name Assessment
* @description Assessment model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.Assessment = Assessment;
/**
* @name indicatorRouter
* @description indicator http router
* @type {express.Router}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.indicatorRouter = indicatorRouter;
/**
* @name questionRouter
* @description question http router
* @type {express.Router}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.questionRouter = questionRouter;
/**
* @name questionnaireRouter
* @description questionnaire http router
* @type {express.Router}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
// exports.questionnaireRouter = questionnaireRouter;
/**
* @name responseRouter
* @description response http router
* @type {express.Router}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
// exports.responseRouter = responseRouter;
/**
* @name observationRouter
* @description observation http router
* @type {express.Router}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
// exports.observationRouter = observationRouter;
/**
* @name apiVersion
* @description http router api version
* @type {String}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.apiVersion = indicatorRouter.apiVersion;
/**
* @name app
* @description express app
* @type {Object}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
Object.defineProperty(exports, 'app', {
get() {
/* @todo bind oauth middlewares authenticate, token, authorize */
app.mount(indicatorRouter);
app.mount(questionRouter);
// app.mount(questionnaireRouter);
// app.mount(responseRouter);
// app.mount(observationRouter);
return app;
}
});