-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathindex.ts
More file actions
35 lines (27 loc) · 677 Bytes
/
index.ts
File metadata and controls
35 lines (27 loc) · 677 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
34
35
import { sentry } from '@sentry/hono/cloudflare';
import { Hono } from 'hono';
interface Env {
SENTRY_DSN: string;
}
const app = new Hono<{ Bindings: Env }>();
app.use(
'*',
sentry(app, {
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
}),
);
app.get('/', c => {
return c.text('Hello from Hono on Cloudflare!');
});
app.get('/json', c => {
return c.json({ message: 'Hello from Hono', framework: 'hono', platform: 'cloudflare' });
});
app.get('/error/:param', () => {
throw new Error('Test error from Hono app');
});
app.get('/hello/:name', c => {
const name = c.req.param('name');
return c.text(`Hello, ${name}!`);
});
export default app;