This repository contains the backend for the Auction System.
The backend consists of a Docker configuration file (docker-compose.yml
) and a migration script that needs to be run during the first-time setup.
To set up the backend, follow these steps:
- Ensure that Node.js v18 and npm (Node Package Manager) are installed on your system.
- Navigate to the
backend
directory. - Run the following command to install the dependencies:
npm install
- src/ # Main source parent folder
- docs/ # Source for OpenAPI Specs Yaml and other relevant document
- controllers/ # Route controllers
- libs/ # Reusable libraries
- middlewares/ # Express middlewares
- services/ # Business logic and Data Fetching
- typeorm/ # TypeORM config
- workers/ # Background workers
- app.ts # Express app
- config.ts # Environment variables
- connect.ts # Database connection
- data-source.ts # TypeORM data source
- init.ts # App initialization
- server.ts # HTTP server start
The backend is composed of two services: postgres
and web
.
- Image: postgres:10.7
- Environment variables:
- POSTGRES_USER: testuser
- POSTGRES_PASSWORD: testpass
- POSTGRES_DB: auction-system
- Ports:
- Host: 5432
- Container: 5432
- Volumes:
- ./postgres-data:/var/lib/postgresql/data
- Build context: .
- Dockerfile: dev.Dockerfile
- Links: postgres
- Container name: jtr-auction-express
- Ports:
- Host: 3000
- Container: 3000
- Environment variables:
- PGHOST: postgres
- PGHOST_MIGRATION: postgres
- Volumes:
- ./:/app
The required environment variables can be found in the .env.example
file. Create a new .env
file and copy the contents from .env.example
. Modify the values of the variables as needed.
To set up the backend for the first time, follow these steps:
- Ensure that Docker is installed on your system.
- Navigate to the project root directory.
- Run the following command to start the backend services:
docker-compose up
- After the services are up and running, open a new terminal window and navigate to the project root directory.
- Run the following command to run the migration script:
npm run migration:run
This will start the backend application on port 3000;
- (Node.js)[https://nodejs.org/]
- (OpenAPI / Swagger.io)[https://swagger.io/]
- (Express)[https://expressjs.com/]
- (TypeScript)[https://www.typescriptlang.org/]
- (TypeORM)[https://typeorm.io/]
- (PostgreSQL)[https://www.postgresql.org/]