Skip to content

Instantly share code, notes, and snippets.

@LironHazan
Created January 29, 2021 11:43
Show Gist options
  • Save LironHazan/5d83ea4e7b6833d5d7ca7041a3943cb5 to your computer and use it in GitHub Desktop.
Save LironHazan/5d83ea4e7b6833d5d7ca7041a3943cb5 to your computer and use it in GitHub Desktop.
const readCreds: Task<string> = async () => readFromFile('src/private/credentials.json', 'utf-8');
const fail = <T>(reason: T) => new Error(`${reason}`);
const auth = (creds: string) => authorize(JSON.parse(creds), fetchTables);
export async function exportTables<E>(): Promise<Either<Error, Promise<Either<void, void>>>> {
const result: TaskEither<Error, string> = tryCatch(readCreds, fail);
return await pipe(result, map(auth))();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment