Skip to content

Commit

Permalink
refact: correct typo
Browse files Browse the repository at this point in the history
  • Loading branch information
DIY0R committed Jul 18, 2024
1 parent 7b7fb2b commit 6b9235a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
14 changes: 8 additions & 6 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,24 @@ export const INITIALIZATION_STEP_DELAY = 400;
export const DEFAULT_TIMEOUT = 40000;
export const RECONNECTION_INTERVAL = 5000;
export const NON_ROUTE = 'non_route_one';

export const INDICATE_REPLY_QUEUE = 'Please indicate `replyToQueue`';
export const INDICATE_REPLY_QUEUE_GLOBAL =
'Please indicate `replyToQueue` in globalBroker';
export const TIMEOUT_ERROR = 'Response timeout error';
export const RECIVED_MESSAGE_ERROR = 'Received a message but with an error';
export const ERROR_RMQ_SERVICE = 'Rmq service error';
export const RECEIVED_MESSAGE_ERROR = 'Received a message but with an error';
export const ERROR_RMQ_SERVICE = 'RMQ service error';
export const NACKED = 'Negative acknowledgment';
export const RETURN_NOTHING = 'Route return noting';
export const INOF_NOT_FULL_OPTIONS =
export const RETURN_NOTHING = 'Route returned nothing';
export const INFO_NOT_FULL_OPTIONS =
'Queue will not be created if there is no bind';
export const ERROR_NO_ROUTE =
"Requested service doesn't have MessageRoute with this path";
"Requested service doesn't have a MessageRoute with this path";
export const EMPTY_MESSAGE = 'Received empty message content';
export const MESSAGE_NON = 'Send an existing message';
export const CLOSE_MESSAGE = 'Disconnected from RMQ. Trying to reconnect';
export const CONNECT_FAILED_MESSAGE = 'Failed to connect to RMQ';
export const WRONG_CREDENTIALS_MESSAGE = 'Wrong credentials for RMQ';
export const CONNECT_BLOCKED_MESSAGE = 'Connection blocked';
export const SUCCESSFULL_CONNECT = 'Successfully connected to RabbitMQ';
export const SUCCESSFUL_CONNECT = 'Successfully connected to RabbitMQ';
export const ROOT_MODULE_DECLARED = 'Root RmqNestjsModule already declared!';
8 changes: 4 additions & 4 deletions lib/rmq-connect.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
RECONNECTION_INTERVAL,
RMQ_APP_OPTIONS,
RMQ_CONNECT_OPTIONS,
SUCCESSFULL_CONNECT,
ROOT_MODULE_DECLARED,
SUCCESSFUL_CONNECT,
} from './constants';
import {
IRabbitMQConfig,
Expand Down Expand Up @@ -57,8 +58,7 @@ export class RmqNestjsConnectService implements OnModuleInit, OnModuleDestroy {
: new RQMColorLogger(this.globalOptions.appOptions?.logMessages);
}
async onModuleInit(): Promise<void> {
if (this.isInitialized)
throw Error('Root RmqNestjsModule root already declared!');
if (this.isInitialized) throw Error(ROOT_MODULE_DECLARED);
await this.setUpConnect(this.options);
await this.createChannels();

Expand Down Expand Up @@ -202,7 +202,7 @@ export class RmqNestjsConnectService implements OnModuleInit, OnModuleDestroy {
this.globalOptions.socketOptions,
);
this.isConnected = true;
this.logger.log(SUCCESSFULL_CONNECT);
this.logger.log(SUCCESSFUL_CONNECT);

this.connection.on(CLOSE_EVENT, (err) => {
this.isConnected = false;
Expand Down
8 changes: 4 additions & 4 deletions lib/rmq.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ import {
ERROR_NO_ROUTE,
INDICATE_REPLY_QUEUE,
INITIALIZATION_STEP_DELAY,
INOF_NOT_FULL_OPTIONS,
INFO_NOT_FULL_OPTIONS,
INTERCEPTORS,
MODULE_TOKEN,
NACKED,
NON_ROUTE,
RECIVED_MESSAGE_ERROR,
RECEIVED_MESSAGE_ERROR,
RETURN_NOTHING,
RMQ_APP_OPTIONS,
RMQ_BROKER_OPTIONS,
Expand Down Expand Up @@ -117,7 +117,7 @@ export class RmqService implements OnModuleInit, OnModuleDestroy {
this.logger.error('Received message with error header', {
correlationId,
});
return reject(new Error(RECIVED_MESSAGE_ERROR));
return reject(new Error(RECEIVED_MESSAGE_ERROR));
}
const content = msg.content;
if (content.toString()) {
Expand Down Expand Up @@ -301,7 +301,7 @@ export class RmqService implements OnModuleInit, OnModuleDestroy {
const { queue: queueName, consumOptions } = this.options.queue;
if (!this.options.queue || !this.rmqMessageTegs?.size)
return this.logger.warn(
INOF_NOT_FULL_OPTIONS,
INFO_NOT_FULL_OPTIONS,
this.options.exchange.exchange,
);
const queue = await this.rmqNestjsConnectService.assertQueue(
Expand Down

0 comments on commit 6b9235a

Please sign in to comment.