-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
31 lines (22 loc) · 782 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
import { Application } from "https://deno.land/x/oak@v11.1.0/mod.ts";
import logger from "https://deno.land/x/oak_logger@1.0.0/mod.ts";
import { green, yellow } from "https://deno.land/std@0.53.0/fmt/colors.ts";
import router from "./routes.ts";
import notFound from "./middlewares/notFound.ts";
const app = new Application();
const port = 4000;
app.use(logger.logger);
app.use(logger.responseTime);
app.use(router.routes());
app.use(router.allowedMethods());
app.use(notFound);
app.addEventListener("listen", ({ secure, hostname, port }) => {
const protocol = secure ? "https://" : "http://";
const url = `${protocol}${hostname ?? "localhost"}:${port}`;
console.log(
`
🚀 ${yellow("Rest")} ${green(url)}
`,
);
});
await app.listen({ port });