added backup to queue

This commit is contained in:
John Yeo
2025-02-20 14:55:02 +00:00
parent a3c5085909
commit e5b9c16dec
20 changed files with 688 additions and 392 deletions

View File

@@ -5,9 +5,43 @@ import { Router } from "express";
import { ApiKeyService } from "./ApiKeyService.js";
import { OrgService } from "../orgs/OrgService.js";
import { createKey } from "./api-keys/apiKeyUtils.js";
import { SupabaseClient } from "@supabase/supabase-js";
export const devRouter = Router();
export const handleCreateApiKey = async ({
sb,
env,
name,
orgId,
orgSlug,
}: {
sb: SupabaseClient;
env: AppEnv;
name: string;
orgId: string;
orgSlug: string;
}) => {
// 1. Create API key
let prefix = "am_sk_test";
if (env === AppEnv.Live) {
prefix = "am_sk_live";
}
const apiKey = await createKey({
sb,
env,
name,
orgId,
prefix,
meta: {
org_slug: orgSlug,
},
});
return apiKey;
};
devRouter.get("/data", withOrgAuth, async (req: any, res) => {
const apiKeys = await ApiKeyService.getByOrg(req.sb, req.orgId, req.env);
const org = await OrgService.getFullOrg({ sb: req.sb, orgId: req.orgId });