mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: delete "deleteSession" method, validate questId and sessionId
This commit is contained in:
1 parent
a7422853fa
commit
5df4967a85
12 files changed
+67
-99
No files matched your search
@@ -1,8 +1,20 @@
|
||||
import { check } from 'express-validator'
|
||||
import { checkQuestId } from './questValidator.js'
|
||||
import { noError } from '../../middleware/validator.js'
|
||||
|
||||
const checkQuestId = () =>
|
||||
check('quest_id').notEmpty().isString().isLowercase().isLength({ max: 64 })
|
||||
const checkSessionStatus = () =>
|
||||
check('status')
|
||||
.isString()
|
||||
.custom((value) => ['active', 'inactive', 'finished'].includes(value))
|
||||
|
||||
export const checkSessionId = () =>
|
||||
check('sessionId').notEmpty().isString().isMongoId()
|
||||
|
||||
export const sessionListValidator = [
|
||||
checkQuestId(),
|
||||
checkSessionStatus(),
|
||||
noError,
|
||||
]
|
||||
export const sessionDetailValidator = [checkSessionId(), noError]
|
||||
export const createSessionValidator = [checkQuestId(), noError]
|
||||
export const activeSessionValidator = [checkQuestId(), noError]
|
||||
Reference in new issue
Block a user