npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bootcheck

v1.0.0

Published

confirms required package dependencies and environment variables are present

Downloads

3

Readme

bootcheck

don't start what you can't finish

Introduction

bootcheck checks that dependencies in package.json are installed and that specified environment variables are defined. bootcheck, itself, has no non-core dependencies so it can be called as soon as a node.js app is started, allowing the app to halt if there are missing dependencies or variables.

The script is intended for use where apps will be run or handled by people who are casual users or who may be in support roles where additional guidance is useful, when first running their app. People working in places with mature environment management tools or DevOps processes are unlikely to find this very useful.

The script was inspired by the Ghost routines that checked for critical dependencies before allowing the app to start.

Installation

bootcheck.js should be copied into an appropriate location within a project's directory structure.

bootcheck is an npm package but it should not be installed with npm.

Why?

You can't check for missing package dependencies if the program checking for dependencies is also missing. It's a chicken and the egg problem...how will you notify there are missing dependencies if the module to check for missing dependencies is, itself, a missing dependency? Yeah?

Also note: bootcheck will not validate or check the values of environment variables to confirm they are good. That responsibility sits with the application code that will consume or manipulate the variable.

Usage

Basic Usage

At the start of the program where bootcheck will help guard against missing dependencies, this would work:

var bc = require("./bootcheck");

bc.pkg("./package.json", "throw");
bc.env(["NODE_ENV", "PORT"], "silent");

action_types for bootcheck

For all methods on the bootcheck object, an action type can be specified that describes how bootcheck should react when there is a problem. These types are:

  1. "throw" - throws an error with a descriptive error message when a requirement is missing
  2. "console" - logs the descriptive error message to the console, but continues operations
  3. "silent" - returns 'false' from the call for other purposes/uses, but does not throw or log

"throw" is the default action and will be used if no action_type is specified when bootcheck methods are called.

Only "throw" will halt execution. "console" and "silent" assume that some other method is in place to assist the app to continue (or that these problems are not fatal, so the app can continue despite the missing requirements).

bootcheck.pkg(package_path[, action_type])

package_path should be a path (relative or absolute) to the project's package.json file.

If this path is missing or if package.json has no dependencies, bootcheck will throw an error.

bootcheck.env(variable_array[, action_type])

variable_array is a single string or an array of string, each providing the name of an environment variable to confirm are defined.

The .env method will not check the variable values. It simply checks for the presence of the variable in the environment via process.env.<var_name>.

If the variable array is missing, .env will throw an error.

License

ISC