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

restify-abstract-config

v0.3.1

Published

Abstract config system for your Restify endpoints

Downloads

10

Readme

restify-abstract-config

NPM

Install

$ npm install restify-abstract-config

Usage

Use the AbstractAPI class to fast track configuring Restify HTTP methods to your own concrete type's instance methods.

For example:

// $PROJECT_ROOT/app/routes/some-custom-api.js
'use strict';

const AbstractAPI = require("restify-abstract-config").AbstractAPI;

class SomeCustomAPI extends AbstractAPI {
    constructor() {

        super();

        this.addGet('get', '/api/custom/:id', this.get);
        this.addGet('getAll', '/api/custom', this.getAll);

        this.addPut('update', '/api/custom/:id', this.update);

        this.addDelete('delete', '/api/custom/:id', this.delete);

        this.addPost('create', '/api/custom', this.create);

    }

    get(req, res, next) {
        res.send('get');
        next();
    }

    getAll(req, res, next) {
        res.send('getAll');
        next();
    }

    update(req, res, next) {
        res.send('update');
        next();
    }

    delete(req, res, next) {
        res.send('delete');
        next();
    }

    create(req, res, next) {
        res.send('create');
        next();
    }

}

module.exports = new SomeCustomAPI();

What is important here is that the server in following code snippet is the instance you get after executing createServer() on the restify module (This is showcased in another code snippet below).

Execute the setup of your routes above as follows (of course you can invoke this as you see fit in your own code base):

// $PROJECT_ROOT/app/routes/index.js
'use strict';

const someCustomAPI = require('./some-custom-api');

module.exports = {

    setup: function(server) {

        someCustomAPI.setupRoutes(server);

        //Print this API's endpoints
        someCustomAPI.endpointsInfo();

        //Print all the Restify-configured routes
        someCustomAPI.allRoutesInfo(server);

    }

}

If you want the version of your project's package.json available at an endpoint as well, be sure to provide a second argument to the above setupRoutes function:

someCustomAPI.setupRoutes(server, '/api/version');

You can use an endpoint URL of your choice.

Ensure that the above setup function is called again eg:

// $PROJECT_ROOT/server.js
'use strict';

let restify = require('restify');
let routes = require('./app/routes');

let server = restify.createServer();
routes.setup(server);

server.listen(8080, function() {
    console.log('%s listening at %s', server.name, server.url);
});

License

MIT

Bugs

See https://github.com/0v3rst33r/restify-abstract-config/issues.