
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@fastify/restartable
Advanced tools
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.
npm i @fastify/restartable
import { restartable } from '@fastify/restartable'
async function createApp (fastify, opts) {
const app = fastify(opts)
app.get('/restart', async () => {
await app.restart()
return { status: 'ok' }
})
app.addHook('onClose', async () => {
if(!app.closingRestartable) {
console.log('closing the app because of restart')
}
else{
console.log('closing the app because server is stopping')
}
})
return app
}
const app = await restartable(createApp, { logger: true })
const host = await app.listen({ port: 3000 })
console.log('server listening on', host)
// call restart() if you want to restart
process.on('SIGUSR1', () => {
console.log('Restarting the server')
app.restart()
})
process.once('SIGINT', () => {
console.log('Stopping the server')
app.close()
})
preRestart
- called before creating a new app instance and closing an
existing one. The hook is called with the current app instance as an argument.
Use it to close any resources that you don't want to be shared between the
app instances.
onRestart
- called after the new app instance is created and the old one
is closed. The hook is called with the new app instance as an argument.
Example:
async function createApplication (fastify, opts) {
console.log('creating new app instance')
return fastify(opts)
}
const app = await restartable(createApplication)
app.addPreRestartHook(async (app) => {
console.log('preRestart hook called')
})
app.addOnRestartHook(async (app) => {
console.log('onRestart hook called')
})
await app.restart()
Output:
preRestart hook called
creating new app instance
onRestart hook called
Licensed under MIT.
FAQs
Restart Fastify without losing a request
The npm package @fastify/restartable receives a total of 723 weekly downloads. As such, @fastify/restartable popularity was classified as not popular.
We found that @fastify/restartable demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 20 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.