npm i
npm run start
Server will run at http://localhost:3000
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
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)
);
Endpoint POST http://localhost:3000/api/category
Endpoint GET http://localhost:3000/api/category
Endpoint GET http://localhost:3000/api/category/${categoryId}
Endpoint PUT http://localhost:3000/api/category/${categoryId}
Endpoint DELETE http://localhost:3000/api/category/${categoryId}