v2
yutent 2023-10-31 18:52:54 +08:00
parent e3ab578088
commit 566432e529
3 changed files with 12 additions and 10 deletions

View File

@ -19,11 +19,7 @@ export default {
db: 0 db: 0
} }
}, },
jwt: {
ttl: 3600 * 24 * 7,
level: 0, // 校验级别, 0: 不校验客户端, 2: ua, 4: ip, 6: ua + ip
secret: 'it_is_secret_key' // jwt密钥, 使用时请修改
},
spa: false, // 单路由模式, 即无论是访问路径是什么, 永远只会调用 \apps\index\index() spa: false, // 单路由模式, 即无论是访问路径是什么, 永远只会调用 \apps\index\index()
website: 'localhost', website: 'localhost',
domain: '', // cookie域, 默认等于website domain: '', // cookie域, 默认等于website

View File

@ -29,6 +29,8 @@ class Five {
#modules = {} #modules = {}
#middlewares = [createCors()] #middlewares = [createCors()]
#server = null
constructor() { constructor() {
readonlyProp(this, 'state', Object.create(null)) readonlyProp(this, 'state', Object.create(null))
} }
@ -65,6 +67,12 @@ class Five {
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
get server(){
return this.#server
}
/*------------------------------------------------------------------------*/
// 注册属性到全局Five对象 // 注册属性到全局Five对象
set(obj) { set(obj) {
for (let i in obj) { for (let i in obj) {
@ -148,15 +156,13 @@ class Five {
} }
run() { run() {
let server = http.createServer() this.#server = http.createServer()
this.server = server
// this.#loadBuildIn() // this.#loadBuildIn()
// 路由中间件要在最后 // 路由中间件要在最后
this.use(createRouter()) this.use(createRouter())
server this.#server
.on('request', (req, res) => { .on('request', (req, res) => {
let request = new Request(req, res) let request = new Request(req, res)
let response = new Response(req, res) let response = new Response(req, res)

View File

@ -19,7 +19,7 @@
"devDependencies": {}, "devDependencies": {},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/bytedo/gmf.core.git" "url": "https://git.wkit.fun/gm5/core.git"
}, },
"keywords": [ "keywords": [
"five, fivejs, node-five, five.js, nodejs, mvc, koa, express" "five, fivejs, node-five, five.js, nodejs, mvc, koa, express"