Skip to content

Commit

Permalink
overload adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
jrCleber committed Oct 24, 2024
1 parent d876891 commit eb6c42d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 39 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"@types/jsonwebtoken": "^9.0.5",
"@types/mime-types": "^2.1.4",
"@types/multer": "^1.4.12",
"@types/node": "^22.7.9",
"@types/qrcode": "^1.5.5",
"@types/qrcode-terminal": "^0.12.2",
"@types/swagger-ui-express": "^4.1.6",
Expand Down
32 changes: 16 additions & 16 deletions src/whatsapp/routers/chat.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.whatsappNumber(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.put(routerPath('markMessageAsRead'), ...guards, async (req, res) => {
const response = await dataValidate<ReadMessageDto>({
Expand All @@ -84,7 +84,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.readMessage(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.patch(routerPath('readMessages'), ...guards, async (req, res) => {
const response = await dataValidate<ReadMessageIdDto>({
Expand All @@ -93,7 +93,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.readMessagesForId(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.patch(routerPath('updatePresence'), ...guards, async (req, res) => {
const response = await dataValidate<UpdatePresenceDto>({
Expand All @@ -102,7 +102,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.updatePresence(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.put(routerPath('archiveChat'), ...guards, async (req, res) => {
const response = await dataValidate<ArchiveChatDto>({
Expand All @@ -111,7 +111,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.archiveChat(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.delete(routerPath('deleteMessageForEveryone'), ...guards, async (req, res) => {
const response = await dataValidate<DeleteMessage>({
Expand All @@ -120,7 +120,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.deleteMessage(instance, data),
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
})
.delete(routerPath('deleteMessage'), ...guards, async (req, res) => {
const response = await dataValidate<DeleteMessage>({
Expand All @@ -129,17 +129,17 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.deleteMessage(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.delete(routerPath('deleteChat'), ...guards, async (req, res) => {
const instance = req.params as unknown as InstanceDto;
const query = req.query as Record<string, string>;
if (!query?.chatId) {
return res.status(HttpStatus.BAD_REQUEST).json({ message: 'chatId is required' });
res.status(HttpStatus.BAD_REQUEST).json({ message: 'chatId is required' });
}
const response = await chatController.deleteChat(instance, query?.chatId);

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.post(routerPath('fetchProfilePictureUrl'), ...guards, async (req, res) => {
const response = await dataValidate<NumberDto>({
Expand All @@ -148,7 +148,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.fetchProfilePicture(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.get(routerPath('fetchProfilePictureUrl'), ...guards, async (req, res) => {
const response = await dataValidate<NumberDto>({
Expand All @@ -157,7 +157,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.fetchProfilePicture(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.post(routerPath('findContacts'), ...guards, async (req, res) => {
const response = await dataValidate<Query<Contact>>({
Expand All @@ -166,7 +166,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.fetchContacts(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
// @deprecated
.post(routerPath('retrieverMediaMessage'), ...guards, async (req, res) => {
Expand Down Expand Up @@ -251,7 +251,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.fetchMessages(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.get(routerPath('findChats'), ...guards, async (req, res) => {
const response = await dataValidate<InstanceDto>({
Expand All @@ -261,7 +261,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
chatController.fetchChats(instance, req.query?.type as string),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.post(routerPath('rejectCall'), ...guards, async (req, res) => {
const response = await dataValidate<RejectCallDto>({
Expand All @@ -270,7 +270,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.rejectCall(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.post(routerPath('assertSessions'), ...guards, async (req, res) => {
const response = await dataValidate<WhatsAppNumberDto>({
Expand All @@ -279,7 +279,7 @@ export function ChatRouter(chatController: ChatController, ...guards: RequestHan
execute: (instance, data) => chatController.assertSessions(instance, data),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
});

return router;
Expand Down
20 changes: 10 additions & 10 deletions src/whatsapp/routers/instance.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function InstanceRouter(
execute: (instance) => instanceController.createInstance(instance, req),
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
})
.get(routerPath('connect'), ...guards, async (req, res) => {
const response = await dataValidate<InstanceDto>({
Expand All @@ -63,7 +63,7 @@ export function InstanceRouter(
execute: (instance) => instanceController.connectToWhatsapp(instance),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.get(routerPath('connectionState'), ...guards, async (req, res) => {
const response = await dataValidate<InstanceDto>({
Expand All @@ -72,7 +72,7 @@ export function InstanceRouter(
execute: (instance) => instanceController.connectionState(instance),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.get(routerPath('fetchInstance'), ...guards, async (req, res) => {
const response = await dataValidate<InstanceDto>({
Expand All @@ -81,7 +81,7 @@ export function InstanceRouter(
execute: (instance) => instanceController.fetchInstance(instance),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.get(routerPath('fetchInstances', false), ...guards, async (req, res) => {
const response = await dataValidate<InstanceDto>({
Expand All @@ -90,7 +90,7 @@ export function InstanceRouter(
execute: (instance) => instanceController.fetchInstances(instance),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.patch(routerPath('reload'), ...guards, async (req, res) => {
const response = await dataValidate<InstanceDto>({
Expand All @@ -99,7 +99,7 @@ export function InstanceRouter(
execute: (instance) => instanceController.reloadConnection(instance),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.patch(routerPath('update'), ...guards, async (req, res) => {
const response = await dataValidate<InstanceDto>({
Expand All @@ -108,7 +108,7 @@ export function InstanceRouter(
execute: (instance) => instanceController.updateInstance(instance),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.delete(routerPath('logout'), ...guards, async (req, res) => {
const response = await dataValidate<InstanceDto>({
Expand All @@ -117,7 +117,7 @@ export function InstanceRouter(
execute: (instance) => instanceController.logout(instance),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.delete(routerPath('delete'), ...guards, async (req, res) => {
const response = await dataValidate<InstanceDto>({
Expand All @@ -127,7 +127,7 @@ export function InstanceRouter(
instanceController.deleteInstance(instance, req?.query?.force === 'true'),
});

return res.status(HttpStatus.OK).json(response);
res.status(HttpStatus.OK).json(response);
})
.put(routerPath('refreshToken'), async (req, res) => {
const response = await dataValidate<OldToken>({
Expand All @@ -136,7 +136,7 @@ export function InstanceRouter(
execute: (instance, data) => instanceController.refreshToken(instance, data, req),
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
});

return router;
Expand Down
24 changes: 12 additions & 12 deletions src/whatsapp/routers/sendMessage.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function MessageRouter(
execute: (instance, data) => sendMessageController.sendText(instance, data),
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
})
.post(routerPath('sendMedia'), ...guards, async (req, res) => {
const response = await dataValidate<SendMediaDto>({
Expand All @@ -105,7 +105,7 @@ export function MessageRouter(
execute: (instance, data) => sendMessageController.sendMedia(instance, data),
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
})
.post(
routerPath('sendMediaFile'),
Expand All @@ -119,7 +119,7 @@ export function MessageRouter(
execute: (instance, data, file) =>
sendMessageController.sendMediaFile(instance, data, file),
});
return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
},
)
.post(routerPath('sendWhatsAppAudio'), ...guards, async (req, res) => {
Expand All @@ -130,7 +130,7 @@ export function MessageRouter(
sendMessageController.sendWhatsAppAudio(instance, data),
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
})
.post(
routerPath('sendWhatsAppAudioFile'),
Expand All @@ -144,7 +144,7 @@ export function MessageRouter(
execute: (instance, data, file) =>
sendMessageController.sendWhatsAppAudioFile(instance, data, file),
});
return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
},
)
.post(routerPath('sendLocation'), ...guards, async (req, res) => {
Expand All @@ -154,7 +154,7 @@ export function MessageRouter(
execute: (instance, data) => sendMessageController.sendLocation(instance, data),
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
})
.post(routerPath('sendContact'), ...guards, async (req, res) => {
const response = await dataValidate<SendContactDto>({
Expand All @@ -163,7 +163,7 @@ export function MessageRouter(
execute: (instance, data) => sendMessageController.sendContact(instance, data),
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
})
.post(routerPath('sendReaction'), ...guards, async (req, res) => {
const response = await dataValidate<SendReactionDto>({
Expand All @@ -172,7 +172,7 @@ export function MessageRouter(
execute: (instance, data) => sendMessageController.sendReaction(instance, data),
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
})
.post(routerPath('sendButtons'), ...guards, async (req, res) => {
const response = await dataValidate<SendButtonsDto>({
Expand All @@ -194,7 +194,7 @@ export function MessageRouter(
},
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
})
.post(routerPath('sendList'), ...guards, async (req, res) => {
const response = await dataValidate<SendListDto>({
Expand All @@ -209,7 +209,7 @@ export function MessageRouter(
},
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
})
.post(routerPath('sendList/legacy'), ...guards, async (req, res) => {
const response = await dataValidate<SendListLegacyDto>({
Expand All @@ -227,7 +227,7 @@ export function MessageRouter(
},
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
})
.post(routerPath('sendLink'), ...guards, async (req, res) => {
const response = await dataValidate<SendLinkDto>({
Expand All @@ -237,7 +237,7 @@ export function MessageRouter(
sendMessageController.sendLinkPreview(instance, data),
});

return res.status(HttpStatus.CREATED).json(response);
res.status(HttpStatus.CREATED).json(response);
});

return router;
Expand Down

0 comments on commit eb6c42d

Please sign in to comment.