Skip to content

Node.js REST API with CRUD operations using node-postgres to interact with the PostgreSQL database.

Notifications You must be signed in to change notification settings

deasartech/nc-news

Repository files navigation

Northcoders News API

Check out the hosted version

My goal was to build the back-end for a news app project

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.

How I worked on this project

  • 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

How to navigate this project

  • 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

Why I built the project this way

  • 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

If I had more time I would change this

  • Add more endpoints - for article filtering and user authentication
  • Integrate pagination by adding limits number of responses
  • POST new topics & DELETE articles by ID

Instructions

  1. Clone the repository
  2. Install dependencies with npm install (or yarn)
   npm install
  1. Dotenv - create two .env files to connect to the database
    • .env.development
    PGDATABASE=nc_news
    • .env.test
    PGDATABASE=nc_news_test
  2. Seed local database
   npm run setup-dbs
  1. Run tests with
   npm test
  1. Start server with
npm start

Minimum Version Requirements

  • Node.js: v17.3.0
  • Postgres: 14.1

About

Node.js REST API with CRUD operations using node-postgres to interact with the PostgreSQL database.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published