How to use the falcor.JSONGModel function in falcor

To help you get started, we’ve selected a few falcor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Netflix / falcor-express / server-example.js View on Github external
var http = require('http');
var falkor = require('falcor');
var Rx = require('rx');
var url = require('url');
var model = new falkor.JSONGModel(null, 0, 0, require('./Cache')());
var FalkorEndpoint = require('./../index');
var falkorEndpoint = new FalkorEndpoint(model);

http.
    createServer(function(req, res) {
        var urlValue = url.parse(req.url);
        if (urlValue.path.indexOf('/falkor') === 0) {
            falkorEndpoint.fromHttpRequest(req, function(err, jsonString) {
                if (err) {
                    res.writeHead(500);
                    res.write(err);
                } else {
                    res.writeHead(200);
                    res.write(jsonString);
                }
                res.end();