Stock/routes/api/kosdaq.ts

17 lines
507 B
TypeScript
Raw Normal View History

2023-07-23 00:32:54 +09:00
import { Handlers } from "$fresh/server.ts";
import {DB} from "https://deno.land/x/sqlite/mod.ts";
export const handler: Handlers = {
async GET(req, _ctx): Promise<Response> {
const headers = new Headers({
"content-type": "application/json"
});
const db = new DB("stock.db");
const conn = db.query("SELECT Code,Name FROM KOSDAQ");
const body = conn.map(row=>({
code: row[0],
name: row[1]
}))
return new Response(JSON.stringify(body), {headers});
},
}