JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1778
  • Score
    100M100P100Q112598F
  • License MIT

Restart Fastify without losing a request

Package Exports

  • @fastify/restartable
  • @fastify/restartable/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@fastify/restartable) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@fastify/restartable

Restart Fastify without losing a request.

This module is useful if you want to compose the fastify routes dynamically or you need some remote config. In case of a change, you can restart Fastify.

Install

npm i @fastify/restartable

Usage

import { start } from '@fastify/restartable'

async function myApp (app, opts) {
  // opts are the options passed to start()
  console.log('plugin loaded', opts)

  app.get('/restart', async (req, reply) => {
    await app.restart()
    return { status: 'ok' }
  })
}

const { stop, port, restart, address } = await start({
  protocol: 'http', // or 'https'
  // key: ...,
  // cert: ...,
  // add all other options that you would pass to fastify
  host: '127.0.0.1',
  port: 3000,
  app: myApp
})

console.log('server listening on', address, port)
// call restart() if you want to restart

License

MIT