Skip to content

Commit 7f915cb

Browse files
fix: eslint action error
1 parent 9aff3b6 commit 7f915cb

File tree

2 files changed

+93
-93
lines changed

2 files changed

+93
-93
lines changed

packages/api-cardano-db-hasura/src/MetadataClient.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class MetadataClient {
1212
private axiosClient: AxiosInstance
1313
public state: RunnableModuleState
1414

15-
constructor(
15+
constructor (
1616
enabled = false,
1717
private metadataServerUri: string,
1818
private logger: Logger = dummyLogger
@@ -29,7 +29,7 @@ export class MetadataClient {
2929
}
3030
}
3131

32-
private async ensureLocalMetadataServerIsAvailable(): Promise<void> {
32+
private async ensureLocalMetadataServerIsAvailable (): Promise<void> {
3333
if (!this.enabled) return
3434
await pRetry(
3535
async () => {
@@ -47,13 +47,13 @@ export class MetadataClient {
4747
}
4848
}
4949
}, {
50-
factor: 1.5,
51-
retries: 10
52-
}
50+
factor: 1.5,
51+
retries: 10
52+
}
5353
)
5454
}
5555

56-
private async waitForLocalMetadataServerSynced(): Promise<void> {
56+
private async waitForLocalMetadataServerSynced (): Promise<void> {
5757
if (!this.enabled) return
5858
await pRetry(
5959
async () => {
@@ -71,14 +71,14 @@ export class MetadataClient {
7171
}
7272
}
7373
}, {
74-
factor: 1.5,
75-
retries: 1000,
76-
minTimeout: 60000 // first try after one minute
77-
}
74+
factor: 1.5,
75+
retries: 1000,
76+
minTimeout: 60000 // first try after one minute
77+
}
7878
)
7979
}
8080

81-
public async fetch(assetIds: Asset['assetId'][]): Promise<AssetMetadata[]> {
81+
public async fetch (assetIds: Asset['assetId'][]): Promise<AssetMetadata[]> {
8282
if (!this.enabled) {
8383
this.logger.debug({ module: MODULE_NAME }, 'Skipping metadata fetch — client disabled.')
8484
return []
@@ -108,7 +108,7 @@ export class MetadataClient {
108108
}
109109
}
110110

111-
public async initialize() {
111+
public async initialize () {
112112
if (!this.enabled) {
113113
this.logger.info({ module: MODULE_NAME }, 'Skipping initialization — MetadataClient disabled.')
114114
this.state = 'initialized'
Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import { createLogger, LogLevelString } from "bunyan";
1+
import { createLogger, LogLevelString } from 'bunyan'
22
import {
33
ChainFollower,
44
Db,
55
HasuraBackgroundClient,
66
MetadataClient,
7-
Worker,
8-
} from "./index";
9-
import onDeath from "death";
10-
import { Logger } from "ts-log";
11-
import { CustomError } from "ts-custom-error";
12-
import fs from "fs-extra";
13-
import { DbConfig } from "./typeAliases";
14-
import { PointOrOrigin } from "@cardano-ogmios/schema";
7+
Worker
8+
} from './index'
9+
import onDeath from 'death'
10+
import { Logger } from 'ts-log'
11+
import { CustomError } from 'ts-custom-error'
12+
import fs from 'fs-extra'
13+
import { DbConfig } from './typeAliases'
14+
import { PointOrOrigin } from '@cardano-ogmios/schema'
1515
// Todo: Hoist to util package next major version
1616
export class MissingConfig extends CustomError {
17-
public constructor(message: string) {
18-
super();
19-
this.message = message;
17+
public constructor (message: string) {
18+
super()
19+
this.message = message
2020
}
2121
}
2222

@@ -41,74 +41,74 @@ export interface BackgroundConfig {
4141
};
4242
}
4343

44-
async function getConfig(): Promise<BackgroundConfig> {
45-
const env = filterAndTypecastEnvs(process.env);
44+
async function getConfig (): Promise<BackgroundConfig> {
45+
const env = filterAndTypecastEnvs(process.env)
4646
if (!env.hasuraCliPath) {
47-
throw new MissingConfig("HASURA_CLI_PATH env not set");
47+
throw new MissingConfig('HASURA_CLI_PATH env not set')
4848
}
4949
if (!env.hasuraCliExtPath) {
50-
throw new MissingConfig("HASURA_CLI_EXT_PATH env not set");
50+
throw new MissingConfig('HASURA_CLI_EXT_PATH env not set')
5151
}
5252
if (!env.hasuraUri) {
53-
throw new MissingConfig("HASURA_URI env not set");
53+
throw new MissingConfig('HASURA_URI env not set')
5454
}
5555
if (!env.metadataServerUri) {
56-
throw new MissingConfig("METADATA_SERVER_URI env not set");
56+
throw new MissingConfig('METADATA_SERVER_URI env not set')
5757
}
5858
if (!env.postgres.dbFile && !env.postgres.db) {
59-
throw new MissingConfig("POSTGRES_DB_FILE or POSTGRES_DB env not set");
59+
throw new MissingConfig('POSTGRES_DB_FILE or POSTGRES_DB env not set')
6060
}
6161
if (!env.postgres.host) {
62-
throw new MissingConfig("POSTGRES_HOST env not set");
62+
throw new MissingConfig('POSTGRES_HOST env not set')
6363
}
6464
if (!env.postgres.passwordFile && !env.postgres.password) {
6565
throw new MissingConfig(
66-
"POSTGRES_PASSWORD_FILE or POSTGRES_PASSWORD env not set",
67-
);
66+
'POSTGRES_PASSWORD_FILE or POSTGRES_PASSWORD env not set'
67+
)
6868
}
6969
if (!env.postgres.port) {
70-
throw new MissingConfig("POSTGRES_PORT env not set");
70+
throw new MissingConfig('POSTGRES_PORT env not set')
7171
}
7272
if (!env.postgres.userFile && !env.postgres.user) {
73-
throw new MissingConfig("POSTGRES_USER_FILE or POSTGRES_USER env not set");
73+
throw new MissingConfig('POSTGRES_USER_FILE or POSTGRES_USER env not set')
7474
}
75-
let db: BackgroundConfig["db"];
75+
let db: BackgroundConfig['db']
7676
try {
7777
db = {
7878
database:
7979
env.postgres.db ||
80-
(await fs.readFile(env.postgres.dbFile, "utf8")).toString().trim(),
80+
(await fs.readFile(env.postgres.dbFile, 'utf8')).toString().trim(),
8181
host: env.postgres.host,
8282
password:
8383
env.postgres.password ||
84-
(await fs.readFile(env.postgres.passwordFile, "utf8"))
84+
(await fs.readFile(env.postgres.passwordFile, 'utf8'))
8585
.toString()
8686
.trim(),
8787
port: env.postgres.port,
8888
user:
8989
env.postgres.user ||
90-
(await fs.readFile(env.postgres.userFile, "utf8")).toString().trim(),
91-
};
90+
(await fs.readFile(env.postgres.userFile, 'utf8')).toString().trim()
91+
}
9292
} catch (error) {
93-
throw new MissingConfig("Database configuration cannot be read");
93+
throw new MissingConfig('Database configuration cannot be read')
9494
}
95-
let chainfollower;
95+
let chainfollower
9696
if (env.chainfollower) {
9797
chainfollower = {
9898
id: env.chainfollower.id,
99-
slot: env.chainfollower.slot,
100-
};
99+
slot: env.chainfollower.slot
100+
}
101101
}
102-
const { postgres, ...selectedEnv } = env;
102+
const { postgres, ...selectedEnv } = env
103103
return {
104104
...selectedEnv,
105105
db,
106106
chainfollower,
107-
loggerMinSeverity: env.loggerMinSeverity || ("info" as LogLevelString),
108-
};
107+
loggerMinSeverity: env.loggerMinSeverity || ('info' as LogLevelString)
108+
}
109109
}
110110

111-
function filterAndTypecastEnvs(env: any) {
111+
function filterAndTypecastEnvs (env: any) {
112112
const {
113113
COMPOSE_PROFILES,
114114
ASSET_METADATA_UPDATE_INTERVAL,
@@ -128,8 +128,8 @@ function filterAndTypecastEnvs(env: any) {
128128
POSTGRES_USER,
129129
POSTGRES_USER_FILE,
130130
CHAIN_FOLLOWER_START_ID,
131-
CHAIN_FOLLOWER_START_SLOT,
132-
} = env as NodeJS.ProcessEnv;
131+
CHAIN_FOLLOWER_START_SLOT
132+
} = env as NodeJS.ProcessEnv
133133
return {
134134
composeProfiles: COMPOSE_PROFILES,
135135
hasuraCliPath: HASURA_CLI_PATH,
@@ -140,11 +140,11 @@ function filterAndTypecastEnvs(env: any) {
140140
metadataUpdateInterval: {
141141
assets: ASSET_METADATA_UPDATE_INTERVAL
142142
? Number(ASSET_METADATA_UPDATE_INTERVAL)
143-
: undefined,
143+
: undefined
144144
},
145145
ogmios: {
146146
host: OGMIOS_HOST,
147-
port: OGMIOS_PORT ? Number(OGMIOS_PORT) : undefined,
147+
port: OGMIOS_PORT ? Number(OGMIOS_PORT) : undefined
148148
},
149149
postgres: {
150150
db: POSTGRES_DB,
@@ -154,86 +154,86 @@ function filterAndTypecastEnvs(env: any) {
154154
passwordFile: POSTGRES_PASSWORD_FILE,
155155
port: POSTGRES_PORT ? Number(POSTGRES_PORT) : undefined,
156156
user: POSTGRES_USER,
157-
userFile: POSTGRES_USER_FILE,
157+
userFile: POSTGRES_USER_FILE
158158
},
159159
chainfollower: {
160160
id: CHAIN_FOLLOWER_START_ID,
161161
slot: CHAIN_FOLLOWER_START_SLOT
162162
? Number(CHAIN_FOLLOWER_START_SLOT)
163-
: undefined,
164-
},
165-
};
163+
: undefined
164+
}
165+
}
166166
}
167167

168-
(async function() {
169-
const config = await getConfig();
168+
(async function () {
169+
const config = await getConfig()
170170
const logger: Logger = createLogger({
171-
name: "background",
172-
level: config.loggerMinSeverity,
173-
});
171+
name: 'background',
172+
level: config.loggerMinSeverity
173+
})
174174
try {
175175
const hasuraBackgroundClient = new HasuraBackgroundClient(
176176
config.hasuraCliPath,
177177
config.hasuraCliExtPath,
178178
config.hasuraUri,
179-
logger,
180-
);
179+
logger
180+
)
181181
const chainFollower = new ChainFollower(
182182
hasuraBackgroundClient,
183183
logger,
184-
config.db,
185-
);
184+
config.db
185+
)
186186

187187
const isTokenRegistryEnabled =
188188
config.composeProfiles &&
189-
config.composeProfiles.split(",").includes("token-registry");
189+
config.composeProfiles.split(',').includes('token-registry')
190190

191-
const metadataClient = new MetadataClient(isTokenRegistryEnabled, config.metadataServerUri, logger);
191+
const metadataClient = new MetadataClient(isTokenRegistryEnabled, config.metadataServerUri, logger)
192192
const worker = new Worker(
193193
hasuraBackgroundClient,
194194
logger,
195195
metadataClient,
196196
config.db,
197197
{
198198
metadataUpdateInterval: {
199-
assets: config.metadataUpdateInterval?.assets,
200-
},
201-
},
202-
);
203-
const db = new Db(config.db, logger);
199+
assets: config.metadataUpdateInterval?.assets
200+
}
201+
}
202+
)
203+
const db = new Db(config.db, logger)
204204
const getChainSyncPoints = async (): Promise<PointOrOrigin[]> => {
205205
const mostRecentPoint =
206-
await hasuraBackgroundClient.getMostRecentPointWithNewAsset();
206+
await hasuraBackgroundClient.getMostRecentPointWithNewAsset()
207207
return mostRecentPoint !== null
208-
? [mostRecentPoint, "origin"]
209-
: ["origin"];
210-
};
208+
? [mostRecentPoint, 'origin']
209+
: ['origin']
210+
}
211211
await db.init({
212212
onDbInit: () => hasuraBackgroundClient.shutdown(),
213213
onDbSetup: async () => {
214214
try {
215-
await hasuraBackgroundClient.initialize();
216-
await metadataClient.initialize();
217-
await chainFollower.initialize(config.ogmios, getChainSyncPoints);
218-
await worker.start();
219-
await chainFollower.start(await getChainSyncPoints());
215+
await hasuraBackgroundClient.initialize()
216+
await metadataClient.initialize()
217+
await chainFollower.initialize(config.ogmios, getChainSyncPoints)
218+
await worker.start()
219+
await chainFollower.start(await getChainSyncPoints())
220220
} catch (error) {
221-
logger.error(error.message);
222-
process.exit(1);
221+
logger.error(error.message)
222+
process.exit(1)
223223
}
224-
},
225-
});
224+
}
225+
})
226226
onDeath(async () => {
227227
await Promise.all([
228228
hasuraBackgroundClient.shutdown,
229229
worker.shutdown,
230230
chainFollower.shutdown,
231-
db.shutdown,
232-
]);
233-
process.exit(1);
234-
});
231+
db.shutdown
232+
])
233+
process.exit(1)
234+
})
235235
} catch (error) {
236-
logger.error("Exiting due to uncaught exception", error.message);
237-
process.exit(1);
236+
logger.error('Exiting due to uncaught exception', error.message)
237+
process.exit(1)
238238
}
239-
})();
239+
})()

0 commit comments

Comments
 (0)