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

0.3.0 • Public • Published

Fastify Adapter (Wooks Composables)

!!! This is work-in-progress library, breaking changes are expected !!!


Want to use @wooksjs/event-http but your project is coupled with fastify? This is not a problem with this Fastify Adapter for wooks

Install

npm install @wooksjs/fastify-adapter @wooksjs/event-http

Usage

import fastify from 'fastify'
import { applyFastifyAdapter } from '@wooksjs/fastify-adapter'
import { useBody } from '@wooksjs/http-body'
import { WooksError } from '@wooksjs/event-http'
import { useRouteParams } = from '@wooksjs/event-core'

const app = fastify()

applyFastifyAdapter(app)

app.get('/test/:param', () => {
    const { get } = useRouteParams()
    return { message: 'it works', param: get('param') }
})

app.post('/post', () => {
    const { parseBody } = useBody()
    return parseBody()
})

app.get('/error', () => {
    throw new WooksError(400, 'test error')
})

app.listen(3000, () => console.log('listening 3000'))

Package Sidebar

Install

npm i @wooksjs/fastify-adapter

Weekly Downloads

1

Version

0.3.0

License

MIT

Unpacked Size

12.9 kB

Total Files

6

Last publish

Collaborators

  • mav-rik