manifold/web/lib/firebase/api-call.ts
mantikoros 908c8c03e6
Create user cloud function (#31)
* createUser cloud function; change User object

* initial commit

* listenForLogin: avoid race condition

* createUser: allow capital letters in username

* remove debugging

* leaderboard: empty url for undefined avatar image
2022-01-18 01:18:38 -06:00

20 lines
612 B
TypeScript

import { getFunctions, httpsCallable } from 'firebase/functions'
import { User } from '../../../common/user'
const functions = getFunctions()
export const cloudFunction = (name: string) => httpsCallable(functions, name)
export const createContract = cloudFunction('createContract')
export const placeBet = cloudFunction('placeBet')
export const resolveMarket = cloudFunction('resolveMarket')
export const sellBet = cloudFunction('sellBet')
export const createUser: () => Promise<User | null> = () =>
cloudFunction('createUser')({})
.then((r) => (r.data as any)?.user || null)
.catch(() => null)