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

simplyrest

v1.0.2

Published

Simplest REST Api Framework for NodeJS

Readme

Logo GitHub license npm version GitHub stars

simplyrest is a REST API Framework based on ExpressJS. simplyrest uses nodeannotations library to provide hassle-free and easy way to expose REST APIs via Annotations.

To Expose a REST API, create a controller class and annotate with the predefined annotations.

Find complete examples in the example folder.

Table Of Contents

Tutorial

Installing simplyrest

npm install --save simplyrest

Configuring simplyrest

let options = {
    // Put your options here
};

simplyrest.config(options);

Creating a Controller

  • Step 1 : Create a file under the [project root]/controllers folder (or the custom configured controllers folder)

  • Step 2 : Create a class and Annotate with @Controller

    /**
     * @Controller("/")
     */
    class MyController {
    
    }

    NOTE :

    • Annotations should be defined as shown above.
    • URLs should contain trailing slashes and not leading slashes
  • Step 3 : Create functions and annotate with supported HTTP Method to expose it as a REST API.

    /**
    * @Controller("/")
    */
    class MyController {
        /**
         * @Get("/")
         */
        rootMethod(req, res, next) {
            res.send("Welcome");
        }
    
        /**
         * @Get("helloWorld/")
         */
        helloWorld(req, res, next) {
            res.send("Hello World");
        }
    }

    NOTE :

    • Annotations should be defined as shown above.
    • Method can be named according to choice.
    • simplyrest expects the method signature to be (req, res, next) just like ExpressJS Router Methods.
    • URLs should contain trailing slashes and not leading slashes.

Supported HTTP Methods

  • GET : @Get(url)
  • POST : @Post(url)
  • PUT : @Put(url)
  • PATCH : @Patch(url)
  • DELETE : @Delete(url)
  • HEAD : @Head(url)
  • OPTIONS : @Options(url)
  • TRACE : @Trace(url)
  • CONNECT : @Connect(url)
  • ALL : @All(url)

Support for router.param

router.param functionality is supported via @Param(paramName) Annotation.
Example :

/**
 * @Controller("/")
 */
class MyController {
    /**
     * @Get("/printName/:name")
     */
    rootMethod(req, res, next) {
        res.send("Welcome "+req.params.name);
    }

    /**
     * @Param("name")
     */
    paramNameHandler(req, res, next) {
        console.log("Route with Param name called...");

        next();
    }
}

Adding Middlewares

To add a middleware, call the use function with an Express Middleware.

simplyrest.use((req, res, next) => {
    console.log("Middleware called");
});

Adding Templating Engine

Any Templating Engine can be used to render the templates.

  • Step 1 : Install the Templating engine
    npm install --save pug
  • Step 2 : Configure the view engine by setting viewEngine to pug in the options.
let options = {
    [...]
    "viewEngine": "pug",
    [...]
};

simplyrest.config(options);

Adding Error Handler

To add an error handler, call the errorHandler function with an Express Error Handler.

simplyrest.errorHandler((err, req, res, next) => {
    res.send(err.message);
});

If no error handler is supplied, by default an error handler is attached with the server which will display the error status, error message and error stack. The following error handler is added by default :

(err, req, res, next) => {
    res.status(err.status || 500);

    res.send(`<h1>${err.message}</h1><h2>${err.status}</h2><pre>${err.stack}</pre>`);
};

Starting simplyrest Server

The simplyrest Server can be started by calling the listen function.

The server will listen on port provided via options if no argument is passed while calling listen(). If port is not configured via options, then the server will listen on the default port 3000.

simplyrest.listen();

The server will listen on port provided via argument even when the port is configured via options.

simplyrest.listen(8080);

Examples

Find two complete examples in the examples folder.

Documentation

simplyrest.config(options)

  • options <Object>
    • controllersPath : Relative Path to Controllers Folder
    • viewsPath : Relative Path to Views Folder
    • publicPath : Relative Path to Public Folder
    • viewEngine : Templating engine to Render the Templates
    • port Port on which the server will listen

simplyrest.use(middleware)

  • middleware : Expects an Express Middleware

simplyrest.errorHandler(handler)

  • handler : Expects an Express Error Handler

simplyrest.listen([, port])

  • port : Port on which the server will listen