IBM, Microsoft, Netflix, Yahoo, eBay, GoDaddy, Heroku, PayPal, Trello, Pascal, …
Un grand nombre de PaaS
Serveur dédié (gestion simple)
Plateform as a serviceFaire une seule chose et la faire bien
Certains modules npm tiennent en une fonction
Architecture microservices
console.log("Hello world");
$ node hello.js > Hello world
Chaque fichier est un module isolé
Dépendances explicites synchrones avec
require("foo")
Enfin du code structuré, modulaire, découpé …
var fs = require("fs");
var data = fs.readFileSync("foo.txt", "utf8"); console.log(data);
fs.readFile("foo.txt", "utf8", function(err, data) { if (err) throw err; console.log(data); });
var fs = require("fs");
var done = fs.writeFileSync("foo.txt", "bar"); if(done) console.log("Done");
fs.writeFile("foo.txt", "bar", function(err) { if (err) throw err; console.log("Done"); });
var os = require("os"); os.networkInterfaces() os.platform() // darwin os.cpus().length // 64Plateforms : 'darwin', 'freebsd', 'linux', 'sunos' or 'win32'
var fs = require("fs"); var stream = fs.createReadStream("/dev/urandom"); stream.on("data", function(chunk) { console.log("got %d bytes of data", chunk.length); }); stream.on("end", function() { console.log("there will be no more data."); });
got 65536 bytes of data got 65536 bytes of data got 65536 bytes of data got 65536 bytes of data … # there will be no more data
process.exit(0)
process.env process.memoryUsage()
console.log("1"); process.nextTick(function() { console.log("2"); }); console.log("3"); // 1 // 3 // 2
var express = require('express'); var app = express(); app.get('/', function (req, res) { res.send('Hello World!'); }); app.listen(8080);
On a un Slack !