feat: add validation before creating session

This commit is contained in:
wancat committed 2023-11-01 22:59:32 +08:00
1 parent bcfdf15559
commit d4000eb5a6
3 files changed
+26 -4

No files matched your search

@@ -1,3 +1,4 @@
import { matchedData } from 'express-validator'
import { Session } from '@linux-odyssey/models'
import {
createNewSession,
@@ -40,7 +41,7 @@ export async function getSessionList(req, res) {
}
export async function createSession(req, res) {
const { quest_id } = req.body
const { quest_id } = matchedData(req)
try {
const session = await createNewSession(req.user, quest_id)
res.status(201).json(sessionDetail(session))
@@ -87,7 +88,7 @@ export async function deleteSessionById(req, res) {
}
export async function getOrCreateSession(req, res) {
const { quest_id } = req.body
const { quest_id } = matchedData(req)
try {
const session = await getOrCreateActiveSession(req.user, quest_id)
res.json(sessionDetail(session))