Skip to content

Commit 51b7c66

Browse files
authored
Merge pull request #83 from internxt/fix/eslint-issues
[_]: fix/eslint-issues
2 parents 0fec9e8 + 013590a commit 51b7c66

31 files changed

Lines changed: 95 additions & 67 deletions

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default [
88
{
99
rules: {
1010
"@typescript-eslint/no-explicit-any": "warn",
11+
"no-console": "off"
1112
}
1213
}
1314
];

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@internxt/inxt-js",
3-
"version": "2.2.1",
3+
"version": "2.2.2",
44
"description": "",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",
@@ -38,7 +38,7 @@
3838
"chai": "5.2.0",
3939
"chai-as-promised": "8.0.1",
4040
"commander": "14.0.0",
41-
"dotenv": "16.6.0",
41+
"dotenv": "17.0.1",
4242
"eslint": "9.29.0",
4343
"express": "^5.1.0",
4444
"jest": "30.0.3",

src/api/ExchangeReport.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,11 @@ export class ExchangeReport {
122122

123123
error() {
124124
this.DownloadError();
125-
// eslint-disable-next-line @typescript-eslint/no-empty-function
126-
this.sendReport().catch(() => {});
125+
this.sendReport().catch(() => { });
127126
}
128127

129128
success() {
130129
this.DownloadOk();
131-
// eslint-disable-next-line @typescript-eslint/no-empty-function
132-
this.sendReport().catch(() => {});
130+
this.sendReport().catch(() => { });
133131
}
134132
}

src/api/ShardObject.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { INXTRequest } from '../lib';
55
import { ContractMeta } from '../api';
66
import { ShardMeta } from '../lib/models';
77
import { wrap } from '../lib/utils/error';
8-
import { logger } from '../lib/utils/logger';
98
import { InxtApiI, SendShardToNodeResponse } from '../services/api';
109
import { Shard } from './';
1110
import { get } from '../services/request';

src/cli/CommandInterface.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Command } from 'commander';
22
import { EnvironmentConfig } from '../api';
33
import { Environment } from '..';
4+
import { EnvService } from './EnvService';
45

56
export interface CommandOpts {
67
version: string;
@@ -19,10 +20,10 @@ interface Option {
1920

2021
export function getEnvironment(): Environment {
2122
const envConfig: EnvironmentConfig = {
22-
bridgePass: process.env.BRIDGE_PASS,
23-
bridgeUser: process.env.BRIDGE_USER,
24-
encryptionKey: process.env.MNEMONIC,
25-
bridgeUrl: process.env.BRIDGE_URL,
23+
bridgePass: EnvService.instance.get('BRIDGE_PASS'),
24+
bridgeUser: EnvService.instance.get('BRIDGE_USER'),
25+
encryptionKey: EnvService.instance.get('MNEMONIC'),
26+
bridgeUrl: EnvService.instance.get('BRIDGE_URL'),
2627
};
2728

2829
return new Environment(envConfig);

src/cli/EnvService.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export interface EnvKeys {
2+
readonly BRIDGE_USER: string;
3+
readonly BRIDGE_PASS: string;
4+
readonly MNEMONIC: string;
5+
readonly BUCKET_ID: string;
6+
readonly BRIDGE_URL: string;
7+
readonly STAGE: string;
8+
}
9+
10+
11+
export class EnvService {
12+
public static readonly instance: EnvService = new EnvService();
13+
14+
/**
15+
* Gets the value from an environment key
16+
* @param key The environment key to retrieve
17+
* @throws {Error} If key is not found in process.env
18+
* @returns The value from the environment variable
19+
**/
20+
public get = (key: keyof EnvKeys): string => {
21+
const value = process.env[key];
22+
if (!value) throw new Error(`Config key ${key} was not found in process.env`);
23+
return value;
24+
};
25+
}

src/cli/download-file.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import { pipeline, Readable } from 'stream';
33

44
import { logger } from '../lib/utils/logger';
55
import { getEnvironment } from './CommandInterface';
6+
import { EnvService } from './EnvService';
67

78
export async function downloadFile(fileId: string, path: string, concurrency: number) {
89
logger.info('Downloading file %s', fileId);
910

1011
const network = getEnvironment();
11-
const bucketId = process.env.BUCKET_ID;
12+
const bucketId = EnvService.instance.get('BUCKET_ID');
1213

1314
const destination = createWriteStream(path);
1415

@@ -52,7 +53,7 @@ export async function downloadFile(fileId: string, path: string, concurrency: nu
5253

5354
process.exit(0);
5455
} catch (err) {
55-
logger.error('Error downloading file %s', err.message);
56+
logger.error('Error downloading file %s', (err as Error).message ?? '');
5657

5758
process.exit(1);
5859
}

src/cli/get-download-links.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export async function getDownloadLinks(bucketId: string, fileIds: string[]): Pro
88
const response = await network.getDownloadLinks(bucketId, fileIds);
99
logger.info(`getDownloadLinks response: ${JSON.stringify(response, null, 2)}`);
1010
} catch (err) {
11-
logger.error(`Something went wrong while getting download links ${err.message}`);
11+
logger.error(`Something went wrong while getting download links ${(err as Error).message ?? ''}`);
1212
}
1313
}

src/cli/get-filo-info.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { DecryptFileName } from '../lib/utils/crypto';
44
import { logger } from '../lib/utils/logger';
55

66
import { getEnvironment } from './CommandInterface';
7+
import { EnvService } from './EnvService';
78

89
export function getFileInfo(fileId: string): Promise<void> {
910
logger.info('Retrieving info for file %s', fileId);
1011

1112
const network = getEnvironment();
12-
const bucketId = process.env.BUCKET_ID;
13+
const bucketId = EnvService.instance.get('BUCKET_ID');
1314

1415
if (!network.config.encryptionKey) {
1516
logger.error('Mnemonic not provided');

src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Command } from 'commander';
22
import { config } from 'dotenv';
3-
config();
3+
config({ quiet: true });
44

55
import * as commands from './Commands';
66

0 commit comments

Comments
 (0)