Skip to content
This repository has been archived by the owner on Mar 28, 2018. It is now read-only.
/ express-eventify Public archive

Converts an express app instance into an object which can subscribe to REST requests like events.

License

Notifications You must be signed in to change notification settings

Heartnett/express-eventify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-eventify

Converts an express app instance into an object which can subscribe to REST requests like events.

Greenkeeper badge Travis Dependency Status David Version npm npm Downloads license Gratipay User Package Quality

NPM Package Quality


Installation

# Install via NPM
npm install express-eventify
# OR
# Install via Yarn
yarn add express-eventify

Usage

express-eventify extends an express app by introducing the $on function.

Initialize

const express = require('express');
const eventify = require('express-eventify');

// create a new express app
let app = express();
// initialize the new express app
app = eventify(app);

Subscribe

There are two ways of subscribing to express with express-eventify

// notice the '!' - it seperates the REST method and the path i.e. "{method}!{path}"
// in this case it's 'get' and '/'
app.$on("get!/", (req, res) => res.send("Using express-eventify")); 

The second way discribes shows how the $on function consumes an object as a parameter.

app.$on({
    get: {
        "/": function(req, res) {
            // all parameters passed to a normal express method 
            // are also sent to this callback (request, response, next, etc..)
        }
    },
    post: {
        // post routes
    }
});

Notes

The following express methods are wrapped by express-eventify:

  • delete
  • get
  • param
  • post
  • put
  • render

License

MIT


Donating

Please support this project via gratipay.

Support via Gratipay

About

Converts an express app instance into an object which can subscribe to REST requests like events.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published