{"id":16261145,"url":"https://github.com/baroshem/microservice-template","last_synced_at":"2025-04-12T18:53:44.987Z","repository":{"id":37928771,"uuid":"328990256","full_name":"Baroshem/microservice-template","owner":"Baroshem","description":"📖 Nest.js based microservice repository template","archived":false,"fork":false,"pushed_at":"2024-10-21T05:58:20.000Z","size":3286,"stargazers_count":266,"open_issues_count":105,"forks_count":36,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-21T08:45:32.187Z","etag":null,"topics":["cqrs","docker","domain-driven-design","env","event-sourcing","microservices","nestjs","postgresql","rabbitmq","typeorm"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Baroshem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-12T13:09:02.000Z","updated_at":"2024-10-15T09:02:29.000Z","dependencies_parsed_at":"2023-02-13T17:46:19.474Z","dependency_job_id":"b24808b9-2dbd-4ab0-8b4f-92b031527deb","html_url":"https://github.com/Baroshem/microservice-template","commit_stats":null,"previous_names":["baroshem/microservice-template"],"tags_count":1,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baroshem%2Fmicroservice-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baroshem%2Fmicroservice-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baroshem%2Fmicroservice-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baroshem%2Fmicroservice-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Baroshem","download_url":"https://codeload.github.com/Baroshem/microservice-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618262,"owners_count":21134200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cqrs","docker","domain-driven-design","env","event-sourcing","microservices","nestjs","postgresql","rabbitmq","typeorm"],"created_at":"2024-10-10T16:40:37.017Z","updated_at":"2025-04-12T18:53:44.967Z","avatar_url":"https://github.com/Baroshem.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/otasoft/microservice-template\"\u003e\n    \u003cimg src=\"doc/microservice-template-logo.png\" alt=\"Otasoft Logo\" width=\"128\" height=\"128\"\u003e\n  \u003c/a\u003e\n\n  \u003ch1 align=\"center\"\u003eOtasoft Microservice Template - Template for creating Nest.js microservices\u003c/h1\u003e\n\n  \u003cp align=\"center\"\u003e\n    \u003c!-- \u003ca href=\"https://github.com/otasoft/microservice-template\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e --\u003e\n    \u003c!-- \u003ca href=\"https://github.com/otasoft/microservice-template\"\u003eView Demo\u003c/a\u003e --\u003e\n    \u003c!-- · --\u003e\n    \u003ca href=\"https://github.com/otasoft/microservice-template/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/otasoft/microservice-template/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/otasoft/microservice-template/actions\"\u003e\u003cimg src=\"https://github.com/otasoft/microservice-template/workflows/Node.js%20CI/badge.svg?branch=master\" alt=\"CI\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# About The Project\n\nOtasoft Microservice template - [Nest.js](https://nestjs.com) based microservice repository template. This project consists of:\n\n* PostgreSQL Typeorm\n* CQRS\n* Domain Driven Design\n* Event Sourcing\n* Healthchecks\n* .env support\n* RabbitMQ Event Bus Connection\n* Dockerfile and docker-compose\n* doc directory\n* Github workflows and issue templates\n\nOtasoft 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.\n\n## Table of Contents\n\n* [Getting Started](#getting-started)\n* [Roadmap](#roadmap)\n* [Contributing](#contributing)\n* [How to support](#how-to-support)\n* [Contact](#contact)\n* [Special Thanks](#special-thanks)\n* [License](#license)\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\nTo start developing the project please check if you have these tools installed on your machine:\n\n* [Node.js](https://nodejs.org/en/download/)\n* [Yarn](https://yarnpkg.com/getting-started/install)\n* [Docker](https://www.docker.com/get-started)\n\n### Installation\n\n1. Clone the repo\n\n```sh\ngit clone https://github.com/otasoft/microservice-template\n```\n\n2. Move into microservice-template\n\n```sh\ncd microservice-template\n```\n\n3. Install project dependencies\n\n```sh\nyarn\n```\n\n4. Copy .env.example file as .env and fill it with your environment variables\n\n```sh\ncp .env.example .env\n```\n\n5. Run docker-compose to start development environment\n\n```sh\ndocker-compose up\n```\n\n6. Run project\n\n```sh\nyarn start:dev\n```\n\n### Testing as a normal web server instead of microservice\n\n1. Replace bootstrap logic inside `main.ts` from microservice\n\n```typescript\n  const app = await NestFactory.createMicroservice(AppModule, {\n    transport: Transport.RMQ,\n    options: {\n      urls: [\n        `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}`,\n      ],\n      queue: 'microservice_queue',\n      queueOptions: {\n        durable: false,\n      },\n    },\n  });\n\n  await app.listen(() =\u003e {\n    logger.log('Microservice is listening');\n  });\n```\n\n2. To basic web HTTP server\n\n```typescript\n  const app = await NestFactory.create(AppModule);\n  await app.listen(3000);\n```\n\n3. Replace message pattern in controller\n\n```typescript\n  @MessagePattern({ role: 'item', cmd: 'get-by-id' })\n  async getItemById(id: number): Promise\u003cItemEntity\u003e {\n    return this.itemService.getItemById(id);\n  }\n\n  @MessagePattern({ role: 'item', cmd: 'create' })\n  async createItem(createItemDto: CreateItemDto): Promise\u003cItemEntity\u003e {\n    return this.itemService.createItem(createItemDto);\n  }\n```\n\n4. To HTTP methods (with Decorators like `@Body()`, `@Param()`)\n\n```typescript\n  @Get('/get-by-id/:id')\n  async getItemById(@Param('id') id: number): Promise\u003cItemEntity\u003e {\n    return this.itemService.getItemById(id);\n  }\n\n  @Post('/create')\n  async createItem(@Body() createItemDto: CreateItemDto): Promise\u003cItemEntity\u003e {\n    return this.itemService.createItem(createItemDto);\n  }\n```\n\n5. Test locally with [Postman](https://www.postman.com/) and [TablePlus](https://tableplus.com/)\n\n\u003c!-- ROADMAP --\u003e\n## Roadmap\n\nSee the [open issues](https://github.com/otasoft/microservice-template/issues) for a list of proposed features (and known issues).\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nYou are welcome to contribute to Otasoft projects. Please see [contribution tips](CONTRIBUTING.md)\n\n\u003c!-- SUPPORT --\u003e\n## How to support\n\nOtasoft projects are and always will be Open Source.\n\nCore 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:\n\n* contributing - it does not matter whether it is writing code, creating designs, or sharing knowledge in our e-books and pdfs. Any help is always welcome!\n* evangelizing - share a good news about Otasoft projects in social media or during technology conferences ;)\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nFounder -\u003e [Jakub Andrzejewski](https://www.linkedin.com/in/jakub-andrzejewski/)\n\n\u003c!-- THANKS --\u003e\n## Special Thanks\n\nThis project wouldn't be possible without amazing work of [Kamil Myśliwiec](https://github.com/kamilmysliwiec) and the [Nest.js Core Team](https://github.com/orgs/nestjs/people). Keep doing the awesome work!\n\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the [MIT licensed](LICENSE). See `LICENSE` for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaroshem%2Fmicroservice-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaroshem%2Fmicroservice-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaroshem%2Fmicroservice-template/lists"}