Skip to content
Express Middleware for Hosting Falcor Data Sources.
JavaScript
Branch: master
Clone or download
Latest commit 35c202b Dec 1, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src moved from res.send to res.json in order to obtain proper json conten… Aug 27, 2015
test tests match Aug 27, 2015
.eslintrc
.gitignore first commit- Feb 12, 2015
LICENSE.txt
OSSMETADATA adding OSSMETADATA for NetflixOSS tracking Dec 11, 2015
README.md Adding colors to example code in readme Aug 21, 2015
authors.txt added authors.txt file. May 3, 2015
gulpfile.js Add test linting to lint command Jul 27, 2015
package.json Update version to 0.1.4 Dec 1, 2016

README.md

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
You can’t perform that action at this time.