ssut / nestjs-sqs

A project to make SQS easier to use within NestJS, with decorator-based handling and seamless NestJS-way integration.
MIT License
214 stars 53 forks source link

Cannot pull QUEUE NAME from ENV in my consumer service file. #57

Closed govind-amt closed 1 year ago

govind-amt commented 1 year ago

`import { Injectable } from '@nestjs/common'; import { SqsMessageHandler } from '@ssut/nestjs-sqs'; import * as AWS from 'aws-sdk'; import { ConfigService } from '@nestjs/config';

@Injectable() export class AwsQueueConsumerService { constructor( private configService: ConfigService ) {} @SqsMessageHandler(NEED_QUEUE_URL_FROM_ENV_HERE, false) async handleMessage(message: AWS.SQS.Message) { //Handle message here } }`

Can Someone please help me to resolve this issue? It's working fine when we hardcode the queue URL there. But its not possible to hardcode in a different environment.

luisfelipej commented 1 year ago

Make a constants file and import at the top dotenv. It's the only way that worked for me

require('dotenv').config();

export const NEED_QUEUE_URL_FROM_ENV_HERE = process.env. NEED_QUEUE_URL_FROM_ENV_HERE
coolusaHD commented 1 year ago

@ssut Can you please create a hint in the readme for that ? after loading it directly from a constant it worked