Clean data and update mockup api spec
This commit is contained in:
parent
aaff6c92b8
commit
9012d03515
13 changed files with 171 additions and 77 deletions
|
|
@ -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)
|
||||
}
|
||||
8
cms/src/routes/api/dev/+server.ts
Normal file
8
cms/src/routes/api/dev/+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})
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue