Skip to content

twilic/fastify

Repository files navigation

@twilic/fastify

Fastify plugin and helpers for Twilic binary request and response bodies.

Install

pnpm add @twilic/fastify fastify @twilic/core

Usage

import Fastify from "fastify";
import { twilicParser, twilicPlugin, twilicReply } from "@twilic/fastify";

const app = Fastify();

await app.register(twilicPlugin);

app.post("/users", { preHandler: twilicParser() }, (request, reply) => {
  return twilicReply(reply, { ok: true, received: request.twilicBody });
});

// or use the reply decorator:
app.get("/ping", (_request, reply) => reply.twilic({ pong: true }));

API

  • TWILIC_CONTENT_TYPE
  • parseTwilic(request)
  • twilicReply(reply, value, init?)
  • twilicParser(options?)
  • twilicPlugin
  • createTwilicFastify(codec?)

Changelog

See docs/CHANGELOG.md.

Publish to npm

The package ships build artifacts from dist/.

Local dry run:

pnpm build
pnpm pack

GitHub Actions publish uses npm trusted publishing (OIDC)—no long-lived NPM_TOKEN secret.

One-time setup on npmjs.com: open the package → SettingsTrusted PublisherGitHub Actions, then set Organization or user twilic, Repository fastify, and Workflow filename publish-npm.yml (exact name, including .yml). See also GitHub Actions OIDC.

Release steps:

  1. Update docs/CHANGELOG.md and bump version in package.json.
  2. Create and push matching tag v<version>.

Example:

git tag v0.1.1
git push origin v0.1.1

The workflow .github/workflows/publish-npm.yml verifies tag/version match, runs tests, and then runs npm publish (OIDC authentication via id-token: write).

Contributing

See docs/CONTRIBUTING.md.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Fastify plugin and helpers for Twilic binary request and response bodies.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors