test workings

This commit is contained in:
simojenki
2022-04-23 14:23:20 +10:00
parent d2f13416f6
commit 1b14b88fb4
6 changed files with 19 additions and 210 deletions

View File

@@ -11,56 +11,10 @@ export interface Http {
(config: AxiosRequestConfig): AxiosPromise<any>;
}
// export const http =
// (base: Http = axios, modifier: RequestModifier = no_op): Http =>
// (config: AxiosRequestConfig) => {
// console.log(
// `applying ${JSON.stringify(config)} onto ${JSON.stringify(modifier)}`
// );
// const result = modifier(config);
// console.log(`result is ${JSON.stringify(result)}`);
// return base(result);
// };
// export const chain =
// (...modifiers: RequestModifier[]): RequestModifier =>
// (config: AxiosRequestConfig) =>
// modifiers.reduce(
// (config: AxiosRequestConfig, next: RequestModifier) => next(config),
// config
// );
// export const baseUrl = (baseURL: string) => (config: AxiosRequestConfig) => ({
// ...config,
// baseURL,
// });
// export const axiosConfig =
// (additionalConfig: Partial<AxiosRequestConfig>) =>
// (config: AxiosRequestConfig) => ({ ...config, ...additionalConfig });
// export const params = (params: any) => (config: AxiosRequestConfig) => {
// console.log(
// `params on config ${JSON.stringify(
// config.params
// )}, params applying ${JSON.stringify(params)}`
// );
// const after = { ...config, params: { ...config.params, ...params } };
// console.log(`params after ${JSON.stringify(after.params)}`);
// return after;
// };
// export const headers = (headers: any) => (config: AxiosRequestConfig) => ({
// ...config,
// headers: { ...config.headers, ...headers },
// });
// export const formatJson = (): RequestModifier => (config: AxiosRequestConfig) => ({...config, params: { ...config.params, f: 'json' } });
// export const subsonicAuth = (credentials: { username: string, password: string}) => (config: AxiosRequestConfig) => ({...config, params: { ...config.params, u: credentials.username, ...t_and_s(credentials.password) } });
export type RequestParams = { baseURL: string; url: string, params: any, headers: any, responseType: ResponseType }
// todo: rename to http
export const http2 =
export const http =
(base: Http, defaults: Partial<RequestParams>): Http =>
(config: AxiosRequestConfig) => {
let toApply = {

View File

@@ -6,7 +6,8 @@ import {
t_and_s,
USER_AGENT,
} from ".";
import { Http, http2 } from "../http";
// todo: rename http2 to http
import { Http, http as http2 } from "../http";
import { Credentials } from "../music_service";
import { asURLSearchParams } from "../utils";

View File

@@ -4,7 +4,8 @@ import { Md5 } from "ts-md5/dist/md5";
import axios from "axios";
import randomstring from "randomstring";
import _ from "underscore";
import { Http, http2 } from "../http";
// todo: rename http2 to http
import { Http, http as http2 } from "../http";
import {
Credentials,

View File

@@ -37,7 +37,8 @@ import Subsonic, {
import axios from "axios";
import { asURLSearchParams } from "../utils";
import { artistSummaryFromNDArtist, NDArtist } from "./navidrome";
import { Http, http2 } from "../http";
//todo: rename http2 -> http
import { Http, http as http2 } from "../http";
import { getRaw2 } from "./http";
type album = {