我有一个简单的Note Api,需要在其中注册CRUD操作的用户。我正在使用express-session存储一些唯一数据,这些数据用于获取此特定用户的注释。我正在使用swagger-ui-express swagger-jsdoc作为文档 登录部分:
auth.signInWithEmailAndPassword(email, password)
.then(() => {
req.session.user = { uid: auth.currentUser.uid, email: auth.currentUser.email
}
console.log(req.session.user)
return res.send(req.session.user)
})
中间件:
let user = req.session.user
if (user === null || user === undefined) {
throw new Error()
}
req.user = user;
next();
Swagger代码,用于获取用户的注释:
/**
* @swagger
* /user/note:
* get:
* description: Get Notes of current user
* responses:
* '200':
* description: A successful response
*/