File tree Expand file tree Collapse file tree
clients/trieve-shopify-extension/app/routes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,16 +7,28 @@ import { authenticate } from "app/shopify.server";
77export const action = async ( { request } : ActionFunctionArgs ) => {
88 await authenticate . webhook ( request ) ;
99
10- const json = await request . json ( ) ;
10+ let json ;
11+ try {
12+ json = await request . json ( ) ;
13+ } catch ( error ) {
14+ console . error ( error ) ;
15+ return new Response ( ) ;
16+ }
1117
1218 const shop = json . shop_domain ;
1319 if ( ! shop ) {
1420 return new Response ( ) ;
1521 }
1622
17- const apiKey = await db . apiKey . findFirst ( {
18- where : { shop : json . shop_domain } ,
19- } ) ;
23+ let apiKey ;
24+ try {
25+ apiKey = await db . apiKey . findFirst ( {
26+ where : { shop : json . shop_domain } ,
27+ } ) ;
28+ } catch ( error ) {
29+ console . error ( error ) ;
30+ return new Response ( ) ;
31+ }
2032
2133 if ( ! apiKey ) {
2234 console . error ( `No API key found for ${ shop } ` ) ;
@@ -34,9 +46,14 @@ export const action = async ({ request }: ActionFunctionArgs) => {
3446
3547 trieve . deleteDataset ( trieveKey . currentDatasetId ?? "" ) ;
3648
37- await db . apiKey . delete ( {
38- where : { id : trieveKey . id } ,
39- } ) ;
49+ try {
50+ await db . apiKey . delete ( {
51+ where : { id : trieveKey . id } ,
52+ } ) ;
53+ } catch ( error ) {
54+ console . error ( error ) ;
55+ return new Response ( ) ;
56+ }
4057
4158 return new Response ( ) ;
4259}
You can’t perform that action at this time.
0 commit comments