Skip to content

Instantly share code, notes, and snippets.

Xujiaao xujiaao

View GitHub Profile
@ramonfritsch
ramonfritsch / expressjs-rewrite.js
Created Nov 9, 2016
URL rewrite on ExpressJS 4.0
View expressjs-rewrite.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');
@slavafomin
slavafomin / nodejs-custom-es6-errors.md
Last active Jul 17, 2020
Custom ES6 errors in Node.js
View nodejs-custom-es6-errors.md

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.

Defining our own base class for errors

errors/AppError.js

@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active Jul 29, 2020
Uninstall nodejs from OSX Yosemite
View gist:d75101d9bdf764c890ef
# 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*
You can’t perform that action at this time.