Skip to content

Starter project for CRUD APIs using PostgreSQL database and Node.js / Express.js

Notifications You must be signed in to change notification settings

mohitsehgal/nodejs-postgres-starter

Repository files navigation

Setup

npm i

Run the project

npm run start

Server will run at http://localhost:3000

About

Complete code to create CRUD REST APIs using Node.js / Postgres DB. It uses all standard HTTP Verbs like GET, POST, PUT, and DELETE to perform the CRUD operations. We have taken the example for e-commerce category with fields: i) Title ii) Description

Table Creation

CREATE TABLE categories (
	id int4 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START 1 CACHE 1 NO CYCLE) NOT NULL,
	title varchar NOT NULL,
	description varchar NULL,
	CONSTRAINT category_pk PRIMARY KEY (id)
);

Insert / Create Entry

Endpoint POST http://localhost:3000/api/category image

List all entries

Endpoint GET http://localhost:3000/api/category

Get Single Entry

Endpoint GET http://localhost:3000/api/category/${categoryId} test get API in postman

Update Entry

Endpoint PUT http://localhost:3000/api/category/${categoryId} Check update in postman for Node js Postgres API

Delete Entry

Endpoint DELETE http://localhost:3000/api/category/${categoryId} image

Releases

No releases published

Packages

No packages published