-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
125 lines (116 loc) · 2.58 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
'use strict';
/**
* @module Role
* @name Role
* @description A representation on how a party(or stakeholder) acts or,
* in other words, what role party(or stakeholder) plays in event of
* emergency(or disaster).
*
* It defines set of permissions(or access rights) and responsibilities that
* are applicable to a specific party(ies).
*
* @author lally elias <lallyelias87@gmail.com>
* @licence MIT
* @since 0.1.0
* @version 0.1.0
* @example
*
* const { app } = require('@lykmapipo/role');
* app.start();
*
*/
/* dependencies */
const { pkg } = require('@lykmapipo/common');
const { include } = require('@lykmapipo/include');
const { apiVersion } = require('@lykmapipo/env');
const { app, mount } = require('@lykmapipo/express-common');
const { Permission, permissionRouter } = require('@lykmapipo/permission');
const Role = include(__dirname, 'lib', 'role.model');
const roleRouter = include(__dirname, 'lib', 'role.http.router');
/**
* @name info
* @description package information
* @type {Object}
*
* @author lally elias <lallyelias87@gmail.com>
* @since 1.0.0
* @version 0.1.0
*/
exports.info = pkg(
'name',
'description',
'version',
'license',
'homepage',
'repository',
'bugs',
'sandbox',
'contributors'
);
/**
* @name Permission
* @description Permission model
* @type {mongoose.Model}
*
* @author lally elias <lallyelias87@gmail.com>
* @since 0.1.0
* @version 0.1.0
*/
exports.Permission = Permission;
/**
* @name Role
* @description Role model
* @type {mongoose.Model}
*
* @author lally elias <lallyelias87@gmail.com>
* @since 0.1.0
* @version 0.1.0
*/
exports.Role = Role;
/**
* @name permissionRouter
* @description permission http router
* @type {express.Router}
*
* @author lally elias <lallyelias87@gmail.com>
* @since 0.1.0
* @version 0.1.0
*/
exports.permissionRouter = permissionRouter;
/**
* @name roleRouter
* @description role http router
* @type {express.Router}
*
* @author lally elias <lallyelias87@gmail.com>
* @since 0.1.0
* @version 0.1.0
*/
exports.roleRouter = roleRouter;
/**
* @name apiVersion
* @description http router api version
* @type {String}
*
* @author lally elias <lallyelias87@gmail.com>
* @since 0.1.0
* @version 0.1.0
*/
exports.apiVersion = apiVersion();
/**
* @name app
* @description express app
* @type {Object}
*
* @author lally elias <lallyelias87@gmail.com>
* @since 0.1.0
* @version 0.1.0
*/
Object.defineProperty(exports, 'app', {
get() {
/* @todo bind oauth middlewares authenticate, token, authorize */
mount(permissionRouter);
mount(roleRouter);
return app;
},
});