-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from polyfact/feat/auth
✨ Add front-end auth & projects
- Loading branch information
Showing
14 changed files
with
646 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
import { createClient, SupabaseClient } from "@supabase/supabase-js"; | ||
import { POLYFACT_ENDPOINT, POLYFACT_TOKEN } from "./utils"; | ||
|
||
export type ClientOptions = { | ||
endpoint: string; | ||
token: string; | ||
}; | ||
|
||
export function defaultOptions(opts: Partial<ClientOptions>): ClientOptions { | ||
if (!(opts.token || process?.env?.POLYFACT_TOKEN)) { | ||
export type InputClientOptions = Partial<ClientOptions> | Promise<Partial<ClientOptions>>; | ||
|
||
export async function defaultOptions(popts: InputClientOptions): Promise<ClientOptions> { | ||
const opts = await popts; | ||
if (!opts.token && !POLYFACT_TOKEN) { | ||
throw new Error( | ||
"Please put your polyfact token in the POLYFACT_TOKEN environment variable. You can get one at https://app.polyfact.com", | ||
); | ||
} | ||
|
||
return { | ||
endpoint: process?.env.POLYFACT_ENDPOINT || "https://api2.polyfact.com", | ||
token: process?.env?.POLYFACT_TOKEN || "", | ||
endpoint: POLYFACT_ENDPOINT || "https://api2.polyfact.com", | ||
token: POLYFACT_TOKEN || "", | ||
...opts, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.