Skip to content

Commit 6638a67

Browse files
committed
Create API route
1 parent 275ef28 commit 6638a67

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

server.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
import { Application } from "https://deno.land/x/oak/mod.ts";
1+
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
22

33
const app = new Application();
44

5+
const router = new Router();
6+
7+
app.use(router.routes());
8+
app.use(router.allowedMethods());
9+
10+
router.get("/api/hello-world", ({ response }: { response: any }) => {
11+
console.log(response);
12+
response.body = "Hello World";
13+
console.log(JSON.stringify(response));
14+
});
15+
516
await app.listen({ port: 3000 });

0 commit comments

Comments
 (0)