A simple and modern TypeScript API for managing price lists built with Node.js, Express, and PostgreSQL.
- Full CRUD operations for price lists
- TypeScript for type safety and better development experience
- PostgreSQL database with automatic timestamp management
- RESTful API design
- Input validation and error handling
- Security middleware (Helmet, CORS)
- Database migrations and seeding
- Runtime: Node.js
- Framework: Express.js
- Language: TypeScript
- Database: PostgreSQL
- Package Manager: Yarn
- Node.js (v16 or higher)
- Yarn package manager
- Docker (for PostgreSQL database)
The easiest way to get started is using the automated setup script:
git clone <your-repo-url>
cd price-list-manager-api
./setup.shThis script will:
- Start PostgreSQL database using Docker
- Create your
.envfile with correct credentials - Install dependencies
- Set up the database tables
- Seed with sample data
- Give you instructions to start the dev server
If you just want to start developing immediately:
./dev-start.shThis will:
- Check if
.envexists (create if needed) - Start PostgreSQL if not running
- Launch the development server
Edit .env with your PostgreSQL credentials (the setup script handles this automatically):
DB_HOST=localhost
DB_PORT=5432
DB_NAME=price_list_db
DB_USER=postgres
DB_PASSWORD=postgres
PORT=3001
NODE_ENV=developmentThe API will be available at http://localhost:3001
GET /health- Check API status
GET /api/price-lists- Get all price listsGET /api/price-lists/:id- Get a specific price listPOST /api/price-lists- Create a new price listPUT /api/price-lists/:id- Update a price listDELETE /api/price-lists/:id- Delete a price list
curl -X POST http://localhost:3001/api/price-lists \
-H "Content-Type: application/json" \
-d '{"name": "Summer Sale Pricing"}'curl http://localhost:3001/api/price-listscurl -X PUT http://localhost:3001/api/price-lists/1 \
-H "Content-Type: application/json" \
-d '{"name": "Updated Summer Sale Pricing"}'Test Structure: Tests are co-located with source files (e.g., priceList.test.ts next to PriceList.ts)
# Start your day
./dev-start.sh
# Run tests
yarn test:watch
# Fix linting issues
yarn lint:fix
# Stop everything
docker-compose downsrc/
├── controllers/ # Request handlers + tests
├── database/ # Database config, migrations + tests
├── models/ # Data models + tests
├── routes/ # API route definitions
├── types/ # TypeScript type definitions
└── server.ts # Main application file
- Use
./setup.shfor first time setup - Use
./dev-start.shfor daily development - it handles everything automatically - Run
yarn testfrequently to catch issues early - Use
yarn lint:fixto automatically fix code style issues - Check
http://localhost:3001/healthto verify the API is running