A simple, RESTful API created to learn Express and Postgres
The purpose of this API is to enable me to learn about utilising Express.js and PostgreSQL and how to utilise them in conjunction to create a stable API with a plethora of endpoints, with versatile queries and parameters on each endpoint. The API is considered a RESTful API with stateless requests and a uniform interface.
Concepts I have learned from this project:
-
How to set up different environments and databases for production, development and testing.
-
How to structure complex SQL queries utilising sanitised, dynamic user-inputs.
-
The MVC pattern.
-
Testing asynchronous code with Jest.
-
Hosting with Heroku.
-
How to utilise JWTs for authentication.
If you would like to view this API, you can click here to view and interact with it through your browser (Firefox/Chrome recommended for the built-in JSON prettier). Alternatively, you can follow the steps below to have it operating locally on your machine.
-
Fork and clone the repository on your machine.
-
Make sure you have Node >v14.x and the latest version of PostgreSQL installed.
-
cd
into the cloned repo and runnpm install
to install the dependencies. -
Once all dependencies are installed, create a
.env.test
and.env.development
file within the root directory of the cloned repo and follow the structure set out in .env-example. -
Once the
.env
files have been created, run thenpm run setup-dbs
command followed bynpm run seed
to create and populate the necessary tables. -
Finally, run
npm test
to make sure that all of the tests are passing.
Note: you can use the
npm run dev
command to start the server and explore the API with an API client such as Insomnia or Postman.
Make a GET request to /api
to view all of the available endpoints and their queries/parameters, as well as example responses.
-
Integrate JWT authorization to protect endpoints.Done. -
Implement image storage and random generation of images for categories.
-
Add more endpoints.
This API is released under the terms of MIT License. For more details click here.
Thanks to the whole team at Northcoders for providing such an incredible learning environment, and a notable mention to Chipie for such a comprehensive code review.