Skip to content

Instantly share code, notes, and snippets.

View ovaillancourt's full-sized avatar

Olivier Vaillancourt ovaillancourt

  • Workleap
  • Montreal, QC, Can
View GitHub Profile
var mongoose = require('mongoose');
mongoose.connect("yourServerUrlHere", function(err){
if(err){
console.log("Error connecting:",err);
}
else{
console.log('connected!');
}
});
var cfg = require('kr-common').config;
var express = require('express');
var app = express.createServer();
var fs = require('fs');
//Html bundler
app.use(require('./server/htmlBundler')({
dirs : [ __dirname + '/static/templates',
{path: __dirname + '/static/templates/controls', namespace: 'controls'}
var hogan = require('hogan.js');
var t = hogan.compile('{{<super}}{{$title}}sub template title{{/title}}{{/super}}');
var s = hogan.compile('...{{$title}}Default title{{/title}}...');
var o = t.render({}, {"super": s});
console.log(o);
1- If a <base> tag exists, use this as the base path, or the "mount point" by default.
The mount point defaults to '' if the base tag isn't there.
2- If the user calls page.base, override the mount point extracted in point 1.
3- Always prepend the mount point.
1- If a <base> tag exists, use this as the base path, or the "mount point" by default. The mount point defaults to '' if the base tag isn't there.
2- If the user calls page.base, override the mount point extracted in point 1.
3- Always prepend the mount point.
var express = require('express');
var app = express.createServer();
app.use(app.router);
app.get('/:john*', function(req,res, next){
res.send('It worked \n req.param(\'john\') = ' + req.param('john'));
});
var Evented = function(){
this._ev = $({});
}
Evented.prototype.on = function(){
this._ev.on.apply(this._ev, arguments);
return this;
}
Evented.prototype.off = function(){
app.use('/my/path/to/css', require('stylus').middleware({
debug: process.env.NODE_ENV !== 'production',
}));
#!/usr/bin/env node
var application_root = __dirname,
express = require("express"),
path = require("path");
var app = express.createServer();
// Config
@ovaillancourt
ovaillancourt / afterouter.js
Created June 4, 2012 18:04
middlleware that catches stuffs the router didn't serve.
var express = require('express');
//Create the express app;
var app = express.createServer();
app.use(app.router);
//You place this middleware right after your router so paths that the
//router can't match will go through it and finally end here.
app.use(function(req, res, next){