Files
plane/packages/services/src/api.service.ts
T
sriram veeraghanta 7ec8d4990f fix: bump npm deps to resolve Dependabot advisories (#9191)
* 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 (ws@7.5.10 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.
2026-06-01 18:37:35 +05:30

97 lines
2.9 KiB
TypeScript

/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
import type { AxiosInstance, AxiosRequestConfig } from "axios";
import { create } from "axios";
/**
* Abstract base class for making HTTP requests using axios
* @abstract
*/
export abstract class APIService {
protected baseURL: string;
private axiosInstance: AxiosInstance;
/**
* Creates an instance of APIService
* @param {string} baseURL - The base URL for all HTTP requests
*/
constructor(baseURL: string) {
this.baseURL = baseURL;
this.axiosInstance = create({
baseURL,
withCredentials: true,
});
}
/**
* Makes a GET request to the specified URL
* @param {string} url - The endpoint URL
* @param {object} [params={}] - URL parameters
* @param {AxiosRequestConfig} [config={}] - Additional axios configuration
* @returns {Promise} Axios response promise
*/
get(url: string, params = {}, config: AxiosRequestConfig = {}) {
return this.axiosInstance.get(url, {
...params,
...config,
});
}
/**
* Makes a POST request to the specified URL
* @param {string} url - The endpoint URL
* @param {object} [data={}] - Request body data
* @param {AxiosRequestConfig} [config={}] - Additional axios configuration
* @returns {Promise} Axios response promise
*/
post(url: string, data = {}, config: AxiosRequestConfig = {}) {
return this.axiosInstance.post(url, data, config);
}
/**
* Makes a PUT request to the specified URL
* @param {string} url - The endpoint URL
* @param {object} [data={}] - Request body data
* @param {AxiosRequestConfig} [config={}] - Additional axios configuration
* @returns {Promise} Axios response promise
*/
put(url: string, data = {}, config: AxiosRequestConfig = {}) {
return this.axiosInstance.put(url, data, config);
}
/**
* Makes a PATCH request to the specified URL
* @param {string} url - The endpoint URL
* @param {object} [data={}] - Request body data
* @param {AxiosRequestConfig} [config={}] - Additional axios configuration
* @returns {Promise} Axios response promise
*/
patch(url: string, data = {}, config: AxiosRequestConfig = {}) {
return this.axiosInstance.patch(url, data, config);
}
/**
* Makes a DELETE request to the specified URL
* @param {string} url - The endpoint URL
* @param {any} [data] - Request body data
* @param {AxiosRequestConfig} [config={}] - Additional axios configuration
* @returns {Promise} Axios response promise
*/
delete(url: string, data?: any, config: AxiosRequestConfig = {}) {
return this.axiosInstance.delete(url, { data, ...config });
}
/**
* Makes a custom request with the provided configuration
* @param {object} [config={}] - Axios request configuration
* @returns {Promise} Axios response promise
*/
request(config = {}) {
return this.axiosInstance(config);
}
}