-
Notifications
You must be signed in to change notification settings - Fork 9
/
app.js
19 lines (17 loc) · 777 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';
module.exports = function(app) {
if (!app.config.session.httpOnly) {
app.logger.warn('[egg-session]: please set `config.session.httpOnly` to true. It is very dangerous if session can read by client JavaScript.');
}
app.config.coreMiddleware.push('session');
// listen on session's events
app.on('session:missed', ({ ctx, key }) => {
ctx.coreLogger.warn('[session][missed] key(%s)', key);
});
app.on('session:expired', ({ ctx, key, value }) => {
ctx.coreLogger.warn('[session][expired] key(%s) value(%j)', key, app.config.session.logValue ? value : '');
});
app.on('session:invalid', ({ ctx, key, value }) => {
ctx.coreLogger.warn('[session][invalid] key(%s) value(%j)', key, app.config.session.logValue ? value : '');
});
};