💡 Help your users easily change their passwords by providing a *well-known* URL.
👉🏼 Redirect a request to "/.well-known/change-password" to the change password page on your site.
Spec: https://w3c.github.io/webappsec-change-password-url/
💡 If you're not using ES Modules (import/export), using "use strict" is still relevant today.
👉🏼 An example of something crazy you can do in sloppy mode.
➡️ var let = 5
Read on the diff between sloppy and strict modes: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode/Transitioning_to_strict_mode#Differences_from_non-strict_to_strict
💡 HTTP Parameter Pollution (HPP) is an attack in which multiple params are sent with the same name, causing your Node.js app to parse them differently.
👉🏼 Use hpp with Express to always resolve with the last value as a String.
🔗 https://www.npmjs.com/package/hpp
💡 Using Nginx as a reverse proxy for your Node.js websocket app?
👉🏼 Add the following config lines to Nginx to make it all work smoothly.
💡 Using PM2 with Node.js?
👉🏼 Your app won't start automatically when the system reboots unless you configure PM2 to run as a daemon service:
1. ➡️ pm2 startup
2. Run the command printed out
3. Start your Node.js app(s)
4. ➡️ pm2 save
🔗 https://pm2.keymetrics.io/docs/usage/startup/
💡 Are you often navigating to the same folders in the terminal?
👉🏼 Add the folders as variables in your source file and type:
➡️ cd $myproject
instead of:
➡️ cd /Users/maxim/Code/myproject
💡 Want to check if a port is open for the public and not blocked by the firewall?
Which command was it again — ss, netstat, lsof or nmap? 🤔
👉🏼 Stop Googling and go to https://www.canyouseeme.org/ . An open port check tool right on the web.
💡 Have you been promisifying the fs module in Node.js all this time like I did?
👉🏼 Not anymore! Node.js >= 10 ships with a native promise implementation of the fs module. #latetotheparty 😅
➡️ require('fs/promises')
💡 Running Node.js as root so you can bind to ports 80/443?
👉🏼 You can relinquish privileges with "process.setuid()" & "process.setguid()" to reduce the damage potential in case of a breach. Do this right after the app starts.
💡 Need to find out how long a section of code or external request takes to complete?
👉🏼 A way to quickly measure this is to use console.time & console.timeEnd.