📖 Nest.js based microservice repository template
MIT License
Otasoft Microservice template - Nest.js based microservice repository template. This project consists of:
Otasoft projects are and always will be open source (MIT Licence). Anyone can use and support the project. The project is currently in the development phase.
To start developing the project please check if you have these tools installed on your machine:
git clone https://github.com/otasoft/microservice-template
cd microservice-template
yarn
cp .env.example .env
docker-compose up
yarn start:dev
main.ts
from microservice const app = await NestFactory.createMicroservice(AppModule, {
transport: Transport.RMQ,
options: {
urls: [
`amqp://${process.env.RABBITMQ_DEFAULT_USER}:${process.env.RABBITMQ_DEFAULT_PASS}@${process.env.RABBITMQ_NODENAME}:${process.env.RABBITMQ_FIRST_HOST_PORT}/${process.env.RABBITMQ_DEFAULT_VHOST}`,
],
queue: 'microservice_queue',
queueOptions: {
durable: false,
},
},
});
await app.listen(() => {
logger.log('Microservice is listening');
});
const app = await NestFactory.create(AppModule);
await app.listen(3000);
@MessagePattern({ role: 'item', cmd: 'get-by-id' })
async getItemById(id: number): Promise<ItemEntity> {
return this.itemService.getItemById(id);
}
@MessagePattern({ role: 'item', cmd: 'create' })
async createItem(createItemDto: CreateItemDto): Promise<ItemEntity> {
return this.itemService.createItem(createItemDto);
}
@Body()
, @Param()
) @Get('/get-by-id/:id')
async getItemById(@Param('id') id: number): Promise<ItemEntity> {
return this.itemService.getItemById(id);
}
@Post('/create')
async createItem(@Body() createItemDto: CreateItemDto): Promise<ItemEntity> {
return this.itemService.createItem(createItemDto);
}
See the open issues for a list of proposed features (and known issues).
You are welcome to contribute to Otasoft projects. Please see contribution tips
Otasoft projects are and always will be Open Source.
Core team and contributors in the Otasoft ecosystem spend their free and off work time to make this project grow. If you would like to support us you can do so by:
Founder -> Jakub Andrzejewski
This project wouldn't be possible without amazing work of Kamil Myśliwiec and the Nest.js Core Team. Keep doing the awesome work!
Distributed under the MIT licensed. See LICENSE
for more information.