This past week, I was setting up a Node.js backend for the first time and fell into a rabbit hole while researching the organizational development options. Enter Git Hooks—these allow the user to run custom scripts whenever a specified git event occurs. You can write the hooks in any language you’d like and you can even view example scripts that git installs when you git init your project directory. Navigate to .git/hooks to check them out.

I also came across the NPM package commitlint which follows the Conventional Commits spec. This is a spec of what should and should not…


In the olden times, the times before ES6 javascript only allowed us to declare variables using var like so

var x = 10

This makes sense var meaning variable is equal to 10. So why do we have to use let and const? Well the problem lies with how the variable is scoped. Variables declared with var can be reassigned and can be hoisted or declared before they actually occur from top to the bottom in your code.

Basically, you can never be too sure what the value of your variable is going to be if you are not extra…


Photo by Arnold Francisca on Unsplash

CODEX

Procs and Lambdas are both used similarly but are different in a particular way. Both are higher order functions which are functions that take other functions as parameters or returns them as a result. Breaking that down further a block is a nameless method that is passed to another method as a parameter.

Blocks cannot be saved as variables. They are one of the few instances in which the ruby “everything is an object” rule is not true.

Procs

Procs are blocks of code that can be bound to a set of local variables. …


Part 3: Adding MongoDB to our API

We will continue from where we left off in this tutorial series by adding MongoDB to our API. If you are just starting now feel free to clone all the code from the previous tutorial here.

First we need to download the MongoDB community server. Make sure to pick the right download for your operating system and then follow the instructions to install and get it running on your system on your system. MongoDB community server is completely free for anyone to use!

Now back to the project. In your /src folder create a file named connect.ts. It’s here we…


In Ruby on Rails we can use the ActiveStorage gem to upload files to your database. Although it takes a little getting used to, it allows you to rather simply upload an image and (in my case) save it in an AWS S3 bucket, then saves the S3 url as in a table as a blob with another table that references it’s placement in the blog table.

So how do we do this in Node.js?

That has what I’ve been researching currently and there seem to be two popular approaches.

Approach 1: aws-sdk, multer and multer-s3

Approach one is to use install the above packages which…


Part 2: Creating a Model, Router and Controller

On the last tutorial we created a very basic ‘Hello World’ implementation of Express.js. In this part of the series we will create a Model, Router and Controller. With the goal of creating a Movie lookup API.

Open up the app me we made in the last tutorial. If you’re just joining now you can clone down it down from my github, here.

Ok now we are ready to go, first lets install body-parser. Although we have a very simple server thus far, as we start adding requests to and from body-parser will make our lives much easier. …


TypeScript allows us to write error proof code by specifying which type the variables we write are. This makes it easier for anyone new to the codebase you are working on to understand what data type is going where.

The most basic data types are

string
number
boolean
enum
void
null
undefined
any
never
array

String

String type is mean for a sequence of one or more characters that may consist of letters, numbers, or symbols.

Number

Javascript does not specify between different types of numbers (floats, short, long) besides bigInt. In JavaScript/TypeScript numbers are always stored as double floating point numbers.

Boolean


Part 1: How to setup basic Express API server

This will be a quick run through how to setup basic Express API server.

Go ahead and create a new directory and open it in your IDE. Initiate the project with npm with the following command

$ npm init -y

This will setup your package.json file with all the default values. If you wish to go through the prompt to fill out all the fields manually just remove the -y flag.

Alright lets get to work. First, lets install express.

$ npm i express 

Since we are using TypeScript lets add it to the project as well as the types…


I’m currently in the process of taking what I learned from the Flatiron School’s Software Engineering program and building upon it. Right now, I’m focusing on learning how to make a backend API using Node.js and also giving noSQL databases a go. Welcome MongoDB.

The difference between using MongoDB and Postgres (what I used in past projects) is pretty clear. A MongoDB database just looks like JSON. When working directly in the shell, all queries are written in Javascript too. It all feels quite comfortable. One feature I found interesting was the ability to create indexes.

An Index is its…


We all need documentation to understand how a new API works, and nothing turns me away faster from learning something new than poorly presented documentation. Grammar or spelling aside (you should always do a double check!), here’s how to use a very basic and powerful, easy-to-use formatting language called Markdown.

Markdown is a markup language that’s meant to be easy to read and format. Its main source of inspiration is a plain old email. There aren’t a lot of features, but for a simple README file, it’s plenty. With these easy options you can create an inline html file for…

Ward Price

Software Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store