feat: add bun-fullstack agent and update skills
This commit is contained in:
33
.agent/skills/tech-stack/elysiajs/examples/body-parser.ts
Normal file
33
.agent/skills/tech-stack/elysiajs/examples/body-parser.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Elysia, t } from 'elysia'
|
||||
|
||||
const app = new Elysia()
|
||||
// Add custom body parser
|
||||
.onParse(async ({ request, contentType }) => {
|
||||
switch (contentType) {
|
||||
case 'application/Elysia':
|
||||
return request.text()
|
||||
}
|
||||
})
|
||||
.post('/', ({ body: { username } }) => `Hi ${username}`, {
|
||||
body: t.Object({
|
||||
id: t.Number(),
|
||||
username: t.String()
|
||||
})
|
||||
})
|
||||
// Increase id by 1 from body before main handler
|
||||
.post('/transform', ({ body }) => body, {
|
||||
transform: ({ body }) => {
|
||||
body.id = body.id + 1
|
||||
},
|
||||
body: t.Object({
|
||||
id: t.Number(),
|
||||
username: t.String()
|
||||
}),
|
||||
detail: {
|
||||
summary: 'A'
|
||||
}
|
||||
})
|
||||
.post('/mirror', ({ body }) => body)
|
||||
.listen(3000)
|
||||
|
||||
console.log('🦊 Elysia is running at :8080')
|
||||
Reference in New Issue
Block a user