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

powter

v1.0.3

Published

Give power to your Router. An abstraction on top of normal routing function definitions. Makes your code more testable, easily configured, and straight forward

Readme

Powter

Give power to your Router!

Purpose

Powter was created with the purpose of creating more readable code, and easier testing. It provides nice documentation of your API as a side effect.

I wanted to make Powter as lightweight as possible. Swagger's express middleware solves alot of problems I had with express, but it is quite heavy and has quite a few strange quirks.

What is it?

Powter is a simple abstraction on top of the express router module that makes your code more testable and straight forward, while also providing some basic documentation.

The examples below show the simplicity attained with some basic configuration

With Powter:

{
  "paths": {
    "/user/:id": {
      "controller": "src/routes/user.js",
    }
  }
}
export function get(req, res) {
  // Handle Request
}

export function post(req, res) {
  // Handle Request
}

Without Powter:

import { Router } from 'express'

router = new Router()

router.get('/user/:id', (req, res) => {
  // Handle Request
})

router.post('/user/:id', (req, res) => {
  // Handle Request
})

Testing

Testing was a large motivation beind building Powter. Without powter, you cannot truly write unit tests because you are also testing express. Not to mention that if you are using a library like supertest, you are most likely testing your server startup file as well.

The below examples show you the difference of using powter vs normal express definitions.

With Powter:

import User from 'src/routes/user.js'

describe('User Route /user/:id', () => {
  let req = { params: { id: 1234 } }
  let res = {
    send: (body) => this.body = body
  }

  describe('GET', () => {
    it('should respond with the user object', () => {
      User.get(req, res)

      expect(res.body).to.equal({ user: 'Tyler', new: false })
    })
  })

  describe('POST', () => {
    it('should respond with a new user object', () => {
      User.post(req, res)

      expect(res.body).to.equal({ user: 'Ashley', new: true })
    })
  })
})

Notice the only testing dependency is the user.js file. Also notice the lightweight stubs for the req and res objects

Without Powter:

import User from 'src/routes/user.js'
import Server from 'src/index.js'

import Request from 'supertest'

describe('User Route /user/:id', () => {
  describe('GET', () => {
    it('should respond with the user object', async () => {
      let response = await Request(Server)
        .set('Authorization', 'Bearer token')
        .get('/user/:id')

      expect(response.body).to.equal({ user: 'Tyler', new: false })
    })
  })

  describe('POST', () => {
    it('should respond with a new user object', async () => {
      let response = await Request(Server)
        .set('Authorization', 'Bearer token')
        .post('/user/:id')

      expect(response.body).to.equal({ user: 'Ashley', new: true })
    })
  })
})

Notice the extra dependancies, the authorization, and the fact that we have to import an entire HTTP Server!

Getting Started

A powter configuration file can be as simple or as verbose as needed.

By default, all functions can be named after the intended HTTP method, but names can be specified as needed.

Here is a basic example:

server.js

Pass the express app and config file path into powter so it can build the routes

const express = require('express')
const powter = require('powter')
const app = new express()

// Build the routes
powter(app, 'config/routes.json')

routes.json

Configure you're API

{
  "paths": {
    "/user/:id": {
      "controller": "src/routes/user.js",
    },
    "/order/:id": {
      "controller": "src/routes/order.js",
      "delete": "removeOrder"
    }
  }
}

user.js

export function get(req, res) {
  // Handle Request
}

export function post(req, res) {
  // Handle Request
}

export function put(req, res) {
  // Handle Request
}

export function patch(req, res) {
  // Handle Request
}

export function unlink(req, res) {
  // Handle Request
}

order.js

export function get(req, res) {
  // Handle Request
}

export function post(req, res) {
  // Handle Request
}

export function removeOrder(req, res) {
  // Handle Request
}