This is a backend server for a news application built with Express.js and PostgreSQL. The server provides API endpoints for managing news articles, topics, users, and comments. It supports CRUD operations and can be extended for various features such as user authentication, pagination, and more.
You can view the API live and view the endpoints that are available here
The frontend repository - the live demo can be seen here
For a better experience viewing JSON responses, install a browser extension like JSON Formatter
- Clone the repository:
git clone https://github.com/TTibbs/be-nc-news.git
cd be-nc-news
npm install
Ensure you have PostgreSQL installed locally or use a hosted database such as Supabase.
If using Supabase:
- Sign up at Supabase
- Create a new project and retrieve your database URL.
- For development:
npm run seed
- For production:
npm run seed-prod
Set up the following .env files for different environments:
.env.development
PGDATABASE=your_development_database_name
.env.test
PGDATABASE=your_test_database_name
.env.production
DATABASE_URL=your_supabase_database_url
Notes:
- PGDATABASE is for local development and testing.
- DATABASE_URL is used in production (e.g., when deploying to Render).
- Ensure .env.* is added to .gitignore to avoid exposing credentials.
Method | Endpoint | Description |
---|---|---|
GET | /api | Lists all available endpoints |
GET | /api/users | Lists all users |
GET | /api/topics | Lists all topics |
GET | /api/articles | Lists all articles |
GET | /api/articles/:article_id | View an article by its ID |
GET | /api/articles/:article_id/comments | View comments on an article by its ID |
POST | /api/articles/:article_id/comments | Creates a new comment on the article |
PATCH | /api/articles/:article_id | Updates the votes on an article |
DELETE | /api/comments/:comment_id | Deletes a comment by its ID |
You need to make sure you have these minimum versions of node.js and postgres in order for the project to run successfully:
- Node.js ^22.5.1
- Postgres ^14.13
To start the server:
npm run start
If you want to include more functionality and tests, you can run them with:
npm test
--- or shorthand
npm t
This portfolio project was created as part of a Digital Skills Bootcamp in Software Engineering provided by Northcoders