npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wooksjs/fastify-adapter

v0.7.0

Published

Fastify Adapter for Wooks — use Wooks composables with Fastify

Readme

@wooksjs/fastify-adapter

Use Wooks composables with Fastify. This adapter lets you register Wooks-style route handlers on top of an existing Fastify app — unmatched requests automatically fall through to Fastify's not-found handler.

Install

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

Quick Start

import Fastify from 'fastify'
import { WooksFastify } from '@wooksjs/fastify-adapter'
import { useRouteParams, useRequest, HttpError } from '@wooksjs/event-http'

const app = Fastify()
const wooks = new WooksFastify(app)

// Return values become the response body
wooks.get('/hello/:name', () => {
    const { get } = useRouteParams()
    return { hello: get('name') }
})

// Async handlers work out of the box
wooks.post('/upload', async () => {
    const { rawBody } = useRequest()
    const body = await rawBody()
    return { received: body.length }
})

// Throw HttpError for error responses
wooks.get('/protected', () => {
    throw new HttpError(403, 'Forbidden')
})

app.listen({ port: 3000 }, () => console.log('listening on 3000'))

How It Works

WooksFastify extends WooksHttp and registers a catch-all route in Fastify. When a request comes in:

  1. Wooks checks if a matching route is registered
  2. If matched — the Wooks handler runs with full composable support
  3. If not matched — the request falls through to Fastify's not-found handler

This means you can use Wooks composables for your route handlers while still leveraging Fastify's plugin ecosystem:

import Fastify from 'fastify'
import { WooksFastify } from '@wooksjs/fastify-adapter'

const app = Fastify()

// Wooks handles these routes
const wooks = new WooksFastify(app)
wooks.get('/api/users', () => {
    return [{ id: 1, name: 'Alice' }]
})

app.listen({ port: 3000 })

API

new WooksFastify(fastifyApp, options?)

Creates a new adapter instance and registers a catch-all route on the Fastify app.

| Option | Type | Default | Description | | ---------------- | -------------------------- | ------- | --------------------------------------------------------------------------------- | | raise404 | boolean | false | Return 404 from Wooks for unmatched routes instead of using Fastify's not-found | | onNotFound | () => unknown | — | Custom handler for unmatched routes | | logger | TConsoleBase | — | Custom logger instance | | router | object | — | Router options (ignoreTrailingSlash, ignoreCase, cacheLimit) | | requestLimits | object | — | Default request body size limits | | defaultHeaders | Record<string, string> | — | Headers added to every response | | responseClass | typeof WooksHttpResponse | — | Custom response class |

Route Methods

wooks.get(path, handler)
wooks.post(path, handler)
wooks.put(path, handler)
wooks.patch(path, handler)
wooks.delete(path, handler)
wooks.head(path, handler)
wooks.options(path, handler)
wooks.all(path, handler)

Handlers take no arguments — use composables to access request data:

wooks.get('/users/:id', () => {
    const { get } = useRouteParams()
    const { method, url, rawBody, getIp } = useRequest()
    const headers = useHeaders()
    const response = useResponse()

    response.setHeader('x-custom', 'value')
    return { id: get('id') }
})

wooks.listen(...args)

Starts the Fastify server and returns a promise that resolves when listening.

await wooks.listen({ port: 3000 })

wooks.close()

Stops the server.

await wooks.close()

Available Composables

These come from @wooksjs/event-http and work inside any Wooks handler:

| Composable | Purpose | | -------------------- | ------------------------------------------- | | useRequest() | Request method, URL, headers, body, IP | | useRouteParams() | Route parameters (:id, etc.) | | useHeaders() | Request headers | | useResponse() | Set status, headers, cookies, cache control | | useCookies() | Read request cookies | | useUrlParams() | URL query parameters | | useAuthorization() | Parse Authorization header | | useAccept() | Check Accept header | | useLogger() | Event-scoped logger |

See the Wooks documentation for full composable reference.

Development

npm install       # install dependencies
npm test          # run tests (vitest)
npm run build     # build for distribution
npm run lint      # lint with oxlint
npm run fmt       # format with oxfmt

License

MIT