Skip to content

Commit

Permalink
feat: update sync date even when no updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sebald committed Sep 12, 2023
1 parent ba4365c commit 6b7d912
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/api/sync/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@ export const GET = async (request: NextRequest) => {
const { searchParams } = new URL(request.url);

const token = searchParams.get('token');
const lastSync = await getLastSync();

if (token !== process.env.SYNC_TOKEN) {
return NextResponse.json(
{
name: 'Nope...',
message: 'ಠ_ಠ U no syncing!',
name: 'Sync!',
message: `Latest sync at ${lastSync}`,
},
{
status: 401,
status: 200,
}
);
}

const lastSync = await getLastSync();

// Find new tournaments
const tournaments = await getAllTournaments({
from: lastSync,
Expand All @@ -44,6 +43,7 @@ export const GET = async (request: NextRequest) => {
);

if (tournaments.length === 0) {
await setLastSync();
return NextResponse.json(
{
name: 'Sync Complete!',
Expand Down

1 comment on commit 6b7d912

@vercel
Copy link

@vercel vercel bot commented on 6b7d912 Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.