A simple news API complete with topics, articles, users, comments, and some sample data to get started. Part of a backend project to learn more about building REST APIs using Express.js, interacting with postgres databases and CRUD operations, error handling, TDD, and best practices.
Try it out HERE for a preview
(As this is a 🔬small🔬 project, it's deployed on a free plan so the instance might spin down with inactivity every 15 mins. If your first request takes a few seconds, this is likely the reason why)
Some of the supported GET
endpoints to try out:
GET /api
GET /api/topics
GET /api/articles
(with optional query parametertopic
, try?topic=coding
)GET /api/articles/:article_id
GET /api/articles/:article_id/comments
For a full list of available endpoints and their detailed descriptions, check out endpoints.json
, or /api
To run the development server and tests on your own device:
Important
Make sure you have node.js and npm installed and updated, and psql setup and running before proceeding.
This project was developed using node.js v20.5.0
, npm 9.8.0
, and psql 14.8
git clone https://github.com/Ak5cel/nc-news.git
cd nc-news/
npm install
This will install all dependencies, including the devDependencies used for testing and seeding the development+test databases
Create two dotenv files .env.test
and .env.development
in the root directory as follows:
# in .env.development
PGDATABASE=nc_news
# in .env.test
PGDATABASE=nc_news_test
npm run setup-dbs
npm run seed
(The tests are setup to automatically re-seed the testing database before each test)
# to run full test suite (using jest)
npm test
# (OR)
# to run just the tests for the api endpoints
npm test app
npm run dev
All good! 🎉
Now open up a client (Insomnia, Postman, browser, or from your terminal using curl
) and make a GET
request to http://localhost:9090/api
to get started.
💜