This commit is contained in:
2026-02-05 19:37:55 +08:00
parent 9d811afeb4
commit ee56795461
5 changed files with 20 additions and 31 deletions

View File

@@ -5,6 +5,9 @@ export type CNBCoreOptions<T = {}> = {
*/
cookie?: string;
cnb?: CNBCore;
cors?: {
baseUrl?: string
}
} & T;
export type RequestOptions = {
@@ -19,6 +22,7 @@ export type RequestOptions = {
};
export class CNBCore {
baseURL = 'https://api.cnb.cool';
hackURL = 'https://cnb.cool'
public token: string;
public cookie?: string;
constructor(options: CNBCoreOptions) {
@@ -32,6 +36,10 @@ export class CNBCore {
this.cookie = options.cnb.cookie;
}
}
if (options?.cors?.baseUrl) {
this.baseURL = options.cors.baseUrl + '/' + this.baseURL;
this.hackURL = options.cors.baseUrl + '/' + this.hackURL;
}
}
async request({ url, method = 'GET', data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any> {