• Stars
    star
    249
  • Rank 162,987 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“– Nest.js based microservice repository template

Otasoft Logo

Otasoft Microservice Template - Template for creating Nest.js microservices

Report Bug Β· Request Feature

CI

About The Project

Otasoft Microservice template - Nest.js based microservice repository template. This project consists of:

  • PostgreSQL Typeorm
  • CQRS
  • Domain Driven Design
  • Event Sourcing
  • Healthchecks
  • .env support
  • RabbitMQ Event Bus Connection
  • Dockerfile and docker-compose
  • doc directory
  • Github workflows and issue templates

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.

Table of Contents

Getting Started

To start developing the project please check if you have these tools installed on your machine:

Installation

  1. Clone the repo
git clone https://github.com/otasoft/microservice-template
  1. Move into microservice-template
cd microservice-template
  1. Install project dependencies
yarn
  1. Copy .env.example file as .env and fill it with your environment variables
cp .env.example .env
  1. Run docker-compose to start development environment
docker-compose up
  1. Run project
yarn start:dev

Testing as a normal web server instead of microservice

  1. Replace bootstrap logic inside 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');
  });
  1. To basic web HTTP server
  const app = await NestFactory.create(AppModule);
  await app.listen(3000);
  1. Replace message pattern in controller
  @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);
  }
  1. To HTTP methods (with Decorators like @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);
  }
  1. Test locally with Postman and TablePlus

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

You are welcome to contribute to Otasoft projects. Please see contribution tips

How to support

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:

  • 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!
  • evangelizing - share a good news about Otasoft projects in social media or during technology conferences ;)

Contact

Founder -> Jakub Andrzejewski

Special Thanks

This project wouldn't be possible without amazing work of Kamil MyΕ›liwiec and the Nest.js Core Team. Keep doing the awesome work!

License

Distributed under the MIT licensed. See LICENSE for more information.

More Repositories

1

nuxt-security

πŸ›‘ Automatically configure your app to follow OWASP security patterns and principles by using HTTP Headers and Middleware
TypeScript
785
star
2

nuxt-medusa

πŸ›οΈ Medusa module for Nuxt
TypeScript
128
star
3

nuxt-lazy-hydrate

πŸ’¦ Lazy Hydration Module for Nuxt
TypeScript
89
star
4

nuxt-newsletter

βœ‰οΈ Nuxt module for first class integration with popular newsletter providers
TypeScript
57
star
5

nuxt-shopify-tailwind

Headless Commerce website with Nuxt 3, Shopify, and Tailwindcss
Vue
57
star
6

cache

πŸ”‹ Browser and Server Cache module for Nuxt 3
TypeScript
35
star
7

compression

πŸ—œ Compression module for Nuxt 3
TypeScript
32
star
8

lazy-load

πŸŒ… Lazy Loading module for Nuxt 3
TypeScript
29
star
9

next-security

πŸ›‘ Security plugin for Next.js based on OWASP and Helmet
TypeScript
25
star
10

nuxt3-structure-modules-pinia

Using Modules and Pinia to structure Nuxt 3 app
TypeScript
23
star
11

nuxt-shopify-storyblok

Composable Commerce with Nuxt, Shopify, and Storyblok
Vue
23
star
12

nuxt-histoire

Histoire module for Nuxt 3
TypeScript
12
star
13

nuxt-backend

Example Nuxt Backend Microservice
TypeScript
10
star
14

map

πŸ—Ί Map Module for Nuxt 3
Vue
10
star
15

nest-microservice

TypeScript
10
star
16

nest-demo

TypeScript
9
star
17

nuxt-module-template

TypeScript
8
star
18

nuxt3-algolia

Nuxt 3 with Algolia search boilerplate project
Vue
7
star
19

nuxt-helm

Security Headers Module for Nuxt 3
TypeScript
6
star
20

nuxt3-tailwind-supabase

Cat Image Gallery built with Nuxt 3, TailwindCSS and Supabase, deployed to Vercel
Vue
6
star
21

nuxt3-algolia-storyblok

Nuxt 3 starter with Algolia, Storyblok, and Indexer
TypeScript
5
star
22

nuxt-a11y

πŸ‘€ Accessibility (A11Y) Module for Nuxt
TypeScript
5
star
23

nuxt-apollo-tailwind

Repository for Nuxt 3, Apollo, and Tailwind Crash Course
Vue
4
star
24

nuxt-partytown

Demo of improving Performance in Nuxt with Partytown and Plausible
TypeScript
4
star
25

nuxt-lighthouse-ci

Demo repository of Nuxt.js project with Lighthouse CI Github workflows
Vue
3
star
26

nuxt-tailwind-medusa

Demo application for the article about Nuxt, Medusa, and Tailwind
Vue
3
star
27

jamstack-nuxt-storyblok

Example Jamstack app with Nuxt 3, Content, and Storyblok deployed to Vercel
Vue
2
star
28

nuxt3-algolia-stackblitz

A demo of Nuxt 3 with Algolia and deployed to Stackblitz
Vue
1
star
29

nuxt-medusa-tailwind

Simple Headless Commerce with Nuxt, Medusa, and TailwindCSS
Vue
1
star
30

dxp-nuxt3-storyblok-algolia-tailwindcss

Digital Experience Platform with Nuxt 3, Storyblok, Algolia, and TailwindCSS
Vue
1
star
31

test-shopify-storyblok

Vue
1
star
32

nuxt-commerce-theme

Vue
1
star
33

vsf2-custom-integration-example

Example of Custom Integration for VSF 2
TypeScript
1
star
34

headless-avuengers

Demo of Nuxt 3 app powered by Headless CMS and Search Engine
Vue
1
star
35

nuxt-storyblok-shopify

Vue
1
star
36

nuxt-image-gallery

Vue
1
star
37

nuxt-storyblok-algolia-tailwindcss

Simple Digital Experience Platform (DXP) with Nuxt 3, Algolia, Storyblok, and TailwindCSS deployed to Vercel
Vue
1
star