Skip to content

Commit

Permalink
add admin create invite code function
Browse files Browse the repository at this point in the history
  • Loading branch information
chase-manning committed Nov 30, 2023
1 parent 6eb691a commit c4a7b76
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import admin from "firebase-admin";

import registrationHandler from "./registration";
import wrapHandler, { getUserAddress, validateParams } from "./utils";
import { userExists } from "./db";
import { generateAndSaveInviteCodes, userExists } from "./db";
import { APIError, SignedParams } from "./types";

admin.initializeApp();
Expand Down Expand Up @@ -45,3 +45,12 @@ export const inviteCodeUsed = onRequest(
return codeSnapshot.val().used;
})
);

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;
})
);

0 comments on commit c4a7b76

Please sign in to comment.