Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into PE-5964-navigation…
Browse files Browse the repository at this point in the history
…-sider-navbar-routing-breadcrumbs
  • Loading branch information
kunstmusik committed Apr 24, 2024
2 parents 8907dc5 + ccec60d commit 2a3ee8f
Show file tree
Hide file tree
Showing 7 changed files with 1,680 additions and 1,564 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "ar-io-network-portal-a40ee"
}
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.16.0
20.6.0
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "template-react-tailwind",
"name": "@ar-io/network-portal",
"private": true,
"version": "0.0.0",
"type": "module",
Expand All @@ -24,12 +24,10 @@
"@sentry/react": "^7.101.1",
"axios": "^1.6.7",
"axios-retry": "^4.0.0",
"eslint-plugin-tailwindcss": "^3.14.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.1",
"tailwindcss-animate": "^1.0.7",
"ts-jest": "^29.1.2",
"winston": "^3.11.0",
"zustand": "^4.5.1"
},
Expand Down Expand Up @@ -84,6 +82,7 @@
"prettier-plugin-tailwindcss": "^0.5.11",
"rimraf": "^5.0.5",
"tailwindcss": "^3.4.1",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.2.2",
"vite": "^5.1.0",
Expand Down
64 changes: 6 additions & 58 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import winston, { createLogger, format, transports } from 'winston';
import { createLogger, format, transports } from 'winston';

import { Logger } from '../types/index.js';

export const ARIO_DOCS_URL = 'https://docs.ar.io';
export const GATEWAY_CONTRACT_URL =
Expand All @@ -11,60 +10,9 @@ export const THEME_TYPES = {
DARK: 'dark',
};

export class DefaultLogger implements Logger {
private logger: winston.Logger;
constructor({
level = 'info',
logFormat = 'simple',
}: {
level?: 'info' | 'debug' | 'error' | 'none' | undefined;
logFormat?: 'simple' | 'json' | undefined;
} = {}) {
this.logger = createLogger({
level,
silent: level === 'none',
format: getLogFormat(logFormat),
export const defaultLogger = createLogger({
level: 'info',
silent: false,
format: format.simple(),
transports: [new transports.Console()],
});
}

/* eslint-disable @typescript-eslint/no-explicit-any */
info(message: string, ...args: any[]) {
this.logger.info(message, ...args);
}

warn(message: string, ...args: any[]) {
this.logger.warn(message, ...args);
}

error(message: string, ...args: any[]) {
this.logger.error(message, ...args);
}

debug(message: string, ...args: any[]) {
this.logger.debug(message, ...args);
}

setLogLevel(level: string) {
this.logger.level = level;
}

setLogFormat(logFormat: string) {
this.logger.format = getLogFormat(logFormat);
}
/* eslint-enable @typescript-eslint/no-explicit-any */
}

function getLogFormat(logFormat: string) {
return format.combine(
format((info) => {
if (info.stack && info.level !== 'error') {
delete info.stack;
}
return info;
})(),
format.errors({ stack: true }), // Ensure errors show a stack trace
format.timestamp(),
logFormat === 'json' ? format.json() : format.simple(),
);
}
})
8 changes: 5 additions & 3 deletions src/services/http.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DefaultLogger } from '@src/constants';
import { defaultLogger } from '@src/constants';
import axios, {
AxiosInstance,
AxiosProgressEvent,
Expand All @@ -9,7 +9,9 @@ import axiosRetry, { IAxiosRetryConfig } from 'axios-retry';
import { Readable } from 'stream';
import { ReadableStream } from 'stream/web';

import { FailedRequestError, HTTPClient, Logger } from '../../types';
import { FailedRequestError, HTTPClient } from '../../types';
import { Logger } from 'winston'


export class AxiosHTTPService implements HTTPClient {
private axios: AxiosInstance;
Expand Down Expand Up @@ -95,7 +97,7 @@ export interface AxiosInstanceParameters {
}

export const createAxiosInstance = ({
logger = new DefaultLogger(),
logger = defaultLogger,
axiosConfig = {},
retryConfig = {
retryDelay: axiosRetry.exponentialDelay,
Expand Down
9 changes: 0 additions & 9 deletions types/common.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { Readable } from 'stream';
import { ReadableStream } from 'stream/web';

export interface Logger {
setLogLevel: (level: string) => void;
setLogFormat: (logFormat: string) => void;
info: (message: string, ...args: any[]) => void;
warn: (message: string, ...args: any[]) => void;
error: (message: string, ...args: any[]) => void;
debug: (message: string, ...args: any[]) => void;
}

export interface HTTPClient {
get<T>({
endpoint,
Expand Down
Loading

0 comments on commit 2a3ee8f

Please sign in to comment.