-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
124 lines (115 loc) · 2.87 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
'use strict';
/**
* @name emis-alert
* @description A representation of an envelope(or payload) which carries
* disaster notifications(or warning) from source(s) to audience(s).
*
* @see {@link http://docs.oasis-open.org/emergency/cap/v1.2/CAP-v1.2-os.html}
* @see {@link http://docs.oasis-open.org/emergency/cap/v1.2/pr03/CAP-v1.2-PR03.pdf}
* @see {@link https://en.wikipedia.org/wiki/Common_Alerting_Protocol}
* @see {@link https://developers.google.com/public-alerts/reference/cap-google}
* @see {@link https://library.wmo.int/pmb_ged/wmo_1109_en.pdf}
* @see {@link https://en.wikipedia.org/wiki/ISO_22324}
*
* @author lally elias <[email protected]>
* @license MIT
* @since 0.1.0
* @version 0.1.0
* @public
* @example
*
* const { app } = require('@codetanzania/emis-alert');
* app.start((error) => { ... });
*
*/
/* dependencies */
const _ = require('lodash');
const { include } = require('@lykmapipo/include');
const { app, mount } = require('@lykmapipo/express-common');
const pkg = include(__dirname, 'package.json');
const AlertSource = include(__dirname, 'lib', 'source.model');
const Alert = include(__dirname, 'lib', 'alert.model');
const alertSourceRouter = include(__dirname, 'lib', 'source.http.router');
const alertRouter = include(__dirname, 'lib', 'alert.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 AlertSource
* @description AlertSource model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.AlertSource = AlertSource;
/**
* @name Alert
* @description Alert model
* @type {mongoose.Model}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.Alert = Alert;
/**
* @name alertSourceRouter
* @description alert http router
* @type {express.Router}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.alertSourceRouter = alertSourceRouter;
/**
* @name alertRouter
* @description alert http router
* @type {express.Router}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.alertRouter = alertRouter;
/**
* @name apiVersion
* @description http router api version
* @type {String}
*
* @author lally elias <[email protected]>
* @since 1.0.0
* @version 0.1.0
*/
exports.apiVersion = alertRouter.version;
/* export app */
Object.defineProperty(exports, 'app', {
get() {
/* @todo bind oauth middlewares authenticate, token, authorize */
mount(alertSourceRouter);
mount(alertRouter);
return app;
},
});