Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 3x 3x 3x 13x 3x | import FormStack from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FormStack';
import { ABasicApplication } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/Basic/ABasicApplication';
import RequestDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto';
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
import AProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/AProcessDto';
export const NAME = 'json-placeholder';
const BASE_URL = 'https://jsonplaceholder.typicode.com';
export default class JsonPlaceholderApplication extends ABasicApplication {
protected isInstallable = false;
public getName(): string {
return NAME;
}
public getPublicName(): string {
return 'JsonPlaceholder Application';
}
public getDescription(): string {
return 'Free fake and reliable API for testing and prototyping. Powered by JSON Server + LowDB.';
}
public getFormStack(): FormStack {
return new FormStack();
}
public isAuthorized(): boolean {
return true;
}
public getRequestDto(): RequestDto {
throw new Error('Method getRequestDto is not supported, use getRequestDtoWithoutInstallation instead.');
}
public getRequestDtoWithoutInstallation(
dto: AProcessDto,
method: HttpMethods,
path?: string,
data?: unknown,
): RequestDto {
const url = new URL(path ?? '', BASE_URL).href;
return new RequestDto(url, method, dto, data);
}
}
export function filterToQueryParamString<
T extends Record<string, string | number | boolean>,
>(keys: (keyof T)[], filter?: T): string {
Iif (!filter) {
return '';
}
const params = new URLSearchParams();
keys.forEach((key) => {
Iif (key in filter) {
params.set(key as string, String(filter[key]));
}
});
return params.size ? `?${params}` : '';
}
|