EJS - Templating for Node.JS 6 Free E-Books and Tutorials for Learning and Mastering Node.js OK, we won't bore you by telling you what Node.js is again or why it's so dang hot. You want to learn Node.js? There's no completely finished Node.js book out there that we're aware of. But there's one complete book in rough draft form, two partial guides and several other great resources for learning Node.js. No more excuses: Try Node.js for $0.02 or less in just a few minutes No more excuses: Try Node.js for $0.02 or less in just a few minutes is a short tutorial from the developers of NowJS. Up and Running With Node.js Up and Running with Node.js by Tom Hughes-Croucher hasn't been officially released yet, but O'Reilly Media has released a free text preview of the book as part of its Open Feedback Publishing System. Our previous coverage of the book is here. The Node Beginner Book The Node Beginner Book by by Manuel Kiessling is a new Node.js e-book. Felix's Node.js Guide Felix's Node.js Guide got a lot of attention this week, particularly the Convincing The Boss section. Mastering Node
SlexAxton's yepnope.js at master - GitHub Handle GET and POST Request in Express 4 | Code for geek As per the documentation GET request are meant to fetch data from specified resource and POST are meant to submit data to a specified resource. Express allows you to handle GET and POST request using the instance of express. Due to the depreciation of connect middle-ware handling POST request however seems confusing to many people. GET request: Handling GET request in Express seems so easy. var express = require("express");var app = express(); app.get('handle',function(request,response){//code to perform particular action. GET request can be cached and remains in browser history. POST Request: Express version 4 and above requires extra middle-ware layer to handle POST request. You can install bodyParser by two way. sudo npm install --save body-parser You have to import this package in your project and tell Express to use this as middle-ware. Once configured you can use app.post express router to handle POST request. In this way you can handle the GET and POST request in Express 4. server.js
Package.json dependencies done rightblog This is part one of a three part post on npm Dependency management. Need I say more? Entire developer ecosystems live and die by how dependency management works. Ask a Ruby developer what they would do without RubyGems, or ask (most) Java developers how to get things done without Maven. Npm recently received a pretty serious makeover in Version 1.0. Npm installs modules and applications based on an interpretation of the package.json specification. How npm works with dependencies in a package.json manifest. tldr;? There are two separate (but equally important) entities that must have specified versions in a package.json manifest: modules dependencies and node version. What is slightly modified about it? Ok, so npm uses semver, awesome. The versions for both the dependencies and node properties in the example above are interpreted using node-semver, a library created and maintained by isaacs for working with semantic version strings. Now suppose that we install the above example using npm:
OpenSSL memory use in Node.js | Paul's Journal Last Thursday I went to the Joyent office for Node Office Hours -- I wanted to talk to Isaac about running a private NPM registry. Isaac answered my questions about private NPM registries, but Matt Ranney explained a more interesting problem. He was dialed into a conference call line for Node Office hours (he is currently living in Hawaii.) Matt explained that he is using the new TLS module in Node v0.4, and it was using 1 megabyte of memory per connection! The TLS server says "welcome" to a newly connected client, and then echos anything it receives back to the client: The client spawns 200 connections, and writes 'hello' to the server every 5 seconds for each connection: var tls = require('tls'); function go() { var s = null; s = tls.connect(8000, '127.0.0.1', function() { setInterval(function() { s.write('hello\n'); }, 5000); }); }; var i;for (i = 0; i<200; i++) { go();} Running the client and server on my laptop, the server used almost 200 megabytes of memory. Zlib: Big Buffers "R" us
wtfjs express-redirect express-redirect offers you simple and blazing fast redirection rules. Even very complex redirect rules don't take longer than 1 ms. It just comes down to concatenating strings. Say goodbye to writing 10 lines of code for a plain redirection over and over again. If you want redirections with fancy JS expressions, you should probably check out deviate. Installation $ npm install express-redirect var express = require("express") , redirect = require("express-redirect"); var app = express(); redirect(app); Example app.redirect("/p/:id", "/page/:id"); app.redirect("/p/:id", "/page/:id", 301); app.redirect("/p/:id?" express-redirect mounts the new method app.redirect(route, target, [status], [method]) to your app. route The parameter route is a string and is required. target The parameter target is a string and is required. app.redirect("/a/:id([0-9]+)?" /a -> /b/1 /a/100 -> /b/100 /c -> /d /c/view -> /d/view status The parameter status is an integer and is optional. method License (The MIT License)
Écrire un module pour Node.js $ mkdir sleep-sort $ cd sleep-sort $ git init Parfait, je viens d'initialiser un dépôt et je n'ai plus qu'à le remplir. J'aime beaucoup le concept de Readme Driven Development, dans cet esprit, je vais donc commencer par créer un fichier Readme. $ vi Readme.md $ cat Readme.md `sleep-sort` works by creating a task for every number to be sorted. The task will "sleep" n number of milliseconds and then push the number onto an array. When all tasks are done, the array is returned sorted. $ git add . $ git commit -m 'Added Readme' J'ai donc mis en place un dépôt local et fait un commit du fichier Readme. $ gh create-from-local Counting objects: 3, done. Le code ci-dessus a créé le dépôt distant, envoyé les modifications locales et affecté l'origine. Même si dans cet exemple le module sera relativement simple, je vais créer des répertoires pour y placer les différents fichiers que je vais utiliser. Je crée maintenant les fichiers. Très bien. J'installe ces dépendances avec la commande npm install.
The Node Beginner Book