change to use session for auth

+ replace BearerAuth to cookieAuth in swagger
+ add swagger.yaml to nodemon watch list
This commit is contained in:
wancat committed 2023-09-17 11:27:37 +08:00
1 parent a6d02f2616
commit be5cd152a9
13 files changed
+216 -71

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import session from 'express-session'
import MongoStore from 'connect-mongo'
import config from '../config.js'
export default (db) => {
console.log(db.constructor.name)
return session({
secret: config.jwtSecret,
resave: false,
saveUninitialized: false,
cookie: {
httpOnly: true,
},
store: MongoStore.create({
mongoUrl: config.db,
collectionName: 'loginSessions',
}),
})
}