Clean data and update mockup api spec

This commit is contained in:
schooltechx 2023-04-08 11:27:09 +07:00
parent aaff6c92b8
commit 9012d03515
13 changed files with 171 additions and 77 deletions

View file

@ -1,6 +1,19 @@
import type {RequestHandler } from './$types'
import {json} from '@sveltejs/kit'
import type {Exam} from '$lib/data/CMSDataType'
import exams from "$lib/data/competitive-exam.json"
export const GET: RequestHandler = async () => {
return json(exams)
import type { RequestEvent,RequestHandler } from './$types'
export const GET: RequestHandler = async ({url}: RequestEvent) => {
const limit= Number(url.searchParams.get("limit"))
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let ex:Exam[] = exams.map(({files,images,detail,...minimal})=>{
if(images && images[0]){
const image = images[0].url
return {...minimal,image}
}
return minimal
})
if(limit>0){
ex = exams.slice(0,limit)
}
return json(ex)
}

View 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})
}

View file

@ -1,9 +1,6 @@
import ver from "$lib/ver.json"
import {json} from '@sveltejs/kit'
import info from "$lib/data/info.json"
import type { RequestHandler } from './$types'
export const GET: RequestHandler = async () => {
const version = ver.version
const builddate = ver.builddate
return json({...info,version,builddate})
return json(info)
}

View file

@ -1,6 +1,19 @@
import type { RequestHandler } from './$types'
import {json} from '@sveltejs/kit'
import type {Exam} from '$lib/data/CMSDataType'
import exams from "$lib/data/qualify-exam.json"
export const GET: RequestHandler = async () => {
return json(exams)
import type { RequestEvent,RequestHandler } from './$types'
export const GET: RequestHandler = async ({url}: RequestEvent) => {
const limit= Number(url.searchParams.get("limit"))
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let ex:Exam[] = exams.map(({files,images,detail,...minimal})=>{
if(images && images[0]){
const image = images[0].url
return {...minimal,image}
}
return minimal
})
if(limit>0){
ex = exams.slice(0,limit)
}
return json(ex)
}