Skip to content

Commit

Permalink
feat: ✨ Adição da rota cron e do vercel.json
Browse files Browse the repository at this point in the history
  • Loading branch information
welllucky committed Nov 20, 2023
1 parent c7740d8 commit e10e928
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "fc-services",
"version": "0.2.0",
"name": "services",
"version": "0.1.0",
"private": true,
"repository": "https://github.com/welllucky/FC-Services.git",
"repository": "https://github.com/welllucky/services.git",
"author": "Wellington Braga <[email protected]>",
"license": "MIT",
"license": "LGPL-3.0-only",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down
19 changes: 19 additions & 0 deletions src/app/api/cron/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { NextRequest, NextResponse } from "next/server";

export async function GET(request: NextRequest) {
const authHeader = request.headers.get("authorization");
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
return NextResponse.json("Unauthorized", {
status: 401,
});
}

return (
NextResponse.json({ success: true }),
{
headers: {
"Content-Type": "application/json",
},
}
);
}
6 changes: 6 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"crons": [{
"path": "/api/cron",
"schedule": "0 10 * * *"
}]
}

0 comments on commit e10e928

Please sign in to comment.