# Using npm
npm install h3-typebox
# Using yarn
yarn install h3-typebox
# Using pnpm
pnpm install h3-typebox
import { createServer } from 'http'
import { createApp } from 'h3'
import { validateBody, validateQuery, Type } from 'h3-typebox'
const app = createApp()
app.use('/', async (event) => {
// Validate body
const body = await validateBody(event, Type.Object({
optional: Type.Optional(Type.String()),
required: Type.Boolean(),
}))
// Validate query
const query = validateQuery(event, Type.Object({
required: Type.String(),
}))
})
createServer(app).listen(process.env.PORT || 3000)
See how to define your schema with Type
on TypeBox documentation.
- Clone this repository
- Install dependencies using
pnpm install
- Run interactive tests using
pnpm dev
Made with ๐
Published under MIT License.