@scaleleap/fastify
v1.0.13
Published
Fastify helpers
Downloads
1
Readme
📦 @scaleleap/fastify
Fastify helpers.
Usage
import { createServer, createRoute, createSchema, typebox } from '../src'
import { createLogger } from '@scaleleap/logger'
const { server, listen } = createServer({
logger: createLogger(),
})
server.route(
createRoute(
// same params as server.route(...)
{
method: 'GET',
url: '/',
handler: async (req, res) => ({ page: req.query.page }),
},
// creates a JSON Schema validator for the request, fully type inferred
createSchema({
querystring: typebox.Type.Object({
page: typebox.Type.Number({ minimum: 1, maximum: 99 }),
}),
}),
),
)
// has sane defaults for port and address
listen()
You can also find the runnable example in test/server.ts
Download & Installation
$ npm i -s @scaleleap/fastify
Contributing
This repository uses Conventional Commit style commit messages.
Authors or Acknowledgments
- Roman Filippov (Scale Leap)
License
This project is licensed under the MIT License.