reformat with prettier with semicolons and tabs
This commit is contained in:
@ -1,40 +1,40 @@
|
||||
import { resolver } from "blitz"
|
||||
import { z } from "zod"
|
||||
import twilio from "twilio"
|
||||
import { resolver } from "blitz";
|
||||
import { z } from "zod";
|
||||
import twilio from "twilio";
|
||||
|
||||
import db from "../../../db"
|
||||
import getCurrentCustomer from "../../customers/queries/get-current-customer"
|
||||
import fetchMessagesQueue from "../../api/queue/fetch-messages"
|
||||
import fetchCallsQueue from "../../api/queue/fetch-calls"
|
||||
import setTwilioWebhooks from "../../api/queue/set-twilio-webhooks"
|
||||
import db from "../../../db";
|
||||
import getCurrentCustomer from "../../customers/queries/get-current-customer";
|
||||
import fetchMessagesQueue from "../../api/queue/fetch-messages";
|
||||
import fetchCallsQueue from "../../api/queue/fetch-calls";
|
||||
import setTwilioWebhooks from "../../api/queue/set-twilio-webhooks";
|
||||
|
||||
const Body = z.object({
|
||||
phoneNumberSid: z.string(),
|
||||
})
|
||||
});
|
||||
|
||||
export default resolver.pipe(
|
||||
resolver.zod(Body),
|
||||
resolver.authorize(),
|
||||
async ({ phoneNumberSid }, context) => {
|
||||
const customer = await getCurrentCustomer(null, context)
|
||||
const customerId = customer!.id
|
||||
const customer = await getCurrentCustomer(null, context);
|
||||
const customerId = customer!.id;
|
||||
const phoneNumbers = await twilio(
|
||||
customer!.accountSid!,
|
||||
customer!.authToken!
|
||||
).incomingPhoneNumbers.list()
|
||||
const phoneNumber = phoneNumbers.find((phoneNumber) => phoneNumber.sid === phoneNumberSid)!
|
||||
).incomingPhoneNumbers.list();
|
||||
const phoneNumber = phoneNumbers.find((phoneNumber) => phoneNumber.sid === phoneNumberSid)!;
|
||||
await db.phoneNumber.create({
|
||||
data: {
|
||||
customerId,
|
||||
phoneNumberSid,
|
||||
phoneNumber: phoneNumber.phoneNumber,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
await Promise.all([
|
||||
fetchMessagesQueue.enqueue({ customerId }, { id: `fetch-messages-${customerId}` }),
|
||||
fetchCallsQueue.enqueue({ customerId }, { id: `fetch-messages-${customerId}` }),
|
||||
setTwilioWebhooks.enqueue({ customerId }, { id: `set-twilio-webhooks-${customerId}` }),
|
||||
])
|
||||
]);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
@ -1,26 +1,26 @@
|
||||
import { resolver } from "blitz"
|
||||
import { z } from "zod"
|
||||
import { resolver } from "blitz";
|
||||
import { z } from "zod";
|
||||
|
||||
import db from "../../../db"
|
||||
import getCurrentCustomer from "../../customers/queries/get-current-customer"
|
||||
import db from "../../../db";
|
||||
import getCurrentCustomer from "../../customers/queries/get-current-customer";
|
||||
|
||||
const Body = z.object({
|
||||
twilioAccountSid: z.string(),
|
||||
twilioAuthToken: z.string(),
|
||||
})
|
||||
});
|
||||
|
||||
export default resolver.pipe(
|
||||
resolver.zod(Body),
|
||||
resolver.authorize(),
|
||||
async ({ twilioAccountSid, twilioAuthToken }, context) => {
|
||||
const customer = await getCurrentCustomer(null, context)
|
||||
const customerId = customer!.id
|
||||
const customer = await getCurrentCustomer(null, context);
|
||||
const customerId = customer!.id;
|
||||
await db.customer.update({
|
||||
where: { id: customerId },
|
||||
data: {
|
||||
accountSid: twilioAccountSid,
|
||||
authToken: twilioAuthToken,
|
||||
},
|
||||
})
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
|
Reference in New Issue
Block a user