-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
86 lines (63 loc) · 1.57 KB
/
Copy pathindex.js
File metadata and controls
86 lines (63 loc) · 1.57 KB
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
'use strict';
/**
* @name majifix-jurisdiction
* @description A representation of an entity (e.g minicipal)
* responsible for addressing citizen(or customer) service request(issue).
*
* It may be a self managed entity or division within another
* entity(jurisdiction) in case there is hierarchy.
*
* @author Benson Maruchu <benmaruchu@gmail.com>
* @author lally elias <lallyelias87@mail.com>
* @since 0.1.0
* @version 0.1.0
* @example
*
* const { app } = require('majifix-jurisdiction');
*
* ...
*
* app.start();
*
*/
/* dependencies */
const path = require('path');
const _ = require('lodash');
const app = require('@lykmapipo/express-common');
/* declarations */
const pkg = require(path.join(__dirname, 'package.json'));
const fields = [
'name',
'description',
'version',
'license',
'homepage',
'repository',
'bugs',
'sandbox',
'contributors'
];
const info = _.merge({}, _.pick(pkg, fields));
/* ensure api version */
process.env.API_VERSION = (process.env.API_VERSION || info.version);
/* import models */
const Module =
require(path.join(__dirname, 'lib', 'module.model'));
/* import routers*/
const router =
require(path.join(__dirname, 'lib', 'http.router'));
/* export package(module) info */
exports.info = info;
/* export Module model */
exports.Module = Module;
/* export module router */
exports.router = router;
/* export app */
Object.defineProperty(exports, 'app', {
get() {
//TODO bind oauth middlewares authenticate, token, authorize
/* bind jurisdiction router */
app.mount(router);
return app;
}
});