saphirestify

0.1.6 • Public • Published

API Restify

API Restity is a RestifyJs based library that simply allows you to use filenames as route name.

Get started:

NPM:

Simply install npm module by typing

npm install saphirestify

And then set up files:

index.js:

const apiExample = require('saphirestify');
apiExample.start('./routes', __dirname);

config.js:

module.exports = {
  port: process.env.PORT || 8081,
  server: { 
    name: 'API'
  },
};

routes/Example.js:

class Example {
  constructor(server) {
    this.server = server;
  }

  Returns a simple json
  get(req) {
    console.log("GET request");
    return {'foo': 'bar'};
  }
}

module.exports = Example;

Note The route path must only have route files. Otherwise the server could not start.

Then run npm start

Connect to localhost:8081/example and enjoy !

Readme

Keywords

Package Sidebar

Install

npm i saphirestify

Weekly Downloads

1

Version

0.1.6

License

MIT

Unpacked Size

4.86 kB

Total Files

4

Last publish

Collaborators

  • saphirevert