Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
| .... | |
| //This is how you'd do on ExpressJS 3.0 | |
| app.get('/my/route1/', function (req, res, next) { | |
| req.url = '/other/route2/'; | |
| next('route'); | |
| }); | |
| app.get('/other/route2/', function (req, res, next) { | |
| res.send('I am other route 2'); |
| # first: | |
| lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done | |
| sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.* | |
| # To recap, the best way (I've found) to completely uninstall node + npm is to do the following: | |
| # go to /usr/local/lib and delete any node and node_modules | |
| cd /usr/local/lib | |
| sudo rm -rf node* |