-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
27 lines (25 loc) · 815 Bytes
/
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
const Util = require('./Util');
class HttpContext {
/**
* @param {Object} app - Express application instance.
*/
static Initialize(app) {
if (app) {
app.use(Util.middleware);
app.use((req, res, next) => {
Util.set('Request', req);
Util.set('Response', res);
Util.set('Next', next);
Util.set('Session', req.session || null);
next();
});
} else {
throw new Error("express not define");
}
}
static get Request() { return Util.get('Request') }
static get Response() { return Util.get('Response') }
static get Next() { return Util.get('Next') }
static get Session() { return Util.get('Session') }
}
module.exports = HttpContext;