-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #741 from hackclub/signup-lottery-rebased
Signup lottery rebased
- Loading branch information
Showing
8 changed files
with
152 additions
and
19 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ron/every-minute/create-background-job.ts → src/app/api/cron/create-background-job.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const dynamic = 'force-dynamic' | ||
export const fetchCache = 'force-no-store' | ||
|
||
import createBackgroundJob from '../create-background-job' | ||
|
||
async function processDailyJobs() { | ||
console.log('Processing daily jobs') | ||
|
||
await createBackgroundJob('run_lottery', {}) | ||
} | ||
|
||
export async function GET() { | ||
await processDailyJobs() | ||
return Response.json({ success: true }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
import type { NextRequest } from 'next/server' | ||
import { processBackgroundJobs } from './process-background-jobs' | ||
import { processBackgroundJobs } from '../process-background-jobs' | ||
|
||
export async function GET(request: NextRequest) { | ||
const authHeader = request.headers.get('authorization') | ||
const isDev = process.env.NODE_ENV === 'development' | ||
if (!isDev && authHeader !== `Bearer ${process.env.CRON_SECRET}`) { | ||
return new Response('Unauthorized', { | ||
status: 401, | ||
}) | ||
} | ||
export const dynamic = 'force-dynamic' | ||
export const fetchCache = 'force-no-store' | ||
|
||
export async function GET() { | ||
await processBackgroundJobs() | ||
|
||
return Response.json({ success: true }) | ||
} | ||
|
||
export const maxDuration = 60 | ||
export const fetchCache = 'force-no-store' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters