forked from sombochea/verdaccio-ui
ae73772a37
* refactor: added eslint-plugin-import * refactor: disable some rules for muiComponents * fix: fixed import
20 lines
913 B
TypeScript
20 lines
913 B
TypeScript
import { PackageMetaInterface } from 'types/packageMeta';
|
|
|
|
import API from './api';
|
|
|
|
export async function callReadme(packageName, packageVersion?: string): Promise<string | {}> {
|
|
return await API.request<string | {}>(`package/readme/${packageName}${packageVersion ? `?v=${packageVersion}` : ''}`, 'GET');
|
|
}
|
|
|
|
export async function callDetailPage(packageName: string, packageVersion?: string): Promise<PackageMetaInterface | {}> {
|
|
const packageMeta = await API.request<PackageMetaInterface | {}>(`sidebar/${packageName}${packageVersion ? `?v=${packageVersion}` : ''}`, 'GET');
|
|
|
|
return packageMeta;
|
|
}
|
|
|
|
export function callSearch(value: string, signal: any) {
|
|
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#Browser_compatibility
|
|
// FUTURE: signal is not well supported for IE and Samsung Browser
|
|
return API.request(`search/${encodeURIComponent(value)}`, 'GET', { signal, headers: {} });
|
|
}
|