Skip to content

Commit

Permalink
fix: added more clarity for the types
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhen-burkovskyi committed Apr 15, 2024
1 parent 9fc9825 commit c0f5d70
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/api/core/services/osmosis/osmosis.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export namespace OsmosisService {
return errorHandleWrapper(
HttpRequester.get.bind(
null,
constructUrl(endpoint, createUrlParams({ tf: payload.range }))
constructUrl(endpoint, createUrlParams({ tf: payload.range.toString() }))
)
);
}
Expand Down
5 changes: 3 additions & 2 deletions app/api/core/utils/create-url-params.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function createUrlParams (params: any): string {
type URLSearchParamInit = string | URLSearchParams | string[][] | Record<string, string> | undefined;

export function createUrlParams (params: URLSearchParamInit): string {
const url = new URLSearchParams(params);
return url.toString();
}
2 changes: 1 addition & 1 deletion app/api/core/utils/exception-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NextResponse } from 'next/server';
import { HttpErrorMessage } from '@core/enums/http-error-message.enum';
import { HttpStatus } from '@core/enums/http-status.enum';

export async function exceptionFilter (fn: any) {
export async function exceptionFilter<T> (fn: () => T) {
try {
return await fn(); // just to catch all error at this step
} catch (e: any) {
Expand Down
2 changes: 1 addition & 1 deletion app/api/core/utils/schema-validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function schemaValidate (schema: ZodSchema, value: unknown) {
throw new BadRequestException(errorView(res));
}

function errorView (value: SafeParseError<unknown>): string {
function errorView<T> (value: SafeParseError<T>): string {
const flattenErrors = value.error.flatten();
let message = 'Passed fields didn\'t match current schema:';

Expand Down

0 comments on commit c0f5d70

Please sign in to comment.