This project is a Node.js REST API with GET, POST, PATCH and DELETE requests. Using node-postgres to interact with the PostgreSQL database. The client can create and manage new articles, users, topics and comments. It is an example of a back-end service allowing access to application data programmatically which serves the information to the front-end architecture.
- I built this REST API using TDD
- I worked with tasks on kanban board see here
- I used feature branches and pull requests see here & here
- Use MVC pattern: Model handles and then sends data to controller see here
- Testing using Jest see here & here
- REST API available endpoints see here
- Express JS is robust and more concise than setting up a server using http
- Node-postgres allows simple interfacing with PostgreSQL database and works well with Express
- Testing using Jest (unit testing), supertest (integration testing) & Husky to test on every commit
- Add more endpoints - for article filtering and user authentication
- Integrate pagination by adding limits number of responses
- POST new topics & DELETE articles by ID
- Clone the repository
- Install dependencies with npm install (or yarn)
npm install
- Dotenv - create two .env files to connect to the database
- .env.development
PGDATABASE=nc_news
- .env.test
PGDATABASE=nc_news_test
- Seed local database
npm run setup-dbs
- Run tests with
npm test
- Start server with
npm start
- Node.js: v17.3.0
- Postgres: 14.1