axios wrapper base
This commit is contained in:
parent
15daa9acef
commit
07d3629622
|
@ -11,7 +11,7 @@
|
||||||
import { DOM, BdUI, BdMenu, Modals, Toasts, Notifications, BdContextMenu, DiscordContextMenu } from 'ui';
|
import { DOM, BdUI, BdMenu, Modals, Toasts, Notifications, BdContextMenu, DiscordContextMenu } from 'ui';
|
||||||
import BdCss from './styles/index.scss';
|
import BdCss from './styles/index.scss';
|
||||||
import { Events, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi, BdWebApi, Connectivity, Cache, Reflection, PackageInstaller } from 'modules';
|
import { Events, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi, BdWebApi, Connectivity, Cache, Reflection, PackageInstaller } from 'modules';
|
||||||
import { ClientLogger as Logger, ClientIPC, Utils } from 'common';
|
import { ClientLogger as Logger, ClientIPC, Utils, Axi } from 'common';
|
||||||
import { BuiltinManager, EmoteModule, ReactDevtoolsModule, VueDevtoolsModule, TrackingProtection, E2EE } from 'builtin';
|
import { BuiltinManager, EmoteModule, ReactDevtoolsModule, VueDevtoolsModule, TrackingProtection, E2EE } from 'builtin';
|
||||||
import electron from 'electron';
|
import electron from 'electron';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
@ -39,7 +39,7 @@ class BetterDiscord {
|
||||||
BdWebApi,
|
BdWebApi,
|
||||||
Connectivity,
|
Connectivity,
|
||||||
Cache,
|
Cache,
|
||||||
Logger, ClientIPC, Utils,
|
Logger, ClientIPC, Utils, Axi,
|
||||||
|
|
||||||
plugins: PluginManager.localContent,
|
plugins: PluginManager.localContent,
|
||||||
themes: ThemeManager.localContent,
|
themes: ThemeManager.localContent,
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/**
|
||||||
|
* BetterDiscord axios wrapper
|
||||||
|
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
|
||||||
|
* All rights reserved.
|
||||||
|
* https://betterdiscord.net
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
export default class AxiosWrapper {
|
||||||
|
|
||||||
|
static get axios() { return axios; }
|
||||||
|
|
||||||
|
static get github() {
|
||||||
|
return this._github ? this._github : (
|
||||||
|
this._github = {
|
||||||
|
main: this.create('https://github.com'),
|
||||||
|
api: this.create('https://api.github.com')
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static create(baseUrl, timeout = 1000, headers = null) {
|
||||||
|
return axios.create({ baseURL: baseUrl, timeout, headers: headers ? headers : this.defaultHeaders });
|
||||||
|
}
|
||||||
|
|
||||||
|
static get defaultHeaders() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,3 +3,4 @@ export { default as Filters } from './filters';
|
||||||
export { default as Logger, ClientLogger } from './logger';
|
export { default as Logger, ClientLogger } from './logger';
|
||||||
export { default as ClientIPC } from './bdipc';
|
export { default as ClientIPC } from './bdipc';
|
||||||
export { default as AsyncEventEmitter } from './async-eventemitter';
|
export { default as AsyncEventEmitter } from './async-eventemitter';
|
||||||
|
export { default as Axi } from './axi';
|
||||||
|
|
Loading…
Reference in New Issue