Skip to content

Commit

Permalink
refactor: remove unused error classes and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
weyoss committed Mar 30, 2024
1 parent 3bfb8f1 commit 15bd959
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 378 deletions.
2 changes: 0 additions & 2 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@

- [ConsumerError](classes/ConsumerError.md)
- [ConsumerGroupDeleteError](classes/ConsumerGroupDeleteError.md)
- [ConsumerGroupIdNotFoundError](classes/ConsumerGroupIdNotFoundError.md)
- [ConsumerGroupIdNotSupportedError](classes/ConsumerGroupIdNotSupportedError.md)
- [ConsumerGroupIdRequiredError](classes/ConsumerGroupIdRequiredError.md)
- [ConsumerInvalidGroupIdError](classes/ConsumerInvalidGroupIdError.md)
- [ConsumerMessageHandlerAlreadyExistsError](classes/ConsumerMessageHandlerAlreadyExistsError.md)
- [ExchangeError](classes/ExchangeError.md)
- [ExchangeFanOutError](classes/ExchangeFanOutError.md)
Expand Down
4 changes: 0 additions & 4 deletions docs/api/classes/ConsumerError.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@

↳↳ [`ConsumerGroupDeleteError`](ConsumerGroupDeleteError.md)

↳↳ [`ConsumerGroupIdNotFoundError`](ConsumerGroupIdNotFoundError.md)

↳↳ [`ConsumerGroupIdNotSupportedError`](ConsumerGroupIdNotSupportedError.md)

↳↳ [`ConsumerGroupIdRequiredError`](ConsumerGroupIdRequiredError.md)

↳↳ [`ConsumerInvalidGroupIdError`](ConsumerInvalidGroupIdError.md)

## Table of contents

### Constructors
Expand Down
153 changes: 0 additions & 153 deletions docs/api/classes/ConsumerGroupIdNotFoundError.md

This file was deleted.

153 changes: 0 additions & 153 deletions docs/api/classes/ConsumerInvalidGroupIdError.md

This file was deleted.

17 changes: 2 additions & 15 deletions src/lib/consumer-groups/_/_save-consumer-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,17 @@
import { ICallback, IEventBus, IRedisClient } from 'redis-smq-common';
import { TRedisSMQEvent } from '../../../common/index.js';
import { redisKeys } from '../../../common/redis-keys/redis-keys.js';
import { ConsumerInvalidGroupIdError } from '../../consumer/index.js';
import { IQueueParams } from '../../queue/index.js';

function validateGroupId(groupId: string): string | false {
const lowerCase = groupId.toLowerCase();
const filtered = lowerCase.replace(
/(?:[a-z][a-z0-9]?)+(?:[-_]?[a-z0-9])*/,
'',
);
if (filtered.length) {
return false;
}
return lowerCase;
}

export function _saveConsumerGroup(
redisClient: IRedisClient,
eventBus: IEventBus<TRedisSMQEvent>,
queue: IQueueParams,
groupId: string,
cb: ICallback<number>,
): void {
const gid = validateGroupId(groupId);
if (!gid) cb(new ConsumerInvalidGroupIdError());
const gid = redisKeys.validateRedisKey(groupId);
if (gid instanceof Error) cb(gid);
else {
const { keyQueueConsumerGroups } = redisKeys.getQueueKeys(queue, gid);
redisClient.sadd(keyQueueConsumerGroups, gid, (err, reply) => {
Expand Down
16 changes: 0 additions & 16 deletions src/lib/consumer/errors/consumer-group-id-not-found.error.ts

This file was deleted.

Loading

0 comments on commit 15bd959

Please sign in to comment.