File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
app/api/internal/shared-sync/[board_name] Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 11// app/api/cron/sync-shared-data/route.ts
22import { NextResponse } from 'next/server' ;
33import { syncSharedData } from '@/lib/data-sync/aurora/shared-sync' ;
4+ import { BoardRouteParameters , ParsedBoardRouteParameters } from '@/app/lib/types' ;
5+ import { parseBoardRouteParams } from '@/app/lib/url-utils' ;
46
57export const dynamic = 'force-dynamic' ;
68export const maxDuration = 300 ;
79// This is a simple way to secure the endpoint, should be replaced with a better solution
810const CRON_SECRET = process . env . CRON_SECRET ;
911
10- export async function GET ( request : Request ) {
12+ export async function GET ( request : Request , { params } : { params : BoardRouteParameters } ) {
13+ const { board_name } : ParsedBoardRouteParameters = parseBoardRouteParams ( params ) ;
14+
1115 try {
1216 // Basic auth check
1317 const authHeader = request . headers . get ( 'authorization' ) ;
1418 if ( process . env . VERCEL_ENV !== 'development' && authHeader !== `Bearer ${ CRON_SECRET } ` ) {
1519 return NextResponse . json ( { error : 'Unauthorized' } , { status : 401 } ) ;
1620 }
1721
18- // Sync both board types
19- const results = await Promise . all ( [
20- syncSharedData ( 'tension' ) ,
21- syncSharedData ( 'kilter' )
22- ] ) ;
22+ const result = syncSharedData ( board_name ) ;
2323
2424 return NextResponse . json ( {
2525 success : true ,
26- results : {
27- tension : results [ 0 ] ,
28- kilter : results [ 1 ] ,
29- } ,
26+ results : result ,
3027 } ) ;
3128 } catch ( error ) {
3229 console . error ( 'Cron job failed:' , error ) ;
Original file line number Diff line number Diff line change 22 "installCommand" : " npm install --legacy-peer-deps" ,
33 "crons" : [
44 {
5- "path" : " /api/internal/shared-sync" ,
5+ "path" : " /api/internal/shared-sync/tension " ,
66 "schedule" : " 0 */2 * * *"
7+ },
8+ {
9+ "path" : " /api/internal/shared-sync/kilter" ,
10+ "schedule" : " 15 */2 * * *"
711 }
812 ]
913}
You can’t perform that action at this time.
0 commit comments