Add lite market endpoint
This commit is contained in:
parent
d83e103fab
commit
7e46188107
23
web/pages/api/v0/market/[id]/lite.ts
Normal file
23
web/pages/api/v0/market/[id]/lite.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import { NextApiRequest, NextApiResponse } from 'next'
|
||||||
|
import { getContractFromId } from 'web/lib/firebase/contracts'
|
||||||
|
import { applyCorsHeaders, CORS_UNRESTRICTED } from 'web/lib/api/cors'
|
||||||
|
import { ApiError, toLiteMarket, LiteMarket } from '../../_types'
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
req: NextApiRequest,
|
||||||
|
res: NextApiResponse<LiteMarket | ApiError>
|
||||||
|
) {
|
||||||
|
await applyCorsHeaders(req, res, CORS_UNRESTRICTED)
|
||||||
|
const { id } = req.query
|
||||||
|
const contractId = id as string
|
||||||
|
|
||||||
|
const contract = await getContractFromId(contractId)
|
||||||
|
|
||||||
|
if (!contract) {
|
||||||
|
res.status(404).json({ error: 'Contract not found' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
res.setHeader('Cache-Control', 'max-age=0')
|
||||||
|
return res.status(200).json(toLiteMarket(contract))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user