mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: add validation before creating session
This commit is contained in:
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))
|
||||
|
||||
Reference in new issue
Block a user