├── .gitignore ├── Procfile ├── README.md ├── db.json ├── default.jpeg ├── default.jpg ├── index.html ├── index.js ├── license ├── package.json └── styles.css /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: node index.js 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hello-faclor 2 | > A simple [faclor.js](https://netflix.github.io/falcor/) example. 3 | 4 | This example uses handlebars and some falcor magic to list JS books. 5 | 6 | Do check the [demo](http://hello-falcor.herokuapp.com/)! 7 | 8 | __Heart of the Server:__ 9 | 10 | ```js 11 | app.use('/library.json', falcorExpress.dataSourceRoute(function (req, res) { 12 | return new Router([ 13 | { 14 | route: "books.list", 15 | get: function() { 16 | return {path:["books"], value: JSON.stringify(Library) }; 17 | } 18 | }, 19 | { 20 | route: "books.names", 21 | get: function() { 22 | return {path:["books","names"], value: Library.map( book => book.name )}; 23 | } 24 | } 25 | ]); 26 | })); 27 | ``` 28 | 29 | __Heart of the client:__ 30 | 31 | ```js 32 | var model = new falcor.Model({source: new falcor.HttpDataSource('/books.json') }); 33 | 34 | model. 35 | get("books"). 36 | then(function(response) { 37 | var books = JSON.parse(response.json.books); 38 | }); 39 | ``` 40 | 41 | ## License 42 | 43 | MIT © [Hemanth.HM](http://h3manth.com) 44 | -------------------------------------------------------------------------------- /db.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "name": "Functional JavaScript: Introducing Functional Programming with Underscore.js", 3 | "author": "Michael Fogus", 4 | "isbn": "978-1449360726", 5 | "url": "http://www.amazon.com/Functional-JavaScript-Introducing-Programming-Underscore-js/dp/1449360726" 6 | },{ 7 | "name": "Maintainable JavaScript - Writing Readable Code", 8 | "author": "Nicholas C. Zakas", 9 | "isbn": "978-1449327682", 10 | "url": "http://www.amazon.com/Maintainable-JavaScript-Nicholas-C-Zakas/dp/1449327680" 11 | }, { 12 | "name": "Professional JavaScript for Web Developers", 13 | "author": "Nicholas C. Zakas", 14 | "isbn": "978-1118026694", 15 | "url": "http://books.google.co.in/books?id=C3kabcBG0ZsC" 16 | }, { 17 | "name": "JavaScript Patterns", 18 | "author": "Stoyan Stefanov", 19 | "isbn": "978-0596806750", 20 | "url": "http://books.google.co.in/books?id=WTZqecc9olUC" 21 | }, { 22 | "name": "JavaScript: The Definitive Guide", 23 | "author": "David Flanagan", 24 | "isbn": "978-0596101992", 25 | "url": "http://books.google.co.in/books?id=6TAODdEIxrgC" 26 | }, { 27 | "name": "Secrets of the JavaScript Ninja", 28 | "author": "John Resig, Bear Bibeault", 29 | "isbn": "978-1933988696", 30 | "url": "http://books.google.co.in/books?id=ab8CPgAACAAJ" 31 | }, { 32 | "name": "Object-Oriented Javascript", 33 | "author": "Stoyan Stefanov", 34 | "isbn": "978-1849693127", 35 | "url": "http://books.google.co.in/books?id=v_oIIyw1vSIC" 36 | }, { 37 | "name": "JavaScript: The Good Parts", 38 | "author": "Douglas Crockford", 39 | "isbn": "978-0596517748", 40 | "url": "http://books.google.co.in/books?id=PXa2bby0oQ0C" 41 | }, { 42 | "name": "JavaScript & jQuery: The Missing Manual", 43 | "author": "David Sawyer McFarland", 44 | "isbn": "978-1449399023", 45 | "url": "http://books.google.co.in/books?id=dAJyxUtEZLMC" 46 | }, { 47 | "name": "High Performance JavaScript", 48 | "author": "Nicholas C. Zakas", 49 | "isbn": "978-0596802790", 50 | "url": "http://books.google.co.in/books?id=ED6ph4WEIoQC" 51 | }, { 52 | "name": "Eloquent JavaScript: A Modern Introduction to Programming", 53 | "author": "Marijn Haverbeke", 54 | "isbn": "978-1593272821", 55 | "url": "http://eloquentjavascript.net/" 56 | }, { 57 | "name": "Pro JavaScript Techniques", 58 | "author": "John Resig", 59 | "isbn": "978-1590597279", 60 | "url": "http://books.google.co.in/books?id=GgJN2CC_2s4C" 61 | }, { 62 | "name": "High Performance Web Sites: Essential Knowledge for Front-End Engineers", 63 | "author": "Steve Souders", 64 | "isbn": "978-0596529307", 65 | "url": "http://stevesouders.com/hpws/" 66 | }, { 67 | "name": "Even Faster Web Sites", 68 | "author": "Steve Souders", 69 | "isbn": "978-0596522308", 70 | "url": "http://stevesouders.com/efws/" 71 | }, { 72 | "name": "Learning JavaScript Design Patterns", 73 | "author": "Addy Osmani", 74 | "isbn": "978-1449331818", 75 | "url": "http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/" 76 | }, { 77 | "name": "jQuery in Action", 78 | "author": "Bear Bibeault, Yehuda Katz", 79 | "isbn": "978-1935182320", 80 | "url": "http://www.manning.com/bibeault2/" 81 | }, { 82 | "name": "jQuery Pocket Reference", 83 | "author": "David Flanagan", 84 | "isbn": "978-1449397227", 85 | "url": "http://books.google.co.in/books?id=qPCCUdDefdkC" 86 | }, { 87 | "name": "Book of Speed [Online]", 88 | "author": "Stoyan Stefanov", 89 | "url": "http://www.bookofspeed.com" 90 | }, { 91 | "name": "JavaScript Allonge [Ebook]", 92 | "author": "Reginald Braithwaite", 93 | "url": "https://leanpub.com/javascript-allonge" 94 | }, { 95 | "name": "JavaScript for PHP Developers", 96 | "author": "Stoyan Stefanov", 97 | "isbn": "978-1449320195", 98 | "url": "http://books.google.co.in/books?id=QT56xKb-S3sC" 99 | }, { 100 | "name": "Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript", 101 | "author": "David Herman", 102 | "isbn": "978-0321812186", 103 | "url": "http://effectivejs.com/" 104 | } 105 | ] 106 | -------------------------------------------------------------------------------- /default.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemanth/hello-falcor/e827ec1bd483a8fe6ab420788def7bc5d3edfee6/default.jpeg -------------------------------------------------------------------------------- /default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemanth/hello-falcor/e827ec1bd483a8fe6ab420788def7bc5d3edfee6/default.jpg -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 21 | 22 | Falcor.js example 23 | 24 | 25 |

Hello Falcor.js!

26 | Fork me on GitHub 27 |
28 | 29 | 42 | 43 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var falcorExpress = require('falcor-express'); 2 | var Router = require('falcor-router'); 3 | var express = require('express'); 4 | var Library = require('./db.json'); 5 | var app = express(); 6 | 7 | app.use('/library.json', falcorExpress.dataSourceRoute(function (req, res) { 8 | return new Router([ 9 | { 10 | route: "books.list", 11 | get: function() { 12 | return {path:["books"], value: JSON.stringify(Library) }; 13 | } 14 | }, 15 | { 16 | route: "books.names", 17 | get: function() { 18 | return {path:["books","names"], value: Library.map( book => book.name )}; 19 | } 20 | } 21 | ]); 22 | })); 23 | 24 | app.use(express.static(__dirname + '/')); 25 | 26 | var server = app.listen(process.env.PORT || 1337); 27 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Hemanth.HM (h3manth.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-falcor", 3 | "version": "1.0.0", 4 | "private": "true", 5 | "description": "Simple faclor app", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "start": "node index.js" 10 | }, 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "express": "^4.13.3", 15 | "falcor-express": "^0.1.2", 16 | "falcor-router": "^0.2.9" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | *, *:before, *:after { 2 | box-sizing: border-box !important; 3 | } 4 | 5 | div#books { 6 | -moz-column-width: 11em; 7 | -webkit-column-width: 11em; 8 | -moz-column-gap: 1em; 9 | -webkit-column-gap: 1em; 10 | } 11 | 12 | div.book { 13 | display: inline-block; 14 | margin: 0.25rem; 15 | padding: 1rem; 16 | width: 100%; 17 | box-shadow: 0 2px 1px rgba(0,0,0,0.30), 0 0px 0px rgba(0,0,0,0.22); 18 | border: 1px #ccc solid; 19 | margin-bottom: 0.8em; 20 | } 21 | 22 | span.author { 23 | font-size: 11px; 24 | } 25 | 26 | span.name { 27 | display: block; 28 | word-wrap: break-word; 29 | font-size: 13px; 30 | padding-top: 11px; 31 | } 32 | 33 | img.cover { 34 | width: 100%; 35 | height: auto; 36 | } 37 | 38 | body { 39 | padding: 1em; 40 | font-family: "Garamond", serif; 41 | line-height: 1.25; 42 | } 43 | 44 | h1 { 45 | margin: 1em 0 0.5em 0; 46 | color: #343434; 47 | font-weight: normal; 48 | font-family: 'Ultra', sans-serif; 49 | font-size: 36px; 50 | line-height: 42px; 51 | padding-bottom: 1em; 52 | text-align: center; 53 | } 54 | --------------------------------------------------------------------------------