async function someAsyncRequest() {
const result = await fetch('https://jsonplaceholder.typicode.com/todos/1');
const json = await result.json();
console.log(json);
}
import Router from 'koa-router';
export const router = new Router();
import './example';
import './another-route';
import './one-more-route';
import { router } from '../../router';
router.get('/example', (ctx) => {
ctx.body = { yo: 'Yo dude' };
});
router.post('/example', (ctx) => {
ctx.body = { wow: 'Some POST request goes here' };
});
import Koa from 'koa';
import { router } from './router';
import './routes';
const app = new Koa();
// body parser etc
// app.use(someMiddleware());
// app.use(moreMiddleware());
app.use(router.routes(), router.allowedMethods());
app.listen(8000);