Skip to content

Commit

Permalink
do some cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ocean committed Jul 24, 2024
1 parent 498d1b0 commit bdc4e5d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 29 deletions.
18 changes: 6 additions & 12 deletions src/components/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export class OrderDatabase {
return (async (): Promise<OrderDatabase> => {
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()
Expand Down Expand Up @@ -191,8 +190,7 @@ export class DdoStateDatabase {
return (async (): Promise<DdoStateDatabase> => {
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()
Expand Down Expand Up @@ -328,8 +326,7 @@ export class DdoDatabase {
return (async (): Promise<DdoDatabase> => {
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 {
Expand Down Expand Up @@ -619,8 +616,7 @@ export class NonceDatabase {
return (async (): Promise<NonceDatabase> => {
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()
Expand Down Expand Up @@ -725,8 +721,7 @@ export class IndexerDatabase {
return (async (): Promise<IndexerDatabase> => {
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()
Expand Down Expand Up @@ -836,8 +831,7 @@ export class LogDatabase {
return (async (): Promise<LogDatabase> => {
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()
Expand Down
8 changes: 2 additions & 6 deletions src/components/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -299,7 +296,6 @@ export class ArweaveStorage extends Storage {
forceChecksum: boolean
): Promise<FileInfoResponse> {
const url = urlJoin(process.env.ARWEAVE_GATEWAY, fileObject.transactionId)
console.log('URL:', url)
const { contentLength, contentType, contentChecksum } = await fetchFileMetadata(
url,
'get',
Expand Down
2 changes: 2 additions & 0 deletions src/test/unit/logging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
6 changes: 0 additions & 6 deletions src/test/unit/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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')
}
Expand Down
7 changes: 2 additions & 5 deletions src/utils/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down

0 comments on commit bdc4e5d

Please sign in to comment.