Skip to content

Commit

Permalink
Fix lint error in store-account-event
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed May 30, 2023
1 parent 3e2923b commit 2d7ff2a
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions functions/src/functions/store-account-event.ts
Expand Up @@ -16,24 +16,44 @@ export function buildStoreAccountEvent(
): functions.HttpsFunction {
const db = getFirestore(app);

return functions.region(region).https.onCall(async (data, context) => {
if (typeof data !== "object" || data === null)
throw new functions.https.HttpsError(
"invalid-argument",
// TODO: fix message
"invalid-argument"
);
const uid = context.auth?.uid;
if (uid === undefined)
throw new functions.https.HttpsError(
"unauthenticated",
// TODO: fix message
"unauthenticated"
);
const { event, last_event_id: lastEventId } = data;
await storeAccountEvent(db, uid, lastEventId, event);
return {};
});
return functions
.region(region)
.https.onCall(async (data: unknown, context) => {
if (
typeof data !== "object" ||
data === null ||
!("event" in data) ||
!("last_event_id" in data)
)
throw new functions.https.HttpsError(
"invalid-argument",
// TODO: fix message
"invalid-argument"
);
const uid = context.auth?.uid;
if (uid === undefined)
throw new functions.https.HttpsError(
"unauthenticated",
// TODO: fix message
"unauthenticated"
);
const { event, last_event_id: lastEventId } = data;
if (lastEventId !== null && typeof lastEventId !== "string")
throw new functions.https.HttpsError(
"invalid-argument",
// TODO: fix message
"invalid-argument"
);
// TODO: check event format
if (typeof event !== "object" || event === null)
throw new functions.https.HttpsError(
"invalid-argument",
// TODO: fix message
"invalid-argument"
);
await storeAccountEvent(db, uid, lastEventId, event as AccountEvent);
return {};
});
}

function err(message: string): Promise<never> {
Expand Down

0 comments on commit 2d7ff2a

Please sign in to comment.