Link to the Hosted Backend Server
See the hosted version of this backend by following this link --> Api Server
This project was a challenge given to myself from Northcoders to show the backend skillset I have been taught during my time on the course. The backend will be used as A RESTful API to insert into my front end project. This will be a type of socail media platform where users can add reviews of their chosen board games, share with others and have other users to be able to comment and like/dislike their posts.
This project has be coded to show the backend skillsets in which i have learnt during my time on the software engineering course at Northcoders. During the development process of this backend project, i used Test Driven Development (TDD) to make sure that the code works as intended. I tested GET, PATCH, POST and DELETE requests and for errors to improve the server's error handling.
A set of packages/frameworks was used -
Node.js:
Allows data to be fetched asynchronously from a database
Express:
This gives ways of request handling and usage of HTTP methods
Postgres SQL:
A relational database
Dotenv:
locates local .env files to be use securely in application
Jest:
Creates tests to make sure code works as intended
Supertest:
Adds tests for HTTP requests
Model View Controller (MVC) archetecture was used as a means to organise the server by isolating it's components in a more manageable way
To have your own clone of this project on your local machine, copy the HTTPS url (or SSH if you have previously set one up. You can create this by following this tutorial -> https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
then open the terminal and then change directory to one where you want to place this repository in.
next, insert into your terminal:
git clone 'INSERT-URL-HERE'
A copy of this repo will now have downloaded onto your local machine
This API server requires that anyone who pulls from this REPO to edit the .env files manually otherwise you will recieve the error...
throw new Error('PGDATABASE not set')
For these databases to be found correctly, you must use the template of PGDATABASE=DATABASE_NAME.
For this repo,
the file
.env.development
needs to read PGDATABASE=nc_games
the file
.env_test
needs to be PGDATABASE=nc_games_test
Remember that it is crucial to omit the semicolon ';' at the end of our line as it will not work and cause more errors!
Simply enter into your terminal:
npm i
All dependencies required to run this server locally will be installed
To do this, in the terminal write
npm run seed
This project uses jest to run our tests. To do this in the terminal write:
npm t
Create three files named .env.test
, .env.development
, .env.production
in the root of the repository
PGDATABASE=[your_database_name_here] // .env.development
PGDATABASE=[your_test_database_name_here] // .env.test
DATABASE_URL=[your_database_url_here] // .env.production
Node: 18.6.0
Postgres: 14.4