-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
46 lines (39 loc) · 1.15 KB
/
server.ts
File metadata and controls
46 lines (39 loc) · 1.15 KB
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
38
39
40
41
42
43
44
45
46
/**
* server.ts
*
* the entrypoint for the web server, handles routing and hosting
*
* by alex prosser
* 9/15/2025
*/
import { route, type Route } from '@std/http/unstable-route';
import { serveDir } from '@std/http/file-server';
import { STEVE } from '@codingap/steve';
import { getNotFoundResponse } from './src/middleware.ts';
import { getLogger } from "./src/logger.ts";
/**
* defined port for the reverse proxy to identify
*/
const PORT = 1337;
// point to the include directory for the rest of the views
STEVE.includeDirectory = './views/includes';
// routing time
import MAIN_ROUTES from './src/routes.ts';
import API_ROUTES from './src/api.ts';
const routers: Route[] = [
...MAIN_ROUTES,
...API_ROUTES,
{
pattern: new URLPattern({ pathname: '/static/*' }),
handler: (request) => serveDir(request, { quiet: true })
}
];
const logger = getLogger();
// serve the routes passed on the object built above
Deno.serve({
port: PORT,
handler: route(routers, getNotFoundResponse),
onListen: () => {
logger.info(`Deno.serve - https://codingap.dev is listening on port ${PORT} (http://localhost:${PORT})`);
}
});