Berikan fitur, saat berjalan dibrowser, "install app"
Siapkan file production mau saya upload digithub
Time zone supabase
alter database postgres set timezone to 'Asia/Jakarta';
Keep Alive✨
-- pastikan tabel ada
create table if not exists public.keepalive (
id bigint generated by default as identity primary key,
ping_at timestamptz default now() not null,
project_name text,
status text default 'ok'
);
-- kasih akses ke role service_role
grant usage on schema public to service_role;
grant all on table public.keepalive to service_role;
grant all on sequence keepalive_id_seq to service_role;
-- aktifkan Row Level Security (RLS)
alter table public.keepalive enable row level security;
-- policy untuk insert (dengan check true = semua row boleh diinsert)
create policy "allow_insert_keepalive"
on public.keepalive
for insert
with check (true);
📝 Catatan:
service_role sebenarnya bypass semua RLS policy, jadi policy ini lebih relevan kalau kamu nanti pakai anon atau authenticated key.klik di sini
function insertKeepalive() {
var url = "<https://jqpgvnbnbvlxaywvzabc.supabase.co/rest/v1/keepalive>";
// ⚠️ service_role key ini full akses → jangan taruh di client publik
var apiKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpxcGd2bmJuYnZseGF5d3Z6YWJjIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc1NzgzNzc4MSwiZXhwIjoyMDczNDEzNzgxfQ.itaj5jCdQha682pSg2km02Kgx5UoLzSie6OmANMv_K8";
var payload = {
project_name: "izinpulang", // kolom text
status: "ok" // opsional, default 'ok'
};
var options = {
method: "post",
headers: {
"apikey": apiKey,
"Authorization": "Bearer " + apiKey,
"Content-Type": "application/json",
"Prefer": "return=representation" // balikin row yang baru diinsert
},
payload: JSON.stringify(payload),
muteHttpExceptions: true
};
var response = UrlFetchApp.fetch(url, options);
Logger.log("Status: " + response.getResponseCode());
Logger.log("Body: " + response.getContentText());
}
✅ Jadi flow-nya:
UrlFetchApp.fetch dengan POST → insert row baru ke keepalive.SELECT * FROM keepalive.