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
/Volumes/Data/kr_devtools/kr/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:134 | |
if(err != null) return internalCallback(err, null); | |
^ | |
TypeError: object is not a function | |
at CALL_NON_FUNCTION (native) | |
at [object Object].<anonymous> (/Volumes/Data/kr_devtools/kr/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:134:28) | |
at [object Object].g (events.js:156:14) | |
at [object Object].emit (events.js:70:17) | |
at /Volumes/Data/kr_devtools/kr/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:367:35 |
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
//Includes | |
var uriAssembler = require('./common/util/uriAssembler.js'); | |
//Initialize configuration data | |
var cfg = exports.cfg = require('./common/util/configuration.js') | |
.ensureLoad('/common/config/'); | |
// [...] | |
//Initialize mongoose | |
var mongoose = require('mongoose'); |
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 connect = require('connect') | |
, http = require('http'); | |
var app = connect().use(connect.static('staticRootHere')); | |
var server = http.createServer(app); | |
var io = require('socket.io').listen(server); |
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
<!-- This should be served by your server --> | |
<script src="/socket.io/socket.io.js"></script> | |
<script> | |
var socket = io.connect('http://localhost'); | |
socket.on('news', function (data) { | |
console.log(data); | |
socket.emit('my other event', { my: 'data' }); | |
}); | |
</script> |
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){ |
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
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
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
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
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. |