generated from stabledata/surface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsurface.app.ts
33 lines (25 loc) · 922 Bytes
/
surface.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
32
33
import { Hono } from "hono";
import type { Dependencies } from './surface.app.ctx.js';
import { handleStaticAssets } from './handlers/assets.service.js';
import { pingRouteHandler } from './handlers/ping.handler.js';
import { viewRouteHandler } from './handlers/view.handler.js';
import { errorHandler } from './handlers/error.handlers.js';
import dotenv from "dotenv";
dotenv.config();
export const app = (inject: Partial<Dependencies> = {}) => {
return (
new Hono()
.use("/assets/*", handleStaticAssets(inject))
// ping example (healthcheck)
.route("/ping", pingRouteHandler(inject))
// views
.route("/*", viewRouteHandler(inject))
// handle errors
.onError(errorHandler(inject))
);
};
// export the app type for for RPC
export type AppType = ReturnType<typeof app>;
// hono vite dev server middleware needs a default export
const ha = app();
export default ha;