欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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())
相关标签: nuxt