Nuxt脚手架创建项目后对server中的index.js所做的修改
程序员文章站
2024-02-13 20:46:04
...
添加
import mongoose from "mongoose"
import bodyParser from "koa-bodyparser"
import session from "koa-generic-session"
import Redis from "koa-redis"
import json from "koa-json"
import dbConfig from './dbs/config'
import passport from "./interface/utils/passport"
import users from "./interface/users"
app.keys = ['mt','keyskeys']
app.proxy = true
app.use(session({
key:'mt',prefix:'mt:uid',store: new Redis()
}))
app.use(bodyParser({
extendTypes:['json','from','text']
}))
app.use(json())
mongoose.connect(dbConfig.dbs,{
useNewUrlParser:true
})
app.use(passport.initialize())
app.use(passport.session())
使用users路由
app.use(users.routes()).use(users.allowedMethods())