This repository contains a NestJS implementation to interact with the TrueAccord Recover API, focusing on the customers
endpoint.
The project follows a Domain-Driven Design (DDD) approach, organizing code based on business domains. The directory structure is organized as follows:
src/
|-- customers/
| |-- dto/
| |-- interfaces/
| |-- services/
| |-- controllers/
| |-- customers.module.ts
|-- app.module.ts
|-- main.ts
- Node.js v14.x
- Docker
Clone the repository:
git clone https://github.com/your-username/trueml-backend-nestjs.git
cd trueml-backend-nestjs
Install dependencies:
npm install
To run the application locally:
npm run start
To run the application inside a Docker container:
docker build -t trueml-backend-nestjs
docker-compose up --build
docker run -d -p 3000:3000 --name trueml-backend-nestjs-container trueml-backend-nestjs
In this command:
-d flag is for running the container in detached mode, which means it runs in the background. -p 3000:3000 flag maps port 3000 on your machine to port 3000 on the container, which is the port your NestJS application is configured to listen on. --name trueml-backend-nestjs-container gives your container a name for easier reference.
The application exposes the following endpoints for interacting with the customers data:
- GET /customers: Retrieve a list of all customers.
- POST /customers: Create a new customer.
- PUT /customers/:id: Update an existing customer.
Run tests using the following command:
npm run test
The application is containerized using Docker, making it easy to deploy in any environment that supports Docker containers.
Install the Google Cloud SDK and Kubernetes CLI (kubectl).
Enable the Kubernetes Engine API for the project.
# Configure Docker to use gcloud as a credential helper
gcloud auth configure-docker
# Tag the Docker image
docker tag trueml-backend-nestjs gcr.io/your-project-id/trueml-backend-nestjs:v1
# Push the Docker image to Google Container Registry
docker push gcr.io/your-project-id/trueml-backend-nestjs:v1
# Create a GKE cluster
gcloud container clusters create trueml-backend-cluster --zone your-zone
# Apply the deployment configuration
kubectl apply -f deployment.yaml
# Expose the application to the internet
kubectl expose deployment trueml-backend-deployment --type=LoadBalancer --port 80 --target-port 3000