Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfeb2f3
commit 50441fd
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var express = require('express') | ||
, app = express.createServer() | ||
, dataLayer = require('../data-cache')() | ||
|
||
app.configure(function(){ | ||
app.use(express.logger()) | ||
app.set('view engine', 'jade') | ||
}) | ||
|
||
app.get('/', dataLayer.connectDataTemplate('index/all', 'index')) | ||
app.get('/:cryptic', dataLayer.connectDataTemplate(':cryptic/all', 'index')) // the params in the external url match an internal url they get passed through | ||
|
||
|
||
dataLayer.compositeRoute(':chaos/all', // Again here the params get passed through if they match. | ||
{ 'datamonkey': 'name' | ||
, 'cryptic/:chaos': 'message' // However the names are independent of what we called them in the other section | ||
}) | ||
|
||
dataLayer.addRoute('datamonkey', function(req, cb) { | ||
console.log('Fetching: ', req.url) | ||
setTimeout(function() { | ||
cb(null, "The Message") | ||
}, 100) | ||
}, 3000) | ||
|
||
dataLayer.addRoute('cryptic/:swarm', function(req, cb) { | ||
console.log('Fetching: ', req.url) | ||
setTimeout(function() { | ||
cb(null, "This is the a parametrized response " + req.params.swarm) | ||
}, 1000) | ||
}, 10000) | ||
|
||
app.listen(3000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
h2 #{name} | ||
h3 #{message} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
!!!5 | ||
html | ||
head | ||
title #{name} | ||
body | ||
h1 Data Layer! | ||
!=body | ||
|