A RESTful API built with Express.js and PostgreSQL for managing items with full CRUD operations.
- Express.js server configured with ES modules
 - PostgreSQL database connection using 
pglibrary - Environment configuration with dotenv
 - CORS enabled for cross-origin requests
 - JSON parsing middleware configured
 
├── index.js           # Main server file
├── db.js             # Database connection configuration
├── routes/
│   └── items.js      # Items API routes
├── package.json      # Dependencies and scripts
├── .env             # Environment variables
└── .gitignore       # Git ignore rules
All endpoints are prefixed with /api/items
| Method | Endpoint | Description | 
|---|---|---|
| GET | / | 
Get all items | 
| GET | /:id | 
Get item by ID | 
| POST | / | 
Create new item | 
| PUT | /:id | 
Update item by ID | 
| DELETE | /:id | 
Delete item by ID | 
The API expects an items table with the following structure:
CREATE TABLE items (
  id SERIAL PRIMARY KEY,
  name VARCHAR(255) NOT NULL,
  description TEXT
);- Full CRUD operations for items
 - Input validation (name is required)
 - Error handling with appropriate HTTP status codes
 - Partial updates using COALESCE for PUT requests
 - Environment-based configuration
 - Development and production scripts
 
- express: Web framework
 - pg: PostgreSQL client
 - dotenv: Environment variable management
 - cors: Cross-origin resource sharing
 - nodemon: Development auto-restart (dev dependency)
 
- Install dependencies: 
npm install - Configure environment variables in 
.env - Start development server: 
npm run dev - Start production server: 
npm start 
- Default port: 3000
 - Health check endpoint: GET 
/returns "API is running 🚀" - Database: PostgreSQL with connection pooling
 
PORT=3000
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=your_database_name






