Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
fastify-check-runtime-env
Advanced tools
Fastify Plugin to check runtime environment properties
The purpose of this plugin is to let Fastify web applications do some checks
on some properties available at runtime (for example at application startup).
By default any checker method that doesn't satisfy its condition
will throw Error
, but in some cases this is configurable via plugin options.
Note that all Chechers features exposed here are in the the library check-runtime-env. For Semantic Versioning checks, see semver.
A common use case is to throw an exception at application startup,
if Node.js version is not compatible with the one set in package.json
.
const fastify = require('fastify')()
const engines = require('../package.json').engines
// register plugin with some options
fastify.register(require('fastify-check-runtime-env'), {
// nodeStrictCheckAtStartup: true, // same as default
nodeVersionCheckAtStartup: true,
nodeVersionExpected: engines.node
// nodeVersionExpected: '<=10.13.0 >=200.0.0', // sample failing test
// onCheckMismatch: 'exception' // throw an exception // same as default
})
fastify.listen(3000)
// curl http://127.0.0.1:3000/ => returning the home page, if current Node.js versio in compatible with the expected one
In the example folder there are some simple server scripts that uses the plugin (inline but it's the same using it from npm registry).
Fastify ^4.0.1 , Node.js 14 LTS (14.15.0) or later. Note that plugin releases 3.x are for Fastify 3.x, 4.x are for Fastify 4.x, etc. Old plugin releases (0.x) are for Fastify 2.x but are now obsolete.
Source code is all inside main repo: fastify-check-runtime-env.
Documentation generated from source code (library API): here.
The plugin decorate Fastify and expose some functions:
CheckRuntimeEnv
, the checkers implementation, as a class (RuntimeEnvChecker);
but note that to use it you need to wait for this plugin to be
fully loaded and initializedPlugin options are:
onCheckMismatch
, define what to do if a checker fails (Node.js version
does not match with the expected one, JavaScript not in strict mode, etc);
by default 'exception' to raise an Error,
but could be 'warning' (to log a message in Fastify logs),
or 'exit' (to stop current Node.js process) with exit code 1nodeStrictCheckAtStartup
, flag to tell (when true) to check JavaScript
strict mode; by default true (safer and already enforced as default mode
in modern JavaScript code using classes, ES Modules, etc)nodeVersionCheckAtStartup
, flag to tell (when true) to check Node.js version
at application startup; by default falsenodeVersionExpected
, the semver string with the expected Node.js version (by default empty, so must be manually provided, for example reading 'package.json' attribute 'engines.node' if specified)all plugin options are optional, and have a default value.
Licensed under Apache-2.0.
FAQs
Fastify Plugin to check runtime environment properties
The npm package fastify-check-runtime-env receives a total of 0 weekly downloads. As such, fastify-check-runtime-env popularity was classified as not popular.
We found that fastify-check-runtime-env demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.