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 mongoose = require('mongoose'); | |
mongoose.connect("yourServerUrlHere", function(err){ | |
if(err){ | |
console.log("Error connecting:",err); | |
} | |
else{ | |
console.log('connected!'); | |
} | |
}); |
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 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'} |
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 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); |
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
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. |
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
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. |
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 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')); | |
}); |
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 Evented = function(){ | |
this._ev = $({}); | |
} | |
Evented.prototype.on = function(){ | |
this._ev.on.apply(this._ev, arguments); | |
return this; | |
} | |
Evented.prototype.off = function(){ |
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
app.use('/my/path/to/css', require('stylus').middleware({ | |
debug: process.env.NODE_ENV !== 'production', | |
})); |
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
#!/usr/bin/env node | |
var application_root = __dirname, | |
express = require("express"), | |
path = require("path"); | |
var app = express.createServer(); | |
// Config |
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 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){ |