Added first draft of story
This commit is contained in:
@@ -4,6 +4,7 @@ import type { Calendar } from "~/models/CalendarConfig";
|
||||
|
||||
const querySchema = z.object({
|
||||
id: z.number({ coerce: true }).positive().int().optional(),
|
||||
shortId: z.string().optional(),
|
||||
full: z.boolean({ coerce: true }).optional()
|
||||
})
|
||||
|
||||
@@ -15,16 +16,20 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
const partialFields = `
|
||||
id,
|
||||
shortId:short_id,
|
||||
name,
|
||||
today,
|
||||
months:calendar_months (*)
|
||||
months:calendar_months (*),
|
||||
state
|
||||
`
|
||||
|
||||
const fullFields = `
|
||||
id,
|
||||
shortId:short_id,
|
||||
name,
|
||||
today,
|
||||
months:calendar_months (*),
|
||||
state,
|
||||
events:calendar_events (
|
||||
id,
|
||||
title,
|
||||
@@ -36,6 +41,10 @@ export default defineEventHandler(async (event) => {
|
||||
wiki,
|
||||
category:calendar_event_categories!calendar_events_category_fkey (*),
|
||||
secondaryCategories:calendar_event_categories!calendar_event_categories_links (*)
|
||||
),
|
||||
world:worlds (
|
||||
id,
|
||||
gmId:gm_id
|
||||
)
|
||||
`
|
||||
|
||||
@@ -47,6 +56,10 @@ export default defineEventHandler(async (event) => {
|
||||
output = client.from("calendars").select(partialFields)
|
||||
}
|
||||
|
||||
if (query.shortId) {
|
||||
return output.eq("short_id", query.shortId).limit(1).single<Calendar>()
|
||||
}
|
||||
|
||||
if (query.id) {
|
||||
return output.eq("id", query.id).limit(1).single<Calendar>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user