https://nc-news-836l.onrender.com/api
An API for the purpose of accessing application data programmatically. The intention here is to mimic the building of a real world backend service (such as Reddit) which should provide this information to the front end architecture.
- Setting up and querying a PostgreSQL database.
- Using a Test Driven Development approach to cover both the happy and error paths.
- Setting a RESTful API with a number of endpoints which cover CRUD operations.
- Setting up parametric endpoints.
- Handling complex queries.
- Manipulating data to respond to client requirements.
- Using Express routing to handle client requests.
- Hosting the server and database via ElephantSQL and Render.
https://github.com/swlho/nc-news.git
Once the repo is cloned to a local machine, run the following in the terminal:
npm install
This will install all the necessary project dependencies
N.B Ensure installed node version is v20.0.0 or above and Postgres is v8.11.3 or above
Create two .env files in the root folder of the project: .env.test and .env.development. Into each, add 'PGDATABASE=' followed with the correct database name for that environment (see /db/setup.sql for the database names).
N.B. Before committing any code, double check that these .env files are included in the .gitignore file.
Create the local databases by running the following in the terminal:
npm run setup-dbs
Seed the local databases by running the following in the terminal:
npm run seed
To run the Jest test suite, run the following command:
npm test app
To access the api through a web browser or a platform like Insomnia, first run the following command to initialise the server listener:
node listen.js
If successful, the message "Listening on port 9090!"
should appear in the terminal
Then use localhost:9090/api
to access the api endpoint documentation to explore the different available endpoints