Skip to content

Commit

Permalink
lint and format
Browse files Browse the repository at this point in the history
  • Loading branch information
diego-lon committed Oct 28, 2024
1 parent 2a70aa4 commit dc44c31
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 76 deletions.
4 changes: 2 additions & 2 deletions packages/kafka-producer/src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export const KafkaProducerConfig = z
const parsedFromEnv = KafkaProducerConfig.safeParse(process.env);
if (!parsedFromEnv.success) {
const invalidEnvVars = parsedFromEnv.error.issues.flatMap(
(issue) => issue.path
(issue) => issue.path,
);
// eslint-disable-next-line no-console
console.error(
"Invalid or missing env vars: Kafka Producer " + invalidEnvVars.join(", ")
"Invalid or missing env vars: Kafka Producer " + invalidEnvVars.join(", "),
);
process.exit(1);
}
Expand Down
28 changes: 14 additions & 14 deletions packages/kafka-producer/src/producer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const errorEventsListener = (consumerOrProducer: Consumer | Producer): void => {
processExit();
} catch (e) {
genericLogger.error(
`Unexpected error on disconnection with event type ${type}; Error detail: ${e}`
`Unexpected error on disconnection with event type ${type}; Error detail: ${e}`,
);
processExit();
}
Expand Down Expand Up @@ -61,14 +61,14 @@ const producerKafkaEventsListener = (producer: Producer): void => {
}
producer.on(producer.events.REQUEST_TIMEOUT, (e) => {
genericLogger.error(
`Error Request to a broker has timed out : ${JSON.stringify(e)}.`
`Error Request to a broker has timed out : ${JSON.stringify(e)}.`,
);
});
};

async function oauthBearerTokenProvider(
region: string,
logger: Logger
logger: Logger,
): Promise<OauthbearerProviderResponse> {
logger.debug("Fetching token from AWS");

Expand All @@ -77,7 +77,7 @@ async function oauthBearerTokenProvider(
});

logger.debug(
`Token fetched from AWS expires at ${authTokenResponse.expiryTime}`
`Token fetched from AWS expires at ${authTokenResponse.expiryTime}`,
);

return {
Expand Down Expand Up @@ -110,7 +110,7 @@ const initKafka = (config: KafkaProducerConfig): Kafka => {
...kafkaConfig,
logCreator:
(
_logLevel // eslint-disable-line @typescript-eslint/no-unused-vars
_logLevel, // eslint-disable-line @typescript-eslint/no-unused-vars
) =>
({ level, log }) => {
const { message, error } = log;
Expand All @@ -121,15 +121,15 @@ const initKafka = (config: KafkaProducerConfig): Kafka => {
(error) =>
(level === logLevel.ERROR || level === logLevel.WARN) &&
error.includes("The group is rebalancing, so a rejoin is needed"),
() => logLevel.INFO
() => logLevel.INFO,
)
.otherwise(() => level);

const msg = `${message}${error ? ` - ${error}` : ""}`;

match(filteredLevel)
.with(logLevel.NOTHING, logLevel.ERROR, () =>
genericLogger.error(msg)
genericLogger.error(msg),
)
.with(logLevel.WARN, () => genericLogger.warn(msg))
.with(logLevel.INFO, () => genericLogger.info(msg))
Expand All @@ -141,11 +141,11 @@ const initKafka = (config: KafkaProducerConfig): Kafka => {

export const initProducer = async (
config: KafkaProducerConfig,
topics: string
topics: string,
): Promise<
Producer & {
send: (
record: Omit<ProducerRecord, "topic"> & { topic: string }
record: Omit<ProducerRecord, "topic"> & { topic: string },
) => Promise<RecordMetadata[]>;
}
> => {
Expand Down Expand Up @@ -186,7 +186,7 @@ export const initProducer = async (
};
} catch (e) {
genericLogger.error(
`Generic error occurs during consumer initialization: ${e}`
`Generic error occurs during consumer initialization: ${e}`,
);
processExit();
return undefined as never;
Expand All @@ -195,10 +195,10 @@ export const initProducer = async (

export const validateTopicMetadata = async (
kafka: Kafka,
topicNames: string[]
topicNames: string[],
): Promise<boolean> => {
genericLogger.debug(
`Check topics |${JSON.stringify(topicNames)}| existence...`
`Check topics |${JSON.stringify(topicNames)}| existence...`,
);

const admin = kafka.admin();
Expand All @@ -215,8 +215,8 @@ export const validateTopicMetadata = async (
await admin.disconnect();
genericLogger.error(
`Unable to subscribe! Error during topic metadata fetch: ${JSON.stringify(
e
)}`
e,
)}`,
);
return false;
}
Expand Down
5 changes: 2 additions & 3 deletions packages/models/src/eservice/eservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ export const EserviceSaveRequest = z.object({
export type EserviceSaveRequest = z.infer<typeof EserviceSaveRequest>;

export const TenantSaveRequest = z.object({
tenant_id: z.string(),
tenant_name: z.string().optional(),
tenant_id: z.string(),
tenant_name: z.string().optional(),
});
export type TenantSaveRequest = z.infer<typeof TenantSaveRequest>;


/**
* Schema for EService.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ export class ModelRepository {
this.eservices = this.entityManager.getRepository(Eservice);
this.tenants = this.entityManager.getRepository(Tenant);
this.eserviceProbingRequest = this.entityManager.getRepository(
EserviceProbingRequest
EserviceProbingRequest,
);
this.eserviceProbingResponse = this.entityManager.getRepository(
EserviceProbingResponse
EserviceProbingResponse,
);
this.eserviceView = this.entityManager.getRepository(EserviceView);
}

public static async init(
config: DbConfig,
initDB: string | null = null
initDB: string | null = null,
): Promise<ModelRepository> {
if (!ModelRepository.instance) {
ModelRepository.instance = new ModelRepository(config);
Expand All @@ -114,7 +114,7 @@ export class ModelRepository {
genericLogger.info(
`Database Connection Status: ${
connectionStatus ? "Initialized" : "Not Initialized"
}`
}`,
);
}

Expand Down
Loading

0 comments on commit dc44c31

Please sign in to comment.