17 lines
507 B
TypeScript
17 lines
507 B
TypeScript
|
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});
|
||
|
},
|
||
|
}
|