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 🙏

© 2026 – Pkg Stats / Ryan Hefner

blue-http

v1.0.0

Published

A quick and efficient Api with Express under the hood.

Readme

impulse-api

This module provides a quick and easy way to create powerful http servers.

Installation

npm install impulse-api

Unit Tests

npm run test

Usage

A at least one .js file must exist at {project-root}/routes in order to initialize a new Api. See sample-routes for reference.

const Impulse = require('impulse-api');

const config = {
    env: 'DEV',
    port: 3000,
    secretKey: 'topSecret!',
    appKey:  '@adminSecretKey',
    version: '1.0.0',
    name: 'Hello-World-Api',
    routeDir: __dirname.concat('/routes'),
    services: {}
}

const api = new Impulse(config);
api.init().then((response) => {
    console.log(response)
}).catch((error) => {
    console.log(error)
})

Server Parameters

-env (required) The Environment the server should be running in. Typically this can be parsed from .env or hoisted from process.ENV.

-port (required) The port on which the server should be running.

-secretKey The key used for all JSON web token encoding and decoding.

-applicationKey The key used for all basic application authentication.

-name The name of the server.

-version The version of the server.

-routeDir (required) The location of the root route directory.

-services Optional object that is available on every route. Services is ideal for storing connection information to databases or any other auxiliary functionality.

Heartbeat endpoint

By default, all Impulse-APIs have a /heartbeat endpoint that returns 200 along with the following standard output:

{ status: 'alive' }

Routes

Routes are functions that expose HTTP path functionality.

Route files must exist in any number of folders or subfolders at {project-root}/routes

// routes/documents.js
exports.getDocument = {
    name: 'getDocument',
    description: 'get a document by id',
    method: 'get',
    endpoint: '/api/document/:id',
    version: 'v1',
    tokenAuth: true,
    inputs: {
        id: {
            required: true,
            validate: val => parseInt(val, 10)
        },
    },
    run: (services, inputs, next) => {
        const id = inputs.id;
        next(200, {
            id
        });
    },
};

Route Auth

Token Auth

Impulse-Api comes with JSON web token auth built in. As long as secretKey is provided to the server configuration on initialization, routes can use an optional tokenAuth:true in order to enable basic JWT authentication.

Additionally, any variables that are encoded in the token are accessible once the token has been decoded via inputs.decoded.

Token generation is handled via Impulse.Auth which again utilizes the JSON web token package.

const { Auth } = require('impulse-api');
{ decode: [Function],
  verify: [Function],
  sign: [Function],
  JsonWebTokenError: [Function: JsonWebTokenError],
  NotBeforeError: [Function: NotBeforeError],
  TokenExpiredError: [Function: TokenExpiredError] }

Application Auth

For admin type routes, Impulse-Api also provides applicationAuth which secures any routes behind basic key authorization provided by appKey in the server configuration. The applicationAuth can be verified and passed in the header, parameters, query, or body as key.

// routes/users.js
exports.createUser = {
    name: 'createUser',
    description: 'create a new user',
    method: 'post',
    endpoint: '/api/user/',
    version: 'v1',
    applicationAuth: true,
    inputs: {
        username: {
            required: true,
        },
        password: {
            required: true,
        }
    },
    run: (services, inputs, next) => {
        const id = inputs.id;
        next(200, {
            id
        });
    },
};

If a route specifies both Application and Token auth, Application auth will take precedence.

-- Application auth routes should not be called from any public client since this will expose appKey.

Inputs

Impulse-Api automatically parses all request query, body, params, and files variables with the following priority: query, body, params, files. Header fields are always parsed.

This allows for very dynamic routes. The following routes will all parse newEmailAddress.

PUT /user/:id/&[email protected]

PUT /user/:id/
body: {
	newEmailAddress: '[email protected]'
}

PUT /user/:id/
json: {
	"newEmailAddress": "[email protected]"
}

PUT /user/:id/
params: newEmailAddress="[email protected]"