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 🙏

© 2025 – Pkg Stats / Ryan Hefner

noswbi

v0.6.1

Published

Node server with batteries included!

Downloads

5

Readme

noswbi

Build Status Codacy Badge Codacy GitHub code size in bytes GitHub All Releases GitHub

Noswbi is a NodeJS HTTP server with everything but routes configured.

Install

npm install --save noswbi

Features

Noswbi includes the following configuration / features:

  • helmet
  • compression
  • overload protection (only on production environment)
  • body-parser for JSON and urlencoded (extended false)
  • cors (can be enabled with `createServer(router, { allowCors: true }))
  • forces Content-Type: application/json on response headers (can be disabled with createServer(router, { forceJsonResponse: false }))
  • attach router routes to / unless routesPrefix provided on config when creating the server
  • authentication protection for routes
  • social login with Google
  • 404 not found handler included
  • error handler included

Production

Don't forget to set the NODE_ENV variable to "production". It will improve the performance of the server and will remove the stack trace from error handler. It will also enable the overload protection.

Usage

The idea behind noswbi is to provide a configured server, so you can focus only on coding the routes and logic of your API.

Noswbi exposes two methods: createRouter and createServer. You can use them to easily create a server.

Simple server

// Import the two required noswbi methods to create the server:
const { createRouter, createServer } = require("noswbi");

// Create the router:
const router = createRouter();

// Add your logic to the router:
router.get("/status", (req, res) => res.status(200).json({ status: "OK" }));

// Create the server by providing the configured router:
const server = createServer(router);

// Start
server.listen(3000);

Server with social login and protected routes

const mongoose = require("mongoose");
const { createRouter, createServer } = require("noswbi");

const router = createRouter();

router.get("/", (req, res) => res.send("holi"));

/**
 * The requests to the routes attached to this router require
 * an Authorization header with value `JWT ${token}`
 */
const protectedRoutes = createRouter({ requireAuth: true });

protectedRoutes.get("/protected-by-default", (req, res) =>
  res.json({
    message: "this should be protected by default",
    user: req.user
  })
);

const options = {
  allowCors: true,
  forceJsonResponse: true, // default value
  domain: process.env.DOMAIN,
  routesPrefix: "/", // default value
  auth: {
    jwtSecret: process.env.JWT_SECRET,
    issuer: process.env.JWT_ISSUER,
    audience: process.env.JWT_AUDIENCE,
    google: { // you will need to create an configure a Google app for login
      clientID: process.env.GOOGLE_CLIENT_ID,
      clientSecret: process.env.GOOGLE_SECRET
    },
    /**
     * If you provide an user model with a method findOrCreate
     * noswbi will call it with the user info provided by Google
     * after succesful login.
     */
    userModel: require("./path/to/your/user/model") // optional
  }
};

const server = createServer([router, protectedRoutes], options);

mongoose.connect(
  "mongodb://localhost:27017/test",
  {
    useNewUrlParser: true,
    useUnifiedTopology: true
  },
  err => {
    if (err) {
      console.error(err);
      process.exit(1);
    }
    server.listen(3000, () => console.log("running on 3000"));
  }
);

Examples

You can check full examples here.