Upgrade package, Implement fake API, version info get from API. Waiting for real API
This commit is contained in:
parent
faaae95956
commit
5b2d7ea68d
16 changed files with 853 additions and 615 deletions
6
cms/src/routes/api/competitive/+server.ts
Normal file
6
cms/src/routes/api/competitive/+server.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import type {RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import exams from "$lib/data/competitive-exam.json"
|
||||
export const GET: RequestHandler = async () => {
|
||||
return json(exams)
|
||||
}
|
||||
14
cms/src/routes/api/competitive/[id]/+server.ts
Normal file
14
cms/src/routes/api/competitive/[id]/+server.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import type { RequestEvent, RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import exams from "$lib/data/competitive-exam.json"
|
||||
export const GET: RequestHandler = async ({params}: RequestEvent) => {
|
||||
const id = params.id+""
|
||||
//const exams = await getCompetitiveExams()
|
||||
const post = exams.find((q)=>{
|
||||
return q.id===id
|
||||
})
|
||||
if(!post)
|
||||
return json({message:`ไม่พบการสอบแข่งขัน ID= ${id}`},{status:404})
|
||||
return json(post)
|
||||
}
|
||||
|
||||
31
cms/src/routes/api/content/+server.ts
Normal file
31
cms/src/routes/api/content/+server.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import type { RequestEvent, RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import home_content from "$lib/data/content/home.html?raw"
|
||||
import about_content from "$lib/data/content/about.html?raw"
|
||||
import qualifying_content from "$lib/data/content/qualifying.html?raw"
|
||||
import competitive_content from "$lib/data/content/competitive.html?raw"
|
||||
export const GET: RequestHandler = async ({url}: RequestEvent) => {
|
||||
let content = ""
|
||||
const page= url.searchParams.get("page") ?? 'nopage'
|
||||
switch (page) {
|
||||
case "home":
|
||||
content = home_content
|
||||
break;
|
||||
case "qualifying":
|
||||
content = qualifying_content
|
||||
break;
|
||||
case "competitive":
|
||||
content = competitive_content
|
||||
break;
|
||||
case "about":
|
||||
content = about_content
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//slience error just send empty content if not found
|
||||
if(!content)
|
||||
console.log(`Request content ${page} not found`)
|
||||
return json({content})
|
||||
|
||||
}
|
||||
8
cms/src/routes/api/info/+server.ts
Normal file
8
cms/src/routes/api/info/+server.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import ver from "$lib/ver.json"
|
||||
import {json} from '@sveltejs/kit'
|
||||
import type { RequestHandler } from './$types'
|
||||
export const GET: RequestHandler = async () => {
|
||||
const version = ver.version
|
||||
const builddate = ver.builddate
|
||||
return json({version,builddate})
|
||||
}
|
||||
6
cms/src/routes/api/qualifying/+server.ts
Normal file
6
cms/src/routes/api/qualifying/+server.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import type { RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import exams from "$lib/data/qualify-exam.json"
|
||||
export const GET: RequestHandler = async () => {
|
||||
return json(exams)
|
||||
}
|
||||
14
cms/src/routes/api/qualifying/[id]/+server.ts
Normal file
14
cms/src/routes/api/qualifying/[id]/+server.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import type { RequestEvent, RequestHandler } from './$types'
|
||||
import {json} from '@sveltejs/kit'
|
||||
import exams from "$lib/data/qualify-exam.json"
|
||||
export const GET: RequestHandler = async ({params}: RequestEvent) => {
|
||||
const id = params.id+""
|
||||
//const exams = await getCompetitiveExams()
|
||||
const post = exams.find((q)=>{
|
||||
return q.id===id
|
||||
})
|
||||
if(!post)
|
||||
return json({message:`ไม่พบการสอบแข่งขัน ID= ${id}`},{status:404})
|
||||
return json(post)
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue