~shreyasminocha/rice-dining-api

206171dfdfb0069377cb238bd94d371b73be9522 — Shreyas Minocha 2 years ago a6950ea
Implement basic REST API
1 files changed, 21 insertions(+), 0 deletions(-)

M src/index.js
M src/index.js => src/index.js +21 -0
@@ 0,0 1,21 @@
import Koa from 'koa';
import Router from 'koa-router';
import { getDailyMenu, getFullWeekMenu } from './scrape.js';

const app = new Koa();
const router = new Router();

router.get('/:servery', async (ctx) => {
	const { servery } = ctx.params;
	ctx.body = await getDailyMenu(servery);
});

router.get('/:servery/full-week-menu', async (ctx) => {
	const { servery } = ctx.params;
	ctx.body = await getFullWeekMenu(servery);
});

app.use(router.routes());
app.use(router.allowedMethods())

app.listen(process.env.PORT || 3000);