This repository contains a Node.js + Express REST API backed by PostgreSQL and Sequelize. It supports user management, product management, product image handling, health checks, and telemetry/logging integration for cloud deployment.
- Node.js
- Express.js
- PostgreSQL
- Sequelize ORM
- AWS SDK (for image storage integration)
- Winston logging
- StatsD metrics
- Mocha/Chai/Supertest test tooling
- Packer + Terraform assets for infrastructure workflows
The API is versioned under /v1 for user/product operations, plus /healthz for health checks.
- Uses HTTP Basic Auth for protected endpoints.
- Public endpoints: user registration and health check.
POST /v1/user- Create a new user (public)GET /v1/user/:id- Get user details (Basic Auth)PUT /v1/user/:id- Update user details (Basic Auth)
User payload:
{
"first_name": "John",
"last_name": "Doe",
"username": "john@example.com",
"password": "strong-password"
}POST /v1/product- Create product (Basic Auth)GET /v1/product- List products (public)GET /v1/product/:id- Get one product (public)PUT /v1/product/:id- Full update product (Basic Auth, owner)PATCH /v1/product/:id- Partial update product (Basic Auth, owner)DELETE /v1/product/:id- Delete product (Basic Auth, owner)
Product payload:
{
"name": "Product Name",
"description": "Product description",
"sku": "UNIQUE-SKU-001",
"manufacturer": "Acme",
"quantity": 10,
"owner_user_id": 1
}POST /v1/product/:product_id/image- Upload image (Basic Auth, owner)GET /v1/product/:product_id/image/:image_id- Get one image metadata (Basic Auth)GET /v1/product/:product_id/image- List image metadata for a product (Basic Auth)
Supported upload types are configured in the application. Commonly used types include jpeg, jpg, and svg.
GET /healthz- Service health probe
- Node.js 16+ (or newer LTS)
- PostgreSQL
- npm
npm installUpdate Sequelize DB settings as needed in config/config.json.
The service file in this repo starts the app from seeders/app.js, so use:
node seeders/app.jsNote: npm start currently points to app.js. If you want to use npm start, align it with your chosen entry file.
npm test- Systemd unit file is available under
service/node.service. - Shell helper scripts are available under
shell/. - Packer and Terraform-related files are included for AMI and infrastructure workflows.
