mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 09:39:09 +00:00
refactor(api): Abstract discord API base url to config.ts
Signed-off-by: Katalina Okano <git@kat.cafe>
This commit is contained in:
parent
31ea2e2183
commit
824fee0703
4 changed files with 14 additions and 6 deletions
|
@ -17,7 +17,13 @@ import {
|
|||
userAgent,
|
||||
} from '../utils/api-tools';
|
||||
import { Bounce } from '../utils/bounce';
|
||||
import { apiPublicURI, botClientID, botClientSecret, uiPublicURI } from '../utils/config';
|
||||
import {
|
||||
apiPublicURI,
|
||||
botClientID,
|
||||
botClientSecret,
|
||||
discordAPIBase,
|
||||
uiPublicURI,
|
||||
} from '../utils/config';
|
||||
import { Sessions } from '../utils/kv';
|
||||
|
||||
const AuthErrorResponse = (extra?: string) =>
|
||||
|
@ -72,7 +78,7 @@ export const LoginCallback = resolveFailures(
|
|||
code,
|
||||
};
|
||||
|
||||
const tokenFetch = await fetch('https://discord.com/api/v8/oauth2/token', {
|
||||
const tokenFetch = await fetch(discordAPIBase + '/oauth2/token', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { SessionData } from '@roleypoly/types';
|
||||
import { formData, respond, userAgent, withSession } from '../utils/api-tools';
|
||||
import { botClientID, botClientSecret } from '../utils/config';
|
||||
import { botClientID, botClientSecret, discordAPIBase } from '../utils/config';
|
||||
import { Sessions } from '../utils/kv';
|
||||
|
||||
export const RevokeSession = withSession(
|
||||
|
@ -11,7 +11,7 @@ export const RevokeSession = withSession(
|
|||
client_secret: botClientSecret,
|
||||
};
|
||||
|
||||
await fetch('https://discord.com/api/v8/oauth2/token/revoke', {
|
||||
await fetch(discordAPIBase + '/oauth2/token/revoke', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue