da Mike Ton mancano 12 anni
1015
Più simili a questo
console.log("Express server listening on port %d", app.address().port)
app.listen(3000);
// Delete
app.del('/documents/:id.:format?', function(req, res){});
// Notice that Express uses del instead of delete
// Update
app.put('/documents/:id.:format?', function(req, res){});
// Read
app.get('/documents/:id.:format?', function(req, res){});
// Create
app.post('/documents.:format?', function(req, res){});
// List
app.get('/documents.:format', function(req, res){});
res.render('index', {});
locals:{title:'Express'}
appconfigure()
production
development
app.use
(express.staticProvider(__dirname + '/public'))
(app.router);
(express.methodOverride());
RESTful HTTP APIs
forms can use hidden variables that express can interpret as a "real" HTTP method
can't rely on browsers understanding HTTP verbs like DELETE
(express.bodyDecoder());
(express.logger());
app.set
('view engine', 'jade');
('views', __dirname + '/views');
Document
=require('./models.js').Document(db);
db
=mongoose.connect('mongodb://localhost/nodepad');
mongoose
=require('mongoose').Mongoose;
app
=express.createServer();
=module.exports
express
= require('express');
issue response
recieves request
mostly idle
open
to push from server
event loop archetecture
nonblocking
doesn't wait, moves to next task until call backed
single thread
only one thing happening at once
wrapper around V8
makes more js more useful for the context where people use Node
nonblocking library
databases
filesystem