First step is to convert all the env.example files to .env files. Every service has it's own .env file, and the .env.example file is located in the root of the service directory.
cp .env.example .env
Every service has its own env.example file. You will have to copy that file into an .env file.
cp .env.example .env
To set up the environment, you will need to first install Docker. Navigate to the project directory and run:
docker compose up
To bring up the services. You will see the pino logs starting to appear. This will stand up the services, You will see the pino logs starting to appear.
Run the tests with the following command: The tests that fail are the ones not implemented yet.
pnpm run test
- Typescript
make sure that you have docker installed in order to spin op all the services. Each service should have it's .env.sample file that you need to convert into .env files. Add the ports that you want each service to have. Note: auth, roles, permissions each have tcp ports for internal communication, since roles, and permissions supply proper authorizatino, and auth supplies authentication. --
See this DOC FILE for more info FIRST: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ Enter the following commands in the terminal:
brew tap mongodb/brew
brew update
brew install mongodb-communitythe mongod.conf file may have different locations depending on your OS.
- conf file location:
/usr/local/etc/mongod.conf - log directory location:
/usr/local/var/log/mongodb - data directory location:
/usr/local/var/mongodb
- conf file location:
/opt/homebrew/etc/mongod.conf - log directory location:
/opt/homebrew/var/log/mongodb - data directory location:
/opt/homebrew/var/mongodb
function mongo() {
if [ $# -eq 0 ]; then
echo "Opening MongoDB Service Client ..."
brew services start mongodb-community
echo "Verifying that MongoDB has started successfully ... "
ps aux | grep -v grep | grep mongod
fi
if [ "$1" = "--restart" ]; then
echo "Restarting the mongodb service ..."
brew services restart mongodb-services
fi
if [ "$1" = "--stop" ]; then
echo "Stopping MongoDB Service ..."
brew services stop mongodb-community
fi
}open your conf file with nano, vim, or code,
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /usr/local/var/mongodb
net:
bindIp: 127.0.0.1, ::1
ipv6: trueNote the location of the log file and associate it with the mongod executable.
mongod --dbpath /usr/local/var/mongodbmongosh "mongodb://127.0.0.1:12027/database_name"brew update
brew upgrade mongodb-community
brew upgrade mongosh- Typescript
Is located in the libs/src directory.
Every microservice has its own PORT & TCP PORT. Here they are listed
- AUTH SERVICE: 3200
- LOCATION SERVICE: 3350
- LOGGED TIME SERVICE: 4400
- TASKS SERVICE: 3400
- WORKER SERVICE: 3100
Each respective service has an api global prefix configured in its main.ts file,
- AUTH SERVICE: http://localhost:3200/api
- LOCATION SERVICE: http://localhost:3350/api
- LOGGED TIME SERVICE: http://localhost:4400/api
- TASKS SERVICE: http://localhost:3400/api
- WORKER SERVICE: http://localhost:3100/api
- AUTH SERVICE : http://localhost:3200/api/swagger/docs
- LOCATION SERVICE : http://localhost:3350/api/swagger/docs
- LOGGED TIME SERVICE : http://localhost:4400/api/swagger/docs
- TASKS SERVICE : http://localhost:3400/api/swagger/docs
- WORKER SERVICE : http://localhost:3100/api/swagger/docs
We are using the Mongodb Data store to store and manipulate the data. This is a global module that is accessible to every service, and this is configured within each service's module.ts file.
THis is configured within each service' module.ts file.
- Custom authentication guards. Can authenticate a route in a matter of seconds.
- Microservices in a monorepo with global shared resources
- Microservices communicate via TCP
- SOLID principle methodology
- Using custom authentication guards for authorization & authentication
- API DESIGN Follows open api specification
- Authenticated user can transact these queries per the JwtAuthGuard
- PINO HTTP LOGGER
- response Serializer ( can be understood by AWS Cloudwatch )
- Mongodb Data store
- Authentication Guard
- Response interceptor ( formats the responses into a data property, and outputs API current version )
- Global API prefix on API calls
- Swagger doc generator
- Custom API version reader that is diplayed by the response interceptor, and swagger docs
- Global directory aliases that allows us to write elegant paths in imports. For example, instead of writing ;
import { AuthService } from '../../../auth/auth.service';We can write:
import { AuthService } from '@auth/auth.service';- Create buildspec for deploying microservices into AWS ECR repositories.
- Kubernetes deployment configurations
- Jest Tests
- Customized logger for production, and development ( development uses pino-pretty )
- Database migration configuration
locationIds:65f779ac7056875318f35df5
includeCompleted:false
workerIds:65f8a856867b4bab8ab29f88,65f9f93cc17f352415384d64,65f779ac7056875318f35dfb