This is a proposal. It does not match the code as of writing.
This describes the minimum contract that Stream objects must adhere to in order to properly interoperate with pipes.
The parent class for all stream objects. Implements the pipe
var express = require('express'); | |
var app = express.createServer(); | |
app.set('view engine', 'jade'); | |
app.set('port', parseInt(process.env.PORT || 5000, 10)); | |
app.get('/', function(req, res) { | |
res.render('index'); |
diff --git a/node/handler/APIHandler.js b/node/handler/APIHandler.js | |
index a057bfc..7476818 100644 | |
--- a/node/handler/APIHandler.js | |
+++ b/node/handler/APIHandler.js | |
@@ -75,8 +75,8 @@ exports.handle = function(functionName, fields, req, res) | |
//check the api key! | |
if(fields["apikey"] != apikey) | |
{ | |
- res.send({code: 4, message: "no or wrong API Key", data: null}); | |
- return; |
Creationix.route("GET", "/", function (req, res, params, next) { | |
render("frontindex", { | |
title: query("index", "title"), | |
links: query("index", "links"), | |
articles: loadArticles | |
}, function (err, html) { | |
if (err) return next(err); | |
res.writeHead(200, { | |
"Content-Length": Buffer.byteLength(html), | |
"Content-Type": "text/html; charset=utf-8" |
#include "Vector.h" | |
Persistent<FunctionTemplate> Vector::ctor; | |
void | |
Vector::Initialize(Handle<Object> target) { | |
HandleScope scope; | |
ctor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(New)); | |
ctor->InstanceTemplate()->SetInternalFieldCount(1); |
a list of slides from nodeconf
you may want to take a look at the jsconf-gist too!
var fs = require('fs'); | |
OAuth = require('oauth').OAuth; | |
var config = JSON.parse( fs.readFileSync(__dirname + '/default_config.json') ); | |
var oauth = config.oauth; | |
console.warn(oauth); | |
var oa = new OAuth(oauth.requestTokenURL | |
, oauth.accessTokenURL |
var Person = function( name ){ this.name = name }; | |
Person.create = function(name) { return new Person(name) }; | |
Brian = new Person('brianleroux'); | |
Tim = Person.create('tim'); | |
// Lame, I would do this one of three ways depending on how it will be used | |
// If the example really was this simple and there was nothing else involved, | |
// I would use object literals. No need to overcomplicate things |
function createPool (port, host, https, credentials) { | |
var pool = new events.EventEmitter(); | |
pool.clients = []; | |
var getClient = function () { | |
for (var i=0;i<pool.clients.length;i+=1) { | |
if (!pool.clients[i].busy) { | |
return pool.clients[i]; | |
} | |
} |
/** Testing sax push parsing | |
* | |
* The output file should have almost identical | |
* to the input file | |
* | |
* Known issues with this example output | |
* | |
* - Doesn't escape entities. You can do it | |
* manually on the character content. | |
* - Doesn't replicate self-closing tags. |