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

rkrouter

v1.1.2

Published

Lightweight package to create RESTful API server

Readme

RK Router 🚀

About this technology:

  • RKRouter is a lightweight package to create RESTful API server.
  • Code-style spirited by React.
  • Written by RK Nguyen. (fb/rknguyen for support)

Installation

This technology is released in the public npm registry and can be installed using:

npm install rkrouter

Usage

See some examples below, it is very easy for beginners to read and approach to this technology.

Init routes

const { Route, Listener } = require('rkrouter')

const Parser = require('./route/Parser')
const Hello = require('./route/Hello')
const Otherwise = require('./route/Otherwise')

const Port = 3001
const http = new Listener(
[ 
  Parser, 
  Hello, 
  Otherwise 
], 
Port)

http.CreateServer()

route/Parser

This route is similar to a middleware that parse input data before go to main route.

const { Route } = require('rkrouter')
const BodyParser = require('body-parser')
const QueryString = require('query-string')

class Parser extends Route {
  async Handle(req, res, next) {
    const __Parser = (parser) => new Promise((next) => parser(req, res, next))
    req.query = QueryString.parse(req.url.query)
    await __Parser(BodyParser.json())
    await __Parser(BodyParser.urlencoded({ extended: false }))
    next()
  }
}

module.exports = Parser

route/Hello

This route is just an example for main route. This example also shows you what you can do with one route, its basically is:

  • Path: define the path that match this route
  • PreEnter: define some validate before handle request
  • Handle: process something...
  • InputSchema: Define the rules of input, it is just a schema validation
const { Route } = require('rkrouter')

class Hello extends Route {
  async Path() { return '/hello/:name' }
  async PreEnter(req, res, enter) {
    // check something before enter the route
    // if not valid to enter, must res.end()
    enter()
  }
  async Handle(req, res, next) {
    res.statusCode = 200
    res.json({
      hello: req.params.name,
      ...{ query: req.query },
      ...{ body: req.body }
    })
  }
  async InputSchema() {
    return {
      msg: {
        type: String,
        length: {
          min: 5,
          max: 10
        }
      }
    }
  }
}

module.exports = Hello

route/Otherwise

When can't find any route match with current request, this route is the last route that shows not found message.

const { Route } = require('rkrouter')

class Otherwise extends Route {
  async Handle(req, res) {
    res.statusCode = 404
    res.json({
      error: true,
      message: "404 not found"
    })
  }
}

module.exports = Otherwise

Got problem?

Just contact me (fb/rknguyen)

Hope you like this technology ❤️