-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
37 lines (27 loc) · 1.03 KB
/
main.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
33
34
35
36
37
// import Application class from Oak module
import {Application as OakApp} from "https://deno.land/x/oak/mod.ts";
// import our middleware
import {authMiddleware} from "./middlewares/auth-middleware.ts";
// import our router class
import {LoremIpsumRouter} from "./routes/lorem-ipsum-router.ts";
// create main function of our program
export function runHttp(): void {
// create new instance of Oak Application
const app = new OakApp();
// add our middleware to our application
app.use(authMiddleware);
// create lorem ipsum router
const loremIpsumRouter = new LoremIpsumRouter();
// add handler to our application
app.use(loremIpsumRouter.routes());
app.use(loremIpsumRouter.allowedMethods());
// start our application and use promise to show server started or not
app.listen({port: 8000});
// show message in console
console.log("Server started on port 8000");
}
// run main function if this file is executed directly
// (not imported as a module)
if (import.meta.main) {
runHttp();
}