Skip to content

Commit

Permalink
fix(backend): test execution fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arybitskiy committed Nov 21, 2024
1 parent b132e71 commit 210f14f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 39 deletions.
3 changes: 2 additions & 1 deletion apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"tar": "^6.2.0",
"valibot": "catalog:",
"ws": "^8.18.0",
"zod": "catalog:"
"zod": "catalog:",
"lodash-es": "catalog:"
},
"type": "module",
"peerDependencies": {
Expand Down
9 changes: 5 additions & 4 deletions apps/backend/src/services/UnkeyService.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import type { CreateAPIKeyRequest } from "@codemod-com/api-types";
import { Unkey } from "@unkey/api";
import { memoize } from "lodash-es";

const UNKEY_API_ID = process.env.UNKEY_API_ID as string;
const UNKEY_ROOT_KEY = process.env.UNKEY_ROOT_KEY as string;

const unkey = new Unkey({ rootKey: UNKEY_ROOT_KEY });
const getUnkey = memoize(() => new Unkey({ rootKey: UNKEY_ROOT_KEY }));

export const createApiKey = async ({
apiKeyData,
externalId,
}: { apiKeyData: CreateAPIKeyRequest; externalId: string }) => {
const response = await unkey.keys.create({
const response = await getUnkey().keys.create({
apiId: UNKEY_API_ID,
prefix: "codemod.com",
externalId,
Expand All @@ -28,7 +29,7 @@ export const createApiKey = async ({
};

export const listApiKeys = async ({ externalId }: { externalId: string }) => {
const response = await unkey.apis.listKeys({
const response = await getUnkey().apis.listKeys({
apiId: UNKEY_API_ID,
externalId,
});
Expand All @@ -43,7 +44,7 @@ export const listApiKeys = async ({ externalId }: { externalId: string }) => {
export const deleteApiKeys = async ({ keyIds }: { keyIds: string[] }) => {
await Promise.all(
keyIds.map(async (keyId) =>
unkey.keys.delete({
getUnkey().keys.delete({
keyId,
}),
),
Expand Down
Loading

0 comments on commit 210f14f

Please sign in to comment.