* fix: bump npm deps to resolve Dependabot advisories Resolve 8 open Dependabot alerts (all npm, in pnpm-lock.yaml) by bumping the affected packages in pnpm-workspace.yaml and regenerating the lockfile: - axios 1.15.2 -> 1.16.0 (catalog): CVE-2026-44494/44492/44490/44489 - tmp -> 0.2.6 (override): CVE-2026-44705 path traversal - ws 8.x -> 8.20.1 (catalog + scoped override): CVE-2026-45736 - qs 6.14.2 -> 6.15.2 (override): CVE-2026-8723 DoS - brace-expansion 5.0.5 -> 5.0.6 (override): CVE-2026-45149 DoS brace-expansion and qs were pinned to their vulnerable versions in the overrides block, so the pins had to be bumped directly. ws is scoped to the 8.x major ([email protected] is below the vulnerable >=8.0.0 floor). All bumps are semver-compatible patch/minor upgrades; no source changes required. * fix: use named axios `create` import after 1.16.0 bump axios 1.16.0 newly exposes `create` as a named export, so oxlint's import/no-named-as-default-member rule now flags `axios.create(...)`. That added one warning to @plane/services (7 > its --max-warnings=6 baseline) and to apps/web and apps/live, failing check:lint — surfaced on this PR because the lockfile change busts Turbo's lint cache. Switch the three `axios.create(...)` call sites to a named `{ create }` import. `create` is a real value+type export in axios 1.16.0 (verified via tsc). isCancel/CancelToken are left as `axios.*`: CancelToken is only a type export (cannot be a value import under verbatimModuleSyntax) and both were already counted within the existing baselines. Verified locally: full `pnpm check:lint` (16/16) and `check:types` (15/15) pass.
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
/**
|
|
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
* See the LICENSE file for details.
|
|
*/
|
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
import type { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
import { create } from "axios";
|
|
|
|
export abstract class APIService {
|
|
protected baseURL: string;
|
|
private axiosInstance: AxiosInstance;
|
|
|
|
constructor(baseURL: string) {
|
|
this.baseURL = baseURL;
|
|
this.axiosInstance = create({
|
|
baseURL,
|
|
withCredentials: true,
|
|
});
|
|
|
|
this.setupInterceptors();
|
|
}
|
|
|
|
private setupInterceptors() {
|
|
this.axiosInstance.interceptors.response.use(
|
|
(response) => response,
|
|
(error) => {
|
|
if (error.response && error.response.status === 401) {
|
|
const currentPath = window.location.pathname;
|
|
window.location.replace(`/${currentPath ? `?next_path=${currentPath}` : ``}`);
|
|
}
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
}
|
|
|
|
get(url: string, params = {}, config: AxiosRequestConfig = {}) {
|
|
return this.axiosInstance.get(url, {
|
|
...params,
|
|
...config,
|
|
});
|
|
}
|
|
|
|
post(url: string, data = {}, config: AxiosRequestConfig = {}) {
|
|
return this.axiosInstance.post(url, data, config);
|
|
}
|
|
|
|
put(url: string, data = {}, config: AxiosRequestConfig = {}) {
|
|
return this.axiosInstance.put(url, data, config);
|
|
}
|
|
|
|
patch(url: string, data = {}, config: AxiosRequestConfig = {}) {
|
|
return this.axiosInstance.patch(url, data, config);
|
|
}
|
|
|
|
delete(url: string, data?: any, config: AxiosRequestConfig = {}) {
|
|
return this.axiosInstance.delete(url, { data, ...config });
|
|
}
|
|
|
|
request(config = {}) {
|
|
return this.axiosInstance(config);
|
|
}
|
|
}
|