forked from sombochea/verdaccio-ui
fix: remove any types and added additional component state interfaces
This commit is contained in:
@@ -25,16 +25,16 @@ function handleResponseType(response: Response): Promise<[boolean, Blob | string
|
||||
}
|
||||
|
||||
class API {
|
||||
public request(url: string, method = 'GET', options: any = {}): Promise<any> {
|
||||
public request<T>(url: string, method = 'GET', options?: RequestInit): Promise<T> {
|
||||
if (!window.VERDACCIO_API_URL) {
|
||||
throw new Error('VERDACCIO_API_URL is not defined!');
|
||||
}
|
||||
|
||||
const token = storage.getItem('token');
|
||||
if (token) {
|
||||
if (!options.headers) options.headers = {};
|
||||
|
||||
options.headers.authorization = `Bearer ${token}`;
|
||||
const headers = new Headers(options && options.headers);
|
||||
if (token && options && options.headers) {
|
||||
headers.set('Authorization', `Bearer ${token}`);
|
||||
options.headers = Object.assign(options.headers, headers);
|
||||
}
|
||||
|
||||
if (!['http://', 'https://', '//'].some(prefix => url.startsWith(prefix))) {
|
||||
@@ -42,7 +42,7 @@ class API {
|
||||
url = window.VERDACCIO_API_URL + url;
|
||||
}
|
||||
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(url, {
|
||||
method,
|
||||
credentials: 'same-origin',
|
||||
|
||||
@@ -2,8 +2,8 @@ import API from './api';
|
||||
import { PackageMetaInterface } from 'types/packageMeta';
|
||||
|
||||
export interface DetailPage {
|
||||
readMe: string;
|
||||
packageMeta: PackageMetaInterface;
|
||||
readMe: string | {};
|
||||
packageMeta: PackageMetaInterface | {};
|
||||
}
|
||||
|
||||
export async function callDetailPage(packageName): Promise<DetailPage> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* tslint:disable */
|
||||
/* @ts-ignore */
|
||||
export default function fileSizeSI(a?: any, b?: any, c?: any, d?: any, e?: any) {
|
||||
return ((b = Math), (c = b.log), (d = 1e3), (e = (c(a) / c(d)) | 0), a / b.pow(d, e)).toFixed(2) + ' ' + (e ? 'kMGTPEZY'[--e] + 'B' : 'Bytes');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user