This release is a developer preview. We are looking for community help to track down and fix bugs. We are also looking for help porting the Router to other platforms.
You can check out a working example server for a Netflix-like application here right now. Alternately you can go through this short tutorial:
Let's use the Falcor Router to build a Virtual JSON resource on an app server and host it at /model.json. The JSON resource will contain the following contents:
"greeting": "Hello World"
Normally Routers retrieve the data for their Virtual JSON resource from backend data stores or other web services on-demand. However in this simple tutorial the Router will simply return static data for a single key.
Creating a Virtual JSON Resource with a Falcor Router
First we create a folder for our application server.
mkdir falcor-app-server && cd !$npm init
Now we install the Falcor Router.
npm i falcor-router -S
npm i express falcor-express -S
Now we create an index.js file with the following contents:
// index.jsvar falcorExpress = ;var Router = ;var express = ;var app = ;app;// statically host all files in current directoryapp;var server = app;
Now we run the server, which will listen on port 3000 for requests for /model.json.
Retrieving Data from the Virtual JSON resource
Now that we've built a simple virtual JSON document with a single read-only key "greeting", we will create a test web page and retrieve this key from the server.
Now create an index.html file with the following contents:
<!-- index.html --><!-- Do _not_ rely on this URL in production. Use only during development. -->
Now visit http://localhost:3000/index.html and you should see the message retrieved from the server:
For an example of a Router built for a Netflix-like application, see this repository.
For in-depth information on the Falcor Router, see the Router Guide in the Falcor Website.
For discussion please use Stack Overflow.