Git Product home page Git Product logo

authen's Introduction


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.

authen's People

Contributors

jigkoh3 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.