@scaleleap/fastify
TypeScript icon, indicating that this package has built-in type declarations

1.0.13 • Public • Published

📦 @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

License

This project is licensed under the MIT License.

Badges

GitHub Workflow Status NPM License Coveralls Semantic Release

/@scaleleap/fastify/

    Package Sidebar

    Install

    npm i @scaleleap/fastify

    Weekly Downloads

    0

    Version

    1.0.13

    License

    MIT

    Unpacked Size

    22.8 kB

    Total Files

    22

    Last publish

    Collaborators

    • scalebot
    • moltar