v1
宇天 2020-09-20 23:11:53 +08:00
parent 97413d2b9c
commit cd1fca1858
1 changed files with 17 additions and 17 deletions

View File

@ -9,7 +9,7 @@ import 'es.shim' // 加载拓展方法
import http from 'http' import http from 'http'
import path from 'path' import path from 'path'
import fs from 'iofs' import fs from 'iofs'
import Ioredis from 'ioredis' // import Ioredis from 'ioredis'
import Request from '@gm5/request' import Request from '@gm5/request'
import Response from '@gm5/response' import Response from '@gm5/response'
import Cookie from '@gm5/cookie' import Cookie from '@gm5/cookie'
@ -20,7 +20,7 @@ import Log from './lib/log.js' //基础日志记录工具
import routerWare from './middleware/router.js' import routerWare from './middleware/router.js'
import credentialsWare from './middleware/credentials.js' import credentialsWare from './middleware/credentials.js'
// import cookieWare from './middleware/cookie.js' // import cookieWare from '@gm5/cookie'
// import sessionWare from './module/session.js' // import sessionWare from './module/session.js'
var log = console.log var log = console.log
@ -49,19 +49,19 @@ export default class Five {
this.set({ domain, session }) this.set({ domain, session })
// 这里只创建session的存储器, 而初始化操作在中间件中进行 // 这里只创建session的存储器, 而初始化操作在中间件中进行
if (session.type === 'redis') { // if (session.type === 'redis') {
hideProperty( // hideProperty(
this, // this,
'__SESSION_STORE__', // '__SESSION_STORE__',
new Ioredis({ // new Ioredis({
host: session.db.host || '127.0.0.1', // host: session.db.host || '127.0.0.1',
port: session.db.port || 6379, // port: session.db.port || 6379,
db: session.db.db || 0 // db: session.db.db || 0
}) // })
) // )
} else { // } else {
hideProperty(this, '__SESSION_STORE__', {}) // hideProperty(this, '__SESSION_STORE__', {})
} // }
// 将session和cookie的中间件提到最前 // 将session和cookie的中间件提到最前
// 以便用户自定义的中间件可以直接操作session和cookie // 以便用户自定义的中间件可以直接操作session和cookie