Welcome to my backend project!
This is the RESTful API for Northcoders News, a Reddit-like application, developed using Node.js and PostgreSQL. The purpose of this project is to provide a platform where users can share articles, comment on them, and vote for their favourites.
The hosted version of this project can be found on https://nc-news-dkoj.onrender.com
- Database hosted on ElephantSQL
- API hosted on Render
To get started with this project, follow these instructions:
Before running the server, make sure you have the following installed on your machine:
- Node.js v21.7.1
- Postgress server version 16.2
-
Clone the repository
git clone <repository-url>
-
Navigate into the project directory:
cd be-nc-news
-
Create two .env files:
.env.test
.env.development
-
Into each
.env
file, addPGDATABASE=
, with the correct database name for that environment (see /db/setup.sql for the database names)- please ensure the
.env
files are .git.ignored
- please ensure the
-
Install the dependencies
npm install
-
Set-up database
npm run setup-bds
This project uses jest as a testing framework. The test database is being re-seeded before each test. To run the test file use the following command:
npm test
- To seed the database run:
npm run seed
- To start the server, run the following command:
npm run start
By default, the server will run on port 9090. You can access the API at http://localhost:9090/api
- GET - Get all endpoints of the api
- GET - Get all topics
- GET - Get all articles. Accepts queries: "author", "topic", "sort_by", "order"
- POST - Inserts a new article
- GET - Get an article by ID
- PATCH - Updates the votes value of an article
- GET - Get all comments for an article.
- POST - Inserts a new comment to an article
- DELETE - Delete a comment
- PATCH - Updates the votes value of a comment
- GET - Get all users
- GET - Get an user by username
For more detailed information about each endpoint, refer to the endpoints.json
file
Contributions are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request.
This project was developed as part of the Northcoders Software Development bootcamp curriculum.