@@ -14,6 +14,7 @@ import ky from "ky";
1414import z from "zod" ;
1515import { researchVendor } from "../scrape/research" ;
1616import { updatePolicies } from "./update-policies" ;
17+ import axios from "axios" ;
1718
1819export const onboardOrganization = task ( {
1920 id : "onboard-organization" ,
@@ -25,6 +26,31 @@ export const onboardOrganization = task({
2526 } ,
2627 data : { triggerJobId : null } ,
2728 } ) ;
29+
30+ try {
31+ logger . info (
32+ `Revalidating path ${ process . env . BETTER_AUTH_URL } /${ organizationId } ` ,
33+ ) ;
34+ const revalidateResponse = await axios . post (
35+ `${ process . env . BETTER_AUTH_URL } /api/revalidate/path` ,
36+ {
37+ path : `${ process . env . BETTER_AUTH_URL } /${ organizationId } ` ,
38+ secret : process . env . REVALIDATION_SECRET ,
39+ type : "layout" ,
40+ } ,
41+ ) ;
42+
43+ if ( ! revalidateResponse . data ?. revalidated ) {
44+ logger . error (
45+ `Failed to revalidate path: ${ revalidateResponse . statusText } ` ,
46+ ) ;
47+ logger . error ( revalidateResponse . data ) ;
48+ } else {
49+ logger . info ( "Revalidated path successfully" ) ;
50+ }
51+ } catch ( err ) {
52+ logger . error ( "Error revalidating path" , { err } ) ;
53+ }
2854 } ,
2955 run : async ( payload : {
3056 organizationId : string ;
@@ -243,27 +269,6 @@ export const onboardOrganization = task({
243269 data : { completed : true } ,
244270 } ) ;
245271
246- try {
247- const revalidateResponse = await ky . post (
248- `${ process . env . BETTER_AUTH_URL } /api/revalidate/path` ,
249- {
250- json : {
251- path : `/${ payload . organizationId } ` ,
252- secret : process . env . REVALIDATION_SECRET ,
253- } ,
254- } ,
255- ) ;
256-
257- if ( ! revalidateResponse . ok ) {
258- logger . error (
259- `Failed to revalidate path: ${ revalidateResponse . statusText } ` ,
260- ) ;
261- logger . error ( await revalidateResponse . json ( ) ) ;
262- }
263- } catch ( err ) {
264- logger . error ( "Error revalidating path" , { err } ) ;
265- }
266-
267272 logger . info ( `Created ${ extractRisks . object . risks . length } risks` ) ;
268273 logger . info ( `Created ${ extractVendors . object . vendors . length } vendors` ) ;
269274 } ,
0 commit comments