@@ -3,16 +3,16 @@ import { plainClient } from "@/lib/plainClient";
33import { inspect } from "util" ;
44
55export type RequestBody = {
6- title : string ;
7- message : string ;
8- }
6+ title : string ;
7+ message : string ;
8+ } ;
99
1010// When implementing this for real, take these values from user auth (e.g validate auth token and take values from claims)
1111const name = "Bob Smith" ;
1212const email = "bob.smith@example.com" ;
1313
1414export async function POST ( request : Request ) {
15- // In production validation of the request body might be necessary.
15+ // In production validation of the request body might be necessary.
1616 const body = await request . json ( ) ;
1717
1818 const upsertCustomerRes = await plainClient . upsertCustomer ( {
@@ -25,16 +25,20 @@ export async function POST(request: Request) {
2525 email : email ,
2626 isVerified : true ,
2727 } ,
28- tenantIdentifiers : [ { externalId : TENANT_EXTERNAL_ID } ]
28+ tenantIdentifiers : [ { externalId : TENANT_EXTERNAL_ID } ] ,
2929 } ,
3030 onUpdate : { } ,
3131 } ) ;
3232
3333 if ( upsertCustomerRes . error ) {
3434 console . error (
35- inspect ( upsertCustomerRes . error , { showHidden : false , depth : null , colors : true } )
35+ inspect ( upsertCustomerRes . error , {
36+ showHidden : false ,
37+ depth : null ,
38+ colors : true ,
39+ } )
3640 ) ;
37- return new Response ( upsertCustomerRes . error . message , { status : 500 } ) ;
41+ return new Response ( upsertCustomerRes . error . message , { status : 500 } ) ;
3842 }
3943
4044 console . log ( `Customer upserted ${ upsertCustomerRes . data . customer . id } ` ) ;
@@ -44,7 +48,7 @@ export async function POST(request: Request) {
4448 customerId : upsertCustomerRes . data . customer . id ,
4549 } ,
4650 title : body . title ,
47- tenantIdentifier : { externalId : TENANT_EXTERNAL_ID } ,
51+ tenantIdentifier : { externalId : TENANT_EXTERNAL_ID } ,
4852 components : [
4953 {
5054 componentText : {
@@ -55,13 +59,16 @@ export async function POST(request: Request) {
5559 } ) ;
5660
5761 if ( createThreadRes . error ) {
58- console . error ( inspect ( createThreadRes . error , { showHidden : false , depth : null , colors : true } ) ) ;
59- return new Response ( createThreadRes . error . message , { status : 500 } ) ;
62+ console . error (
63+ inspect ( createThreadRes . error , {
64+ showHidden : false ,
65+ depth : null ,
66+ colors : true ,
67+ } )
68+ ) ;
69+ return new Response ( createThreadRes . error . message , { status : 500 } ) ;
6070 }
6171
6272 console . log ( `Thread created ${ createThreadRes . data . id } .` ) ;
63-
64-
65-
66- return new Response ( '' , { status : 200 } )
67- }
73+ return new Response ( "" , { status : 200 } ) ;
74+ }
0 commit comments