NC News API is a back-end interface built for modern web applications. It simplifies data management with PostgreSQL databases, enabling flexible interaction via endpoints.
Designed to emulate real-world backend service like reddit, an efficient solution for creating and accessing application data programmatically.
- Visit NC News
- Make a request to an existing endpoint such as /api
- e.g.
https://nc-news-hwajay.onrender.com/api
- Browse through the result
Note:
- Upon visiting the link in step 1, you will encounter a 404 message at the '/' path, which is expected.
- You can find all the existing endpoints in this json file.
- If your data appears on one line, it can be difficult to read. Consider installing a JSON Formatter extension to your browser. For Chrome users, I recommend this one.
Before setting up, make sure your system meets the following requirements:
- Node.js v21.6.1 or higher
- PostgreSQL v15.6 or higher
You can check your versions by running the following commands in your terminal:
node --version
psql -V
1. Clone the repository:
- Navigate to the folder where you want to clone the repo, then type the following commands in your terminal:
git clone https://github.com/aytchhh/project-0.git
-
If you are not familiar with github, check out this article: cloning a repo.
-
After cloning, open this repo in VSCode or your preferred editor.
-
open the terminal within your editor. For VSCode, press Ctrl+` or Cmd+`
- Install dependencies:
npm install
- Setup databases:
npm setup-dbs
npm seed
- To connect to the databases, you will need to create two .env files within the project root directory.
- type the following commands:
touch .env.test
touch .env.development
- Within these files, add PGDATABASE=, with the correct database name for that environment. e.g.
PGDATABASE=my_database
(see /db/setup.sql for the database names)
- After setting up, you should be able to use npm test to run all JEST tests in the test folder
npm test
The endpoints.json file contains details about all the existing endpoints on the API, it requires updating whenever a new endpoint is added.
Refer to the file for examples.