mia-hot-start
v2.0.0
Published
A very opinionated Fastify Plugin to kickstart your project
Readme
Mia Hot Start
A very opinionated Fastify Plugin to kickstart your project.
It combines the utilities of lc39 and custom-plugin-lib and gives them as an idiomatic Fastify plugin without custom types.
Getting Started
Install
To install the package you can run:
npm install mia-hot-startUsage
To use the plugin, simply register it after creating an instance of Fastify:
import MiaHotStart from 'mia-hot-start'
const schema = {
type: 'object',
properties: {
HTTP_PORT: { type: 'number', default: 3000 },
LOG_LEVEL: { type: 'string', default: 'trace' },
},
}
const fastify = Fastify()
await fastify.register(MiaHotStart, {
envSchema: schema,
logLevelEnvKey: 'LOG_LEVEL',
})Remember to await the plugin so that all the configurations can be loaded before continuing.
Functionalities
The plugin provides you out of the box:
- env schema handling via fastify-env
- logging enhancement
- metrics exposed to Prometheus via fastify-metrics
- graceful shutdown catching the Kubernetes signals
- status routes for Kubernetes (
/-/ready,/-/healthzand/-/check-up) - OpenAPI spec generation and a Swagger Viewer via fastify-swagger and fastify-swagger-ui
- an HTTP client based on Axios with pre-built handling of platform headers and logging
- handling of platform headers via Fastify request decorators
