Skip to content

Instantly share code, notes, and snippets.

@z4nr34l
Last active May 28, 2024 08:18
Show Gist options
  • Save z4nr34l/07f900ed265708145445c50ffb3d56e2 to your computer and use it in GitHub Desktop.
Save z4nr34l/07f900ed265708145445c50ffb3d56e2 to your computer and use it in GitHub Desktop.
@rescale/cron example usage
import type { NextRequest, NextResponse } from 'next/server';
import { CronJob, type ErrorResponse } from '@rescale/cron';
// [...]
interface CombinedResponse {
updateSubscriptions: UpdateSubscriptionResponse[];
sendNewsletter: SendNewsletterResponse[];
}
export async function GET(
request: NextRequest,
): Promise<NextResponse<CombinedResponse | ErrorResponse>> {
return CronJob<CombinedResponse>(request as never, {
updateSubscriptions: await updateSubscriptions(),
sendNewsletter: await sendNewsletter(),
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment