A
A
Andrey Rudakov2022-01-14 14:19:39
RabbitMQ
Andrey Rudakov, 2022-01-14 14:19:39

How to make a Gateway (single gateway) RabbitMQ for microservices in NestJS?

Greetings.
Previously, I used bare NodeJS and connected microservices through a single gateway gateway using RabbitMQ.
Example:
Gateway:

const gateway = new Gateway({
    microservices: [
        'user'
    ],
    rabbit: {
        url: 'amqp://localhost:5672',
    }
})

// И ДЕЛЕГИРОВАЛ ЗАПРОСЫ В МИКРОСЕРВИС:
gateway.post(['/register', '/login'], async (req, res) => {
    await res.delegate('user')
})


The microservice itself:
const app = new MicroMQ({
    name: 'user',
    rabbit: {
        url: process.env.RABBIT_URL,
    },
});


Now I switched to NestJS and I can't figure out how to do the same.
There are examples and articles, but there is no way to redirect from the Gateway to the microservice.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question