From bdc4e5d31320e6d76e0cd2156bdc037f7e7fb88e Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Wed, 24 Jul 2024 23:40:59 +0100 Subject: [PATCH] do some cleaning --- src/components/database/index.ts | 18 ++++++------------ src/components/storage/index.ts | 8 ++------ src/test/unit/logging.test.ts | 2 ++ src/test/unit/storage.test.ts | 6 ------ src/utils/asset.ts | 7 ++----- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/src/components/database/index.ts b/src/components/database/index.ts index d47032c62..2be3f7c81 100644 --- a/src/components/database/index.ts +++ b/src/components/database/index.ts @@ -21,8 +21,7 @@ export class OrderDatabase { return (async (): Promise => { this.provider = new Typesense({ ...convertTypesenseConfig(this.config.url), - logger: DATABASE_LOGGER, - logLevel: LOG_LEVELS_STR.LEVEL_ERROR + logger: DATABASE_LOGGER }) try { await this.provider.collections(this.schema.name).retrieve() @@ -191,8 +190,7 @@ export class DdoStateDatabase { return (async (): Promise => { this.provider = new Typesense({ ...convertTypesenseConfig(this.config.url), - logger: DATABASE_LOGGER, - logLevel: LOG_LEVELS_STR.LEVEL_ERROR + logger: DATABASE_LOGGER }) try { await this.provider.collections(this.schema.name).retrieve() @@ -328,8 +326,7 @@ export class DdoDatabase { return (async (): Promise => { this.provider = new Typesense({ ...convertTypesenseConfig(this.config.url), - logger: DATABASE_LOGGER, - logLevel: LOG_LEVELS_STR.LEVEL_ERROR + logger: DATABASE_LOGGER }) for (const ddoSchema of this.schemas) { try { @@ -619,8 +616,7 @@ export class NonceDatabase { return (async (): Promise => { this.provider = new Typesense({ ...convertTypesenseConfig(this.config.url), - logger: DATABASE_LOGGER, - logLevel: LOG_LEVELS_STR.LEVEL_ERROR + logger: DATABASE_LOGGER }) try { await this.provider.collections(this.schema.name).retrieve() @@ -725,8 +721,7 @@ export class IndexerDatabase { return (async (): Promise => { this.provider = new Typesense({ ...convertTypesenseConfig(this.config.url), - logger: DATABASE_LOGGER, - logLevel: LOG_LEVELS_STR.LEVEL_ERROR + logger: DATABASE_LOGGER }) try { await this.provider.collections(this.schema.name).retrieve() @@ -836,8 +831,7 @@ export class LogDatabase { return (async (): Promise => { this.provider = new Typesense({ ...convertTypesenseConfig(this.config.url), - logger: DATABASE_LOGGER, - logLevel: LOG_LEVELS_STR.LEVEL_ERROR + logger: DATABASE_LOGGER }) try { await this.provider.collections(this.schema.name).retrieve() diff --git a/src/components/storage/index.ts b/src/components/storage/index.ts index 84ecb1c97..3d28ce212 100644 --- a/src/components/storage/index.ts +++ b/src/components/storage/index.ts @@ -14,6 +14,7 @@ import urlJoin from 'url-join' import { encrypt as encryptData, decrypt as decryptData } from '../../utils/crypt.js' import { Readable } from 'stream' import { getConfiguration } from '../../utils/index.js' +import { CORE_LOGGER } from '../../utils/logging/common.js' export abstract class Storage { private file: UrlFileObject | IpfsFileObject | ArweaveFileObject @@ -80,20 +81,16 @@ export abstract class Storage { const response: FileInfoResponse[] = [] try { - console.log('before getFile()') const file = this.getFile() - console.log('after getFile()') if (!file) { throw new Error('Empty file object') } else { - console.log('before get metadata....') const fileInfo = await this.fetchSpecificFileMetadata(file, forceChecksum) - console.log('after get metadata....') response.push(fileInfo) } } catch (error) { - console.log(error) + CORE_LOGGER.error(error) } return response } @@ -299,7 +296,6 @@ export class ArweaveStorage extends Storage { forceChecksum: boolean ): Promise { const url = urlJoin(process.env.ARWEAVE_GATEWAY, fileObject.transactionId) - console.log('URL:', url) const { contentLength, contentType, contentChecksum } = await fetchFileMetadata( url, 'get', diff --git a/src/test/unit/logging.test.ts b/src/test/unit/logging.test.ts index 699ecbe33..6bdecd4c5 100644 --- a/src/test/unit/logging.test.ts +++ b/src/test/unit/logging.test.ts @@ -53,7 +53,9 @@ describe('Logger instances and transports tests', async () => { // will build the DB transport layer const config = await getConfiguration(true) // eslint-disable-next-line no-unused-vars + console.log('CONFIG IS', config.dbConfig) const DB = await new Database(config.dbConfig) + console.log(DB) // Could generate Typesene error if DB is not running, but does not matter for this test OCEAN_NODE_LOGGER.logMessage('Should build DB transport layer') diff --git a/src/test/unit/storage.test.ts b/src/test/unit/storage.test.ts index d4b2498e7..7823dc14e 100644 --- a/src/test/unit/storage.test.ts +++ b/src/test/unit/storage.test.ts @@ -324,8 +324,6 @@ describe('Arweave Storage getFileInfo tests', function () { // this.timeout(15000) let storage: ArweaveStorage - console.log('STORAGE TESTING....') - before(() => { storage = new ArweaveStorage({ type: FileObjectType.ARWEAVE, @@ -349,13 +347,9 @@ describe('Arweave Storage getFileInfo tests', function () { }) it('Throws error when transaction ID is missing in request', async () => { - console.log('DO YOU SEE ME??') - const fileInfoRequest: FileInfoRequest = { type: FileObjectType.ARWEAVE } try { - console.log('3 - DO YOU STILL SEE ME??') await storage.getFileInfo(fileInfoRequest) - console.log('4 - DO YOU STILL SEE ME HERE??') } catch (err) { expect(err.message).to.equal('Transaction ID is required for type arweave') } diff --git a/src/utils/asset.ts b/src/utils/asset.ts index e680026e9..8901b0a7e 100644 --- a/src/utils/asset.ts +++ b/src/utils/asset.ts @@ -43,12 +43,10 @@ export async function fetchFileMetadata( const response = await axios({ url, method: method || 'get', - responseType: 'stream', - timeout: 10000 // 10 seconds timeout + responseType: 'stream' }) contentType = response.headers['content-type'] let totalSize = 0 - console.log('reading content') for await (const chunk of response.data) { totalSize += chunk.length contentChecksum.update(chunk) @@ -59,10 +57,9 @@ export async function fetchFileMetadata( } contentLength = totalSize } catch (error) { - console.log('Got error: ', error) + CORE_LOGGER.error(error) } - console.log('im out') return { contentLength: contentLength.toString(), contentType,