This is a straightforward Order Management Service developed using Nest.js, a powerful Node.js framework, along with Express. It incorporates Swagger for API documentation, TypeORM for database interactions, Docker for containerization, and PostgreSQL for data storage.
- Use transactions, especially for endpoints like creating orders.
- Enhance the "Update Order" endpoint to accommodate updates in order products.
- Improve test coverage.
- Add missing DTO validation
To quickly set up and run this project locally, follow these steps:
- Install project dependencies:
$ yarn
- Build the project to generate Swagger documentation (see the section below):
$ yarn run build
- Copy the environment configuration files:
$ cp .env.example .env
$ cp docker.env.example docker.env
- Start the application along with PostgreSQL, Redis, and the Nest.js app:
$ docker-compose up -d
Your API will be accessible at http://localhost:3030. To test the API using Swagger with the authentication token provided in the .env
file, follow these steps:
-
Open the Swagger documentation by visiting http://localhost:3030/swagger in your web browser. Replace
localhost:3030
with the appropriate hostname and port if your application is hosted differently. -
Click on an endpoint that requires authentication, such as one that is protected by JWT (JSON Web Tokens).
-
In the Swagger UI, you'll likely find an "Authorize" button. Click on it.
-
In the "Value" field, enter your authentication token as a Bearer token.
If you wish to modify the codebase, you can use docker-compose.dev.yml
to start only PostgreSQL and Redis.
Then, you can run the Nest.js app separately with hot reloading:
$ yarn run start:dev
Install project dependencies with:
$ yarn install
To generate the Swagger API documentation, run:
$ yarn run build
To test the API using Swagger with the authentication token provided in the .env
file, follow these steps:
-
Open the Swagger documentation by visiting http://localhost:3030/swagger in your web browser. Replace
localhost:3030
with the appropriate hostname and port if your application is hosted differently. -
Click on an endpoint that requires authentication, such as one that is protected by JWT (JSON Web Tokens).
-
In the Swagger UI, you'll likely find an "Authorize" button. Click on it.
-
In the "Value" field, enter your authentication token as a Bearer token.
Create environment configuration files by copying the examples:
$ cp .env.development.example .env
$ cp docker.env.example docker.env
To start the application and associated services:
- Launch PostgreSQL and Redis:
$ docker-compose up -f docker-compose.dev.yml
- Start the application in development mode:
$ yarn run start
- Activate watch mode for development (with hot reloading):
$ yarn run start:dev
- Deploy the application in production mode:
$ yarn run start:prod
Execute unit tests, end-to-end tests, or test coverage checks:
- Run unit tests:
$ yarn run test
- Run end-to-end tests:
$ yarn run test:e2e
- Check test coverage:
$ yarn run test:cov
This project is open source and available under the MIT License.