express-rx-simple

0.1.3 • Public • Published

It's a simple express app observable factory.

How to use

'use strict'; 
const makeExpressApp$ = require('express-rx-simple');
const bodyParser = require('body-parser');
const logger = require('morgan');
const http = require('http');
const pug = require('pug');

// defining app stream
const app$ = makeExpressApp$(
    {
        routes : [
            {
                url : '/hello',
                method : 'get',
                before : (req, res) => { // optional [without next]
                    // do something before execution of controller
                },
                controller : (req, res) => {
                    // handle request
                }
            },
            // other routes
        ],
        engine : {
            name : 'pug',
            instance : pug.__express
        },
        settings : {
            port : process.env.port || 3000,
            // other settings for the setting table see the express doc
        },
        middlewares : [
            // list of middlewares to apply
            bodyParser.json(),
            logger('dev')
        ]
    });
app$.subscribe( app => {
    let server = http.createServer(app);
    server.listen(app.get('port') || 3000);
});

Readme

Keywords

none

Package Sidebar

Install

npm i express-rx-simple

Weekly Downloads

1

Version

0.1.3

License

ISC

Last publish

Collaborators

  • wbasmi