forked from honojs/hono
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsunder.js
40 lines (38 loc) · 1.18 KB
/
sunder.js
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
import { Sunder, Router } from 'sunder'
const sunderRouter = new Router()
sunderRouter.get('/user', (ctx) => {
ctx.response.body = 'User'
})
sunderRouter.get('/user/comments', (ctx) => {
ctx.response.body = 'User Comments'
})
sunderRouter.get('/user/avatar', (ctx) => {
ctx.response.body = 'User Avatar'
})
sunderRouter.get('/user/lookup/email/:address', (ctx) => {
ctx.response.body = 'User Lookup Email Address'
})
sunderRouter.get('/event/:id', (ctx) => {
ctx.response.body = 'Event'
})
sunderRouter.get('/event/:id/comments', (ctx) => {
ctx.response.body = 'Event Comments'
})
sunderRouter.post('/event/:id/comments', (ctx) => {
ctx.response.body = 'POST Event Comments'
})
sunderRouter.post('/status', (ctx) => {
ctx.response.body = 'Status'
})
sunderRouter.get('/very/deeply/nested/route/hello/there', (ctx) => {
ctx.response.body = 'Very Deeply Nested Route'
})
//sunderRouter.get('/static/*', () => {})
sunderRouter.get('/user/lookup/username/:username', (ctx) => {
ctx.response.body = `Hello ${ctx.params.username}`
})
const sunderApp = new Sunder()
sunderApp.use(sunderRouter.middleware)
addEventListener('fetch', (event) => {
event.respondWith(sunderApp.handle(event))
})