1.1.0 • Published 5 years ago

millennium-node-falcon v1.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

millennium-node-falcon

CircleCI Coverage Status

This is a utility library that aims at making your end-points neater by organising them in classes.

How to get setup

Installation

Run npm i millennium-node-falcon or yarn add millennium-node-falcon

Hello world

In your entry point file:

  • import import * as falcon from 'millennium-node-falcon';
  • import a resource class. (Creation demonstrated below)
  • add await falcon.createFalconApp();
  • create a self-invoking function and thats it.

The file should look like this.

import * as falcon from 'millennium-node-falcon';
import { Users } from './Users';

(async () => {
  await falcon.createFalconApp();
  new Users();
})();

Next step create a resource class

  • Create a nomal ES6 class
  • @method(MethodType, url) decorator class funtions
  • The functions should receive two parameters

    • body for POST, PUT, DELETE or params for GET
    • express response

Sample of a class

import { MethodTypes, method } from 'millennium-node-falcon';

export class Users {
  constructor(){}

  @method(MethodTypes.get, '/')
  helloSample(req, res) {
    res.send({ message: 'hello from falcon' })
  }
}

TODO

  • Add infrastructure to allow addition of middleware

And thats it you are ready to code, give it a star if you like it :-)