-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
32 lines (24 loc) · 870 Bytes
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Application, Router } from "https://deno.land/x/[email protected]/mod.ts"
import { oakCors } from "https://deno.land/x/[email protected]/mod.ts"
import { getSchoolInfo } from "./data/GetSchool.ts"
import { getSchoolMeal } from "./data/GetMeal.ts"
const app = new Application()
const router = new Router()
const port = 8000
router
.get("/",(ctx) => {
ctx.response.body = "SIF Backend API, Made with Neis API.";
})
.get("/api/info/:school", async (ctx) => {
const school_name = ctx.params.school
ctx.response.body = await getSchoolInfo(school_name)
})
.get("/api/meal/:school", async (ctx) => {
const school_name = ctx.params.school
ctx.response.body = await getSchoolMeal(school_name)
})
app.use(router.routes())
app.use(router.allowedMethods())
app.use(oakCors())
console.log(`http://localhost:${port}/`)
app.listen({port: port})