How to use the boilerplate Step: Use a great boilerplate template Step: Copy the repo, change the details and you are set up! The 6 Areas of a chrome extension Step: Learn the different parts files in the “pages” directory content: stuff you want to add to the dom devtools: devtools tab AND panel: the…
All posts in Javascript
JavaScript, node.js versions with nvm
TLDR: use nvm to manage node.js versions; develop and deploy with the same version. $ nvm ls-remote|tail to see the latest versions $ nvm ls-remote|grep LTS to see the “long term support” versions $ nvm install lts/erbium to install “erbium” (the latest release of version 12) $ nvm install 14 to install the latest version…
Save time: npm install nodemon
Nodemon will allow you to start your node.js project and make changes without manually shutting down and restarting your server. Many people are scared of installing nodemon globally, so here’s a guide to install nodemon locally in your node.js project. Step 1: Install nodemon $ npm install nodemon –save-dev Step 2: Update your npm scripts…
Setting up Redis on Heroku for ExpressJS
By default, your express application will store session data in memory. That means if your server restarts all users will need to log back in. Additionally, this does not scale to more than one instance, leaks memory and does other mean things. While this works while developing your local computer (notice how you always need…
Create an interactive terminal cli with node
Let’s create a tool that will track our some text entries. Step 1: Create a new npm project and install the necessary libraries $ mkdir my_cli && cd my_cli && npm init -y && npm i –save inquirer chalk chalk – helps color the terminal prompts inquirer – makes creating interactive prompts a breeze Step 2: create…
How to publish an npm module
Step 0: You need some code to share. Create a new Github repo or choose one you currently want to publish Here is the command line argument to create a repo called “adder” $ curl -u <your_username> https://api.github.com/user/repos -d “{\”name\”: \”adder\”}” Once you have chosen a Github repo clone it Step 1: Create a proper…
Do not use bcrypt-nodejs
“Invalid salt revision” bcrypt-nodejs is no longer maintained and you might run into this Use bcryptjs for a more secure actively maintained experience. Also, check out Django, its great, but if you do, consider adding bcrypt
Express Sequelize Heroku Postgres Configuration Success
You are in flow developing on your local database and you decide to upload everything to heroku and share it with the world. How do you configure your production database? It’s easier than you think. Let’s assume you have already set up your site. If you used the sequelize init command, you will have a…
How does sequelize pluralize?
If you use .sync with sequlize and have a model name like User, your database ends up with a table called Users. More clearly, when you use the sequelize-cli model generator the generated file will show this pluralized table. Here is the code: (link) What is Utils? * Note Sequelize has a directory called Utils AND a file…
curl express hello world
The official express.js hello world example may crash on certain deployments that rely on a certain PORT. Make sure you use the PORT set on process.env if it is set. const PORT = process.env.PORT || 3000 Complete example (code): const express = require(‘express’) const app = express() const PORT = process.env.PORT || 3000 app.get(‘/’, (req, res) =>…