mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
feat: enable strictNullChecks
feat: enable `noImplicitAny` chore: remove sync data access fix loading package data for affected dependencies chore: properly get alt marketplace data update patchdb client to allow for emit on undefined values
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import {
|
||||
HttpClient,
|
||||
HttpErrorResponse,
|
||||
HttpHeaders,
|
||||
HttpParams,
|
||||
} from '@angular/common/http'
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'
|
||||
import { Observable, from, interval, race } from 'rxjs'
|
||||
import { map, take } from 'rxjs/operators'
|
||||
import { ConfigService } from './config.service'
|
||||
@@ -27,6 +22,7 @@ export class HttpService {
|
||||
this.fullUrl = `${window.location.protocol}//${window.location.hostname}:${port}`
|
||||
}
|
||||
|
||||
// @ts-ignore TODO: fix typing
|
||||
async rpcRequest<T>(rpcOpts: RPCOptions): Promise<T> {
|
||||
const { url, version } = this.config.api
|
||||
rpcOpts.params = rpcOpts.params || {}
|
||||
@@ -53,12 +49,15 @@ export class HttpService {
|
||||
|
||||
const urlIsRelative = httpOpts.url.startsWith('/')
|
||||
const url = urlIsRelative ? this.fullUrl + httpOpts.url : httpOpts.url
|
||||
const { params } = httpOpts
|
||||
|
||||
Object.keys(httpOpts.params || {}).forEach(key => {
|
||||
if (httpOpts.params[key] === undefined) {
|
||||
delete httpOpts.params[key]
|
||||
}
|
||||
})
|
||||
if (hasParams(params)) {
|
||||
Object.keys(params).forEach(key => {
|
||||
if (params[key] === undefined) {
|
||||
delete params[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const options = {
|
||||
responseType: httpOpts.responseType || 'json',
|
||||
@@ -181,6 +180,12 @@ export interface HttpOptions {
|
||||
timeout?: number
|
||||
}
|
||||
|
||||
function hasParams(
|
||||
params?: HttpOptions['params'],
|
||||
): params is Record<string, string | string[]> {
|
||||
return !!params
|
||||
}
|
||||
|
||||
function withTimeout<U>(req: Observable<U>, timeout: number): Observable<U> {
|
||||
return race(
|
||||
from(req.toPromise()), // this guarantees it only emits on completion, intermediary emissions are suppressed.
|
||||
|
||||
Reference in New Issue
Block a user