-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
33 lines (26 loc) · 726 Bytes
/
main.ts
File metadata and controls
33 lines (26 loc) · 726 Bytes
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
import { Hono } from 'hono';
import { cors } from 'hono/cors';
import { logger } from 'hono/logger';
import { prettyJSON } from 'hono/pretty-json';
import { secureHeaders } from 'hono/secure-headers';
import indexRouter from './routes/index.ts';
const app = new Hono();
// Middlewares
app.use('*', logger(), cors(), prettyJSON(), secureHeaders());
// Routes
app.route('/', indexRouter);
app.notFound((c) => {
return c.json({
message: '404 Not Found',
});
});
app.onError((error, c) => {
return c.json(error);
});
const PORT = Number.parseInt(Deno.env.get('PORT') || '8000');
Deno.serve({
port: PORT,
onListen: ({ port }) => {
console.info(`Listening on http://localhost:${port}`);
},
}, app.fetch);