Guillermo Rodas
Google Developer Expert in Web Technologies, Community Organizer, and Online Teacher.
In the middleton of the middleware
@glrodasz
Guillermo Rodas
Engineer at Auth0
Organizer of Medellín CSS, CSS Conf CO
and Medellín Identidad y Seguridad
@glrodasz
GDE Web Technologies
Curso de Autenticación con OAuth
Curso de Express.js
Web apps, web apis, web services.
Open Source, MIT License.
TJ Holowaychuk,
Sinatra (Ruby).
Icons from www.flaticon.com is licensed by CC 3.0 BY, slide from Curso avanzado de Express.js (Platzi, 2018)
Icons from www.flaticon.com is licensed by CC 3.0 BY, slide from Curso avanzado de Express.js (Platzi, 2018)
Junio 2014
Septiembre 2015
Enero 2016
Slide from Curso avanzado de Express.js (Platzi, 2018)
/ˈmɪdlwɛː/
software that acts as a bridge between an operating system or database and applications, especially on a network.
Slide from Curso avanzado de Express.js (Platzi, 2018)
Slide from Curso avanzado de Express.js (Platzi, 2018)
Object Schema Validation
HTTP-friendly error objects
Slide from Curso avanzado de Express.js (Platzi, 2018)
Slide from Curso avanzado de Express.js (Platzi, 2018)
Errors asynchronous inside route handlers or middleware, you must pass them to the next() function.
if (err) { next(err); } // Pass errors to Express.
If you pass anything to the next() (except the string 'route'), Express regards the current request as an error and will skip any remaining non-error handlers and middleware.
fs.writeFile("/inaccessible-path", "data", next);
Must catch errors asynchronous inside route handlers or middleware, and pass them to Express for processing.
setTimeout(function () { try { throw new Error("Oops!"); } catch (err) { next(err); } }, 100);
The stack trace is not included in the production environment.
You define error-handling middleware last, after other app.use() and routes calls;
Default error handler: Call next() with an error after you have started writing the response (Streams) the default error handler closes the connection and fails the request.
If (res.headersSent) { return next(err) }
Default error handler can get triggered if you call next() with an error in your code more than once, even if custom error handling middleware is in place.
if you have a route handler with multiple callback functions you can use the "route" parameter to skip to the next route handler.
Slide from Curso avanzado de Express.js (Platzi, 2018)
body-parser
cors
morgan
helmet
express-debug
express-slash
passport
By Guillermo Rodas
Explaining how middlewares work in Express.js
Google Developer Expert in Web Technologies, Community Organizer, and Online Teacher.