Skip to content

mia-care/node-hot-starter

 
 

Repository files navigation

Fastify Starter

javascript style guide NPM version NPM downloads Coverage Status CI CodeQL

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 node-hot-starter

Usage

To use the plugin, simply register it after creating an instance of Fastify:

import NodeHotStarter from 'node-hot-starter'

const schema = {
  type: 'object',
  properties: {
    HTTP_PORT: { type: 'number', default: 3000 },
    LOG_LEVEL: { type: 'string', default: 'trace' },
  },
}

const fastify = Fastify()
await fastify.register(NodeHotStarter, {
  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, /-/healthz and /-/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

How To

About

A Fastify Plugin to kickstart your project.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%