mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 11:10:11 +08:00
Add quest to API spec
+ Remove timestamps + Add 404 error handling
This commit is contained in:
1 parent
247c75ff84
commit
5e8115be11
3 files changed
+71
-10
No files matched your search
@@ -15,5 +15,9 @@ export async function getQuests(req, res) {
|
||||
export async function getQuestDetail(req, res) {
|
||||
const { name } = req.params
|
||||
const quest = await Quest.findOne({ name })
|
||||
if (!quest) {
|
||||
res.status(404).json({ message: 'Quest not found.' })
|
||||
return
|
||||
}
|
||||
res.json(quest)
|
||||
}
|
||||
@@ -2,15 +2,12 @@ import { model, Schema } from 'mongoose'
|
||||
|
||||
const Quest = model(
|
||||
'Quest',
|
||||
new Schema(
|
||||
{
|
||||
name: String,
|
||||
title: String,
|
||||
order: Number,
|
||||
content: String,
|
||||
},
|
||||
{ timestamps: true }
|
||||
)
|
||||
new Schema({
|
||||
name: String,
|
||||
title: String,
|
||||
order: Number,
|
||||
content: String,
|
||||
})
|
||||
)
|
||||
|
||||
export default Quest
|
||||
Reference in new issue
Block a user