-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
31 lines (26 loc) · 1.17 KB
/
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, isHttpError,Status } from "https://deno.land/x/oak/mod.ts";
import { oakCors } from "https://deno.land/x/cors/mod.ts";
import {Asset} from './.core/app___.ts'
import {router} from './routers/router.ts'
import Conf from './config.ts'
import * as ink from 'https://deno.land/x/ink/mod.ts'
import { log } from './.core/handel.ts'
const port:number = Conf.PORT
const app = new Application()
app.use(log);
app.use(oakCors()); // Enable CORS for All Routes
app.use(router.routes())
app.use(router.allowedMethods())
app.use(Asset)
app.use(async (ctx, next) => {
const start = Date.now();
await next();
const ms = Date.now() - start;
ctx.response.headers.set("X-Response-Time", `${ms}ms`);
});
console.log(ink.colorize('<blue>༼ つ ◕_◕ ༽つ</blue>'));
console.log(ink.colorize('<blue>╔═══════════════════════╗</blue>'));
console.log(ink.colorize('<blue>║ Enjoy it ║</blue>'));
console.log(ink.colorize('<blue>╚═══════════════════════╝</blue>'));
console.log(ink.colorize(`<blue>http://localhost:${port}/</blue>`));
await app.listen({ port });