handle cors
This commit is contained in:
@@ -7,8 +7,10 @@ await ingestOptions(sourceDataDir);
|
||||
*/
|
||||
|
||||
import fastify from 'fastify'
|
||||
import cors from '@fastify/cors'
|
||||
|
||||
const server = fastify()
|
||||
await server.register(cors, {});
|
||||
|
||||
server.get('/ping', async (request, reply) => {
|
||||
return 'pong\n'
|
||||
@@ -18,6 +20,18 @@ server.get('/option_quotes/underlyings', async (request, reply) => {
|
||||
const underlyings = (await sql`SELECT DISTINCT "underlying" FROM "option_quote";`).map(x=>x.underlying);
|
||||
reply.status(200).send(underlyings);
|
||||
})
|
||||
server.get<{
|
||||
Params: {underlying:string},
|
||||
}>('/option_quotes/:underlying/quote_dates', async (request, reply) => {
|
||||
const options_quotes = (await sql`
|
||||
SELECT DISTINCT "quote_date"
|
||||
FROM "option_quote"
|
||||
WHERE
|
||||
"underlying" = ${request.params.underlying}
|
||||
ORDER BY "quote_date";`
|
||||
).map(x=>x.quote_date);
|
||||
reply.status(200).send(options_quotes);
|
||||
})
|
||||
server.get<{
|
||||
Params: {underlying:string, quote_date:string},
|
||||
}>('/option_quotes/:underlying/:quote_date', async (request, reply) => {
|
||||
|
||||
Reference in New Issue
Block a user