mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 19:59:20 +00:00
changed ticket creation and list to typescript
This commit is contained in:
17
backend/src/helpers/GetDefaultWhatsapp.ts
Normal file
17
backend/src/helpers/GetDefaultWhatsapp.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import AppError from "../errors/AppError";
|
||||
import Whatsapp from "../models/Whatsapp";
|
||||
import FindWhatsAppService from "../services/WhatsappService/FindWhatsAppService";
|
||||
|
||||
const GetDefaultWhatsapp = async (): Promise<Whatsapp> => {
|
||||
const defaultWhatsapp = await FindWhatsAppService({
|
||||
where: { isDefault: true }
|
||||
});
|
||||
|
||||
if (!defaultWhatsapp) {
|
||||
throw new AppError("No default WhatsApp found. Check Connection page.");
|
||||
}
|
||||
|
||||
return defaultWhatsapp;
|
||||
};
|
||||
|
||||
export default GetDefaultWhatsapp;
|
||||
Reference in New Issue
Block a user