-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (36 loc) · 1.14 KB
/
index.js
File metadata and controls
43 lines (36 loc) · 1.14 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
'use strict';
/**
* Copyright (c) 2021 Copyright bp All Rights Reserved.
* Author: brian.li
* Date: 2021-03-11 13:53
* Desc:
*/
var afterRoute = require('./libs/afterRoute');
var beforeRoute = require('./libs/beforeRoute');
var initiator = require('./libs/initiator');
var defaultCfg = require('./libs/defaultCfg');
var path = require('path');
exports.name = "middleware-koa-session";
exports.middleware = function (cfg) {
cfg = cfg || {};
cfg.keys = cfg.keys || defaultCfg.keys;
cfg.key = cfg.key || defaultCfg.key;
cfg.maxAge = cfg.maxAge || defaultCfg.maxAge;
cfg.autoCommit = cfg.autoCommit || defaultCfg.autoCommit;
cfg.overwrite = cfg.overwrite || defaultCfg.overwrite;
cfg.httpOnly = cfg.httpOnly || defaultCfg.httpOnly;
cfg.signed = cfg.signed || defaultCfg.signed;
cfg.rolling = cfg.rolling || defaultCfg.rolling;
cfg.renew = cfg.renew || defaultCfg.renew;
cfg.secure = cfg.secure || defaultCfg.secure;
cfg.sameSite = cfg.sameSite || defaultCfg.sameSite;
return {
type: 'koa',
name: exports.name,
afterRoute,
beforeRoute,
initiator: (app, bpApp) => {
return initiator(app, cfg, bpApp);
}
};
}