A simple CRUD API built with Node.js, Express, and PostgreSQL.
This project allows you to manage client data with endpoints for creating, reading, updating, deleting and searching clients.
- Node.js
- Express.js
- PostgreSQL
- pg (https://node-postgres.com/) (node-postgres)
- dotenv
- CORS
git clone https://github.com/leoangr/node-express-postgres-crud-api.git
cd node-express-postgres-crud-apinpm installCreate an .env file based on .env.example:
CREATE TABLE clients_tb (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
job VARCHAR(50),
rate NUMERIC(10, 2) DEFAULT 100.00,
isActive BOOLEAN DEFAULT TRUE
);npm run devServer will run at: http://localhost:3000
GET /api/clientsPOST /api/clients/Request Body:
{
"name": "Sally",
"email": "sally@gmail.com",
"job": "Web Developer",
"rate": 80,
"isactive": "true"
}PUT /api/clients/:idDELETE /api/clients/:idGET /api/clients/search?q=keywordCreated by leoanggoro.my.id