-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathroutes.ts
More file actions
24 lines (20 loc) · 718 Bytes
/
routes.ts
File metadata and controls
24 lines (20 loc) · 718 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
import type { Hono } from 'hono';
import { HTTPException } from 'hono/http-exception';
export function addRoutes(app: Hono<{ Bindings?: { E2E_TEST_DSN: string } }>): void {
app.get('/', c => {
return c.text('Hello Hono!');
});
app.get('/test-param/:paramId', c => {
return c.json({ paramId: c.req.param('paramId') });
});
app.get('/error/:cause', c => {
throw new Error('This is a test error for Sentry!', {
cause: c.req.param('cause'),
});
});
app.get('/http-exception/:code', c => {
// oxlint-disable-next-line typescript/no-explicit-any
const code = Number(c.req.param('code')) as any;
throw new HTTPException(code, { message: `HTTPException ${code}` });
});
}