Setting up NodeJS and required packages
Tutorial on how to setup NodeJS and packages using npm for the webserver
Installing NodeJS
Go to https://nodejs.org/en/download and download the right version of NodeJS for your system
Open the installer, accept the terms of service and press next until you see the install button. Press it and after some time you will se a message that NodeJS is successfully installed.

To check that node is installed you can type node
into your terminal and you should see a message that says Welcome to Node.js vXX.X.X
Installing packages
NodeJS includes a package manager called NPM (Node Package Manager). We will use this to install the necessary packages for the webserver to run
First create a folder for the webserver to run in.
Next navigate into the folder using your terminal or in windows you can open the folder Ctrl + Right-Click
and select open terminal here.
Then you need to initialize your project by typing this into your console
npm init -y

Next install the necessary packages using this command
npm install pg express body-parser float-array-to-string dotenv
Body parser: This package makes it so we can take in JSON files sent the webhook from the things stack and use them to insert data into our database
PG (postgres): This package makes it so we can connect and query a postgres database.
Express: This package is the main web framework for the server.
Dotenv: This package makes it so we can use a
.env
file or the main enviroment variables on the computer to store our database details in to make the server more secure.

Last updated