replace early returns with NotFoundError

test /api/webhook/incoming-message
This commit is contained in:
m5r
2021-08-02 21:43:27 +08:00
parent 827ed9f1c0
commit 2cf53533a3
11 changed files with 223 additions and 28 deletions

View File

@ -1,4 +1,4 @@
import { resolver } from "blitz";
import { NotFoundError, resolver } from "blitz";
import db from "db";
import getCurrentCustomer from "../../customers/queries/get-current-customer";
@ -6,7 +6,7 @@ import getCurrentCustomer from "../../customers/queries/get-current-customer";
export default resolver.pipe(resolver.authorize(), async (_ = null, context) => {
const customer = await getCurrentCustomer(null, context);
if (!customer) {
return;
throw new NotFoundError();
}
return db.phoneNumber.findFirst({