-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3234386
commit 2641e9d
Showing
3 changed files
with
26 additions
and
19 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
.github/workflows/supabase-activity.yml → .github/workflows/activity.yml
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,12 +1,12 @@ | ||
name: Supabase Activity | ||
on: | ||
schedule: | ||
- cron: "0 0 * * 0,3" | ||
- cron: "0 9 * * 1,4" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
send-http-request: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Send HTTP Request | ||
run: curl https://trophy-hunt.vercel.app/api/supabase-activity | ||
run: curl https://trophy-hunt.vercel.app/api/activity |
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,24 @@ | ||
import { createClient } from "@/utils/supabase/server"; | ||
import { cookies } from "next/headers"; | ||
|
||
interface Data { | ||
id: number; | ||
value: string; | ||
} | ||
|
||
const table = "keep-alive"; | ||
|
||
export const GET = async (): Promise<Response> => { | ||
try { | ||
const sb = createClient(cookies()); | ||
const { data, error } = await sb.from(table).select("id").single<Data>(); | ||
if (error !== null) throw new Error(error.message); | ||
const payload = { value: new Date().toISOString() }; | ||
const remove = await sb.from(table).update(payload).eq("id", data.id); | ||
if (remove.error !== null) throw new Error(remove.error.message); | ||
return Response.json(`Success! ${payload.value}`); | ||
} catch (error) { | ||
const message = (error as Error).message ?? "An error occurred."; | ||
return Response.json(message, { status: 400 }); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.