How to connect to a NestJS microservice running on AWS using ClientProxy?

Viewed 305

Given I have a NestJS Microservice (created with NestFactory.createMicroservice) deployed as Lambda + API Gateway in AWS by Serverless framework. How can I connect to it from my NestJS HTTP Api using the ClientProxy class?

I have succesfully connected to it using Websocket King so I know it works however I can't see a WSS Transport option for the NestJS Client Proxy.

I've tried using Transport.TCP to the API Gateway directly and I get a NOT FOUND exception, e.g:

ClientsModule.register([
  {
    name: dataApiClientToken,
    transport: Transport.TCP,
    options: {
      host: 'xxx.execute-api.eu-west-2.amazonaws.com/dev',
      port: 80
    }
  },
])

To give some context, My architectural plan was to have a microservice specifically for database operations (TypeORM etc) that was called by a NestJS HTTP API. I assumed it would work with ClientProxy? If this assumption is wrong, should I instead be using a Websocket Gateway?

0 Answers
Related