Copyright (c) 2025 Michael Welter me@mikinho.com
A simple and lightweight Fastify plugin to expose your application's name and version from package.json.
It automatically handles content negotiation to respond with JSON, HTML, or plain text based on the client's Accept header.
Install the package and its required peer dependency, fastify.
npm install @ynode/versionify fastify
You can pass an options object as the second argument to register.
| Option | Type | Default | Description |
|---|---|---|---|
prefix |
string |
undefined |
Optional Fastify route prefix. |
path |
string |
"/version" |
The URL path to expose the version endpoint. |
pkg |
object |
undefined |
A package.json object. If not provided, the plugin will automatically load package.json from your project root. |
import versionify from "@ynode/versionify";
// Register the plugin with default options
await fastify.register(versionify, { prefix: "/~" });import versionify from "@ynode/versionify";
// Register with a custom path
await fastify.register(versionify, {
path: "/info"
});Now the endpoint will be available at http://localhost:3000/info.
To release a new version, use the included Makefile.
make release VERSION=1.2.3This command will:
- Check that
npmandpackage.jsonexist. - Run
npm versionto updatepackage.jsonand create a git tag. - Publish the package to npm.
- Push the commit and tags to the git remote.
This project is licensed under the MIT Lisence.