mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
33 lines
844 B
TypeScript
33 lines
844 B
TypeScript
import { functions } from "./index";
|
|
|
|
export enum CLOUD_FUNCTIONS {
|
|
ImpersonatorAuth = "callable-ImpersonatorAuth",
|
|
getAlgoliaSearchKey = 'getAlgoliaSearchKey'
|
|
}
|
|
|
|
export const cloudFunction = (
|
|
name: string,
|
|
input: any,
|
|
success?: Function,
|
|
fail?: Function
|
|
) =>
|
|
new Promise((resolve, reject) => {
|
|
const callable = functions.httpsCallable(name);
|
|
callable(input)
|
|
.then((result) => {
|
|
if (success) {
|
|
resolve(success(result));
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
if (fail) {
|
|
reject(fail(error));
|
|
}
|
|
});
|
|
});
|
|
|
|
export const ImpersonatorAuth = (email: string) =>
|
|
functions.httpsCallable(CLOUD_FUNCTIONS.ImpersonatorAuth)({ email });
|
|
|
|
export const getAlgoliaSearchKey = (index: string) =>
|
|
functions.httpsCallable(CLOUD_FUNCTIONS.getAlgoliaSearchKey)({ index }); |