Skip to content

Latest commit

 

History

History
49 lines (37 loc) · 1.63 KB

README.md

File metadata and controls

49 lines (37 loc) · 1.63 KB

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