Created
September 18, 2012 00:07
-
-
Save notlion/3740535 to your computer and use it in GitHub Desktop.
Derby Test
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
var derby = require('derby') | |
, app = derby.createApp(module) | |
app.get('/', function(page, model, params, next) { | |
model.subscribe("result", function(err, all) { | |
page.render() | |
}) | |
}) | |
app.ready(function(model) { | |
}) |
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
<Title:> | |
Derby Test! | |
<Body:> | |
<input type="text" name="a" value="{a}" /> + <input type="text" name="b" value="{b}" /> = {result} |
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
var http = require('http') | |
, path = require('path') | |
, express = require('express') | |
, gzippo = require('gzippo') | |
, derby = require('derby') | |
, app = require('../app') | |
, serverError = require('./serverError') | |
var expressApp = express() | |
, server = module.exports = http.createServer(expressApp) | |
derby.use(derby.logPlugin) | |
var store = derby.createStore({ listen: server }) | |
var ONE_YEAR = 1000 * 60 * 60 * 24 * 365 | |
, root = path.dirname(path.dirname(__dirname)) | |
, publicPath = path.join(root, 'public') | |
store.afterDb("set", "*", function(txn, doc, previousDoc, done) { | |
if(txn[1].charAt(0) != '#') { | |
store.set("result", "hello", function(){}) | |
} | |
done() | |
}) | |
expressApp | |
.use(express.favicon()) | |
.use(gzippo.staticGzip(publicPath, { maxAge: ONE_YEAR })) | |
.use(express.compress()) | |
.use(store.modelMiddleware()) | |
.use(app.router()) | |
.use(expressApp.router) | |
.use(serverError(root)) | |
expressApp.all('*', function(req) { | |
throw '404: ' + req.url | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment