Skip to content

Commit

Permalink
fix issue with codes not being returned
Browse files Browse the repository at this point in the history
  • Loading branch information
chase-manning committed Nov 30, 2023
1 parent c4a7b76 commit 49090b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions functions/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ async function generateInviteCode(): Promise<string> {
return code;
}

export async function generateAndSaveInviteCodes(user: string, count: number): Promise<Code[]> {
export async function generateAndSaveInviteCodes(user: string, count: number): Promise<string[]> {
const db = admin.database();
const codes = [];
for (let i = 0; i < count; i++) {
const code = await generateInviteCode();
const codeMetadata = { creator: user, used: false, createdAt: Date.now() };
codes.push(codeMetadata);
codes.push(code);
await db.ref("invites").child(code).set(codeMetadata);
}
return codes;
Expand Down
3 changes: 1 addition & 2 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const adminCreateInviteCodes = onRequest(
wrapHandler(async (request) => {
const { amount } = validateParams<{ amount: string }>(request.query, "amount");
const adminAddress = "0x0000000000000000000000000000000000000000";
const codes = await generateAndSaveInviteCodes(adminAddress, Number(amount));
return codes;
return await generateAndSaveInviteCodes(adminAddress, Number(amount));
})
);

0 comments on commit 49090b2

Please sign in to comment.