Files
outline/shared/utils/urlHelpers.ts
Tom Moor 3c002f82cc chore: Centralize env parsing, validation, defaults, and deprecation notices (#3487)
* chore: Centralize env parsing, defaults, deprecation

* wip

* test

* test

* tsc

* docs, more validation

* fix: Allow empty REDIS_URL (defaults to localhost)

* test

* fix: SLACK_MESSAGE_ACTIONS not bool

* fix: Add SMTP port validation
2022-05-19 08:05:11 -07:00

56 lines
1.3 KiB
TypeScript

import env from "../env";
export function slackAuth(
state: string,
scopes: string[] = [
"identity.email",
"identity.basic",
"identity.avatar",
"identity.team",
],
clientId: string,
redirectUri = `${env.URL}/auth/slack.callback`
): string {
const baseUrl = "https://slack.com/oauth/authorize";
const params = {
client_id: clientId,
scope: scopes ? scopes.join(" ") : "",
redirect_uri: redirectUri,
state,
};
const urlParams = Object.keys(params)
.map((key) => `${key}=${encodeURIComponent(params[key])}`)
.join("&");
return `${baseUrl}?${urlParams}`;
}
export function githubUrl(): string {
return "https://www.github.com/outline";
}
export function githubIssuesUrl(): string {
return "https://www.github.com/outline/outline/issues";
}
export function twitterUrl(): string {
return "https://twitter.com/getoutline";
}
export function feedbackUrl(): string {
return "https://www.getoutline.com/contact";
}
export function developersUrl(): string {
return "https://www.getoutline.com/developers";
}
export function changelogUrl(): string {
return "https://www.getoutline.com/changelog";
}
export function signin(service = "slack"): string {
return `${env.URL}/auth/${service}`;
}
export const SLUG_URL_REGEX = /^(?:[0-9a-zA-Z-_~]*-)?([a-zA-Z0-9]{10,15})$/;