feat: add bun-fullstack agent and update skills
This commit is contained in:
61
.opencode/skills/tech-stack/elysiajs/examples/schema.ts
Normal file
61
.opencode/skills/tech-stack/elysiajs/examples/schema.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { Elysia, t } from 'elysia'
|
||||
|
||||
const app = new Elysia()
|
||||
.model({
|
||||
name: t.Object({
|
||||
name: t.String()
|
||||
}),
|
||||
b: t.Object({
|
||||
response: t.Number()
|
||||
}),
|
||||
authorization: t.Object({
|
||||
authorization: t.String()
|
||||
})
|
||||
})
|
||||
// Strictly validate response
|
||||
.get('/', () => 'hi')
|
||||
// Strictly validate body and response
|
||||
.post('/', ({ body, query }) => body.id, {
|
||||
body: t.Object({
|
||||
id: t.Number(),
|
||||
username: t.String(),
|
||||
profile: t.Object({
|
||||
name: t.String()
|
||||
})
|
||||
})
|
||||
})
|
||||
// Strictly validate query, params, and body
|
||||
.get('/query/:id', ({ query: { name }, params }) => name, {
|
||||
query: t.Object({
|
||||
name: t.String()
|
||||
}),
|
||||
params: t.Object({
|
||||
id: t.String()
|
||||
}),
|
||||
response: {
|
||||
200: t.String(),
|
||||
300: t.Object({
|
||||
error: t.String()
|
||||
})
|
||||
}
|
||||
})
|
||||
.guard(
|
||||
{
|
||||
headers: 'authorization'
|
||||
},
|
||||
(app) =>
|
||||
app
|
||||
.derive(({ headers }) => ({
|
||||
userId: headers.authorization
|
||||
}))
|
||||
.get('/', ({ userId }) => 'A')
|
||||
.post('/id/:id', ({ query, body, params, userId }) => body, {
|
||||
params: t.Object({
|
||||
id: t.Number()
|
||||
}),
|
||||
transform({ params }) {
|
||||
params.id = +params.id
|
||||
}
|
||||
})
|
||||
)
|
||||
.listen(3000)
|
||||
Reference in New Issue
Block a user