This is a backend project created to maintain users, articles, topics and comments data within a relational database management system. The database respondes to specific HTTPS requests such as POST, GET, PATCH and DELETE in order to manage the data within the tables. This RESTful API has been built utilising Node.js, PostgreSQL and Express.js framework it enables clients to perform CRUD (Create, Read, Update, Delete) operations, and it has been thoroughly tested using Jest framework and Supertest library to ensure the endpoints respond as expected.
The available endpoints and expected responses are documented within the endpoints.json file at the root of this repository. You can also access the live version via the URL ( https://nc-news-qvgz.onrender.com/api ).
Below are some examples of the currently live endpoints available.
- Articles: https://nc-news-qvgz.onrender.com/api/articles
- Users: https://nc-news-qvgz.onrender.com/api/users
- Topics: https://nc-news-qvgz.onrender.com/api/topics
CRUD Operation examples using the article table within the database.
CRUD | HTTP | ENDPOINTS | RESPONSE |
---|---|---|---|
CREATE | POST | /api/articles | Posted article object |
READ | GET | /api/articles/:article_id | Gets article object by id |
PATCH | PATCH | api/articles/:article_id | Updates article votes by id |
DELETE | DELETE | /api/articles/:article_id | Deletes articles by id |
- Install git (https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and node (https://nodejs.org/en/download/)
- Clone this repository by running the following command
git clone https://github.com/ClaudioCamba/be-nc-news.git
in the terminal / CLI - Install the project dependencies by running the following command
npm install
- Create .env.development and .env.test files in the be-nc-news root directory
- Assign database to each file (.env.test file should have
PGDATABASE=nc_news_test
and for .env.developmentPGDATABASE=nc_news
). The database name can be found in (db/ seeds/ setup.sql), assign appropriate database names in each file. - run
npm run setup-dbs
to create the databases - run
npm run seed
to seed the databases - Now you have the databases setup you can run tests by running
npm run test
command to begin running tests on each endpoint within the (tests/app.test.js) file directory.
- Node: v10.24.1
- Postgres: v8.7.3