falcor-express
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/falcor-express package

0.1.4 • Public • Published

falcor-express

Server middleware for falcor-express

Working usage example of the basic repro in netflix/falcor-express-demo

Usage

Minimalistic example

var FalcorServer = require('falcor-express');
var bodyParser = require('body-parser');
var express = require('express');
var app = express();
 
var TestRouter = <your router here>;
 
app.use(bodyParser.text({ type: 'text/*' }))
app.use('/model.json', FalcorServer.dataSourceRoute(function(req, res) {
    return new TestRouter();
}));
 
app.use(express.static('.'));
 
var server = app.listen(9090, function(err) {
    if (err) {
        console.error(err);
        return;
    }
    console.log("navigate to http://localhost:9090")
});
 

Example of using a static model (for development purposes only)

var falcor = require('falcor');
var FalcorServer = require('falcor-express');
var bodyParser = require('body-parser');
var express = require('express');
var app = express();
 
var model = new falcor.Model({
    cache: {
        todos: [
            {
                name: 'get milk from corner store',
                done: false
            },
            {
                name: 'withdraw money from ATM',
                done: true
            }
        ]
    }
});
 
app.use(bodyParser.text({ type: 'text/*' }))
app.use('/model.json', FalcorServer.dataSourceRoute(function(req, res) {
    return model.asDataSource();
}));
 
app.use(express.static('.'));
 
var server = app.listen(9090, function(err) {
    if (err) {
        console.error(err);
        return;
    }
    console.log("navigate to http://localhost:9090")
});

Development

Before contributing, please run the linter and the tests to be sure there are no issues.

npm run lint

and

npm run test

/falcor-express/

    Package Sidebar

    Install

    npm i falcor-express

    Weekly Downloads

    97

    Version

    0.1.4

    License

    none

    Last publish

    Collaborators

    • kkwon
    • kaylie
    • donutespresso
    • tbranyen
    • tvui-user
    • tvuiops-user
    • gsimpson
    • barb_the_builder
    • mmarchini
    • wesleytodd
    • satyend