Skip to content

Commit f9bc07b

Browse files
committed
style: runs prettier
1 parent ffe6bd1 commit f9bc07b

File tree

25 files changed

+259
-188
lines changed

25 files changed

+259
-188
lines changed

packages/amqp-connector/src/errors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class AMQPConnectorError extends Error {
1313
/**
1414
* Error thrown when the queue is not specified.
1515
* @class QueueNotSpecifiedError
16-
* @extends AMQPConnectorError
16+
* @extends AMQPConnectorError
1717
*/
1818
export class ExchangeNotSpecifiedError extends AMQPConnectorError {
1919
constructor() {
@@ -25,7 +25,7 @@ export class ExchangeNotSpecifiedError extends AMQPConnectorError {
2525
/**
2626
* Error thrown when the queue is not specified.
2727
* @class QueueNotSpecifiedError
28-
* @extends AMQPConnectorError
28+
* @extends AMQPConnectorError
2929
*/
3030
export class QueueNotSpecifiedError extends AMQPConnectorError {
3131
constructor() {

packages/amqp-connector/src/types.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import { type Channel, type ConsumeMessage } from 'amqplib'
1111
* @returns void
1212
*/
1313
export interface AmqpConfig {
14-
host: string;
15-
port: number;
16-
vhost: string;
17-
username: string;
18-
password: string;
19-
tls?: boolean;
14+
host: string
15+
port: number
16+
vhost: string
17+
username: string
18+
password: string
19+
tls?: boolean
2020
}
2121

2222
/**
@@ -25,4 +25,7 @@ export interface AmqpConfig {
2525
* @param channel - The channel the message was received on
2626
* @returns void
2727
*/
28-
export type MessageHandler = (msg: ConsumeMessage, channel: Channel) => Promise<void> | void
28+
export type MessageHandler = (
29+
msg: ConsumeMessage,
30+
channel: Channel
31+
) => Promise<void> | void

packages/common-settings/src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ export class CouldNotParseMessageError extends CommonSettingsError {
8080
super('Could not parse message')
8181
this.name = 'CouldNotParseMessageError'
8282
}
83-
}
83+
}

packages/common-settings/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ export class CommonSettingsService {
146146
updatePayload = { displayName, avatarUrl }
147147
} else {
148148
const { settings: oldConfig, version } = userSettings
149-
this.logger.info(`[CommonSettingsService] Comparing with existing version ${version}`, { userId });
149+
this.logger.info(
150+
`[CommonSettingsService] Comparing with existing version ${version}`,
151+
{ userId }
152+
)
150153

151154
if (oldConfig.display_name !== displayName) {
152155
updatePayload.displayName = displayName

packages/common-settings/src/types.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ export interface UserInformationPayload {
55

66
interface SettingsPayload {
77
language?: string
8-
timezone?: string
9-
avatar?: string
10-
last_name?: string
11-
first_name?: string
12-
email?: string
13-
phone?: string
14-
matrix_id?: string
15-
display_name?: string
8+
timezone?: string
9+
avatar?: string
10+
last_name?: string
11+
first_name?: string
12+
email?: string
13+
phone?: string
14+
matrix_id?: string
15+
display_name?: string
1616
}
1717

1818
export interface CommonSettingsMessage {

packages/config-parser/src/index.test.ts

Lines changed: 55 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ describe('twakeConfig - Basic Cases', () => {
131131
})
132132
})
133133

134-
const res: Configuration = twakeConfig(
135-
createTestConfigDesc(),
136-
mockFilePath
137-
)
134+
const res: Configuration = twakeConfig(createTestConfigDesc(), mockFilePath)
138135
expect(res).toEqual({
139136
STRING_KEY: 'fileString',
140137
NUMBER_KEY: 200,
@@ -392,16 +389,16 @@ describe('twakeConfig - Hard Cases (Complex Coercion & Defaults)', () => {
392389
test('Array coercion with empty string items', () => {
393390
process.env.ARRAY_KEY = 'item1,,item2'
394391

395-
396392
const res = twakeConfig(createTestConfigDesc(), undefined, true)
397393
expect(res.ARRAY_KEY).toEqual(['item1', 'item2'])
398394

399-
400395
process.env.ARRAY_KEY = ''
401-
expect(() => twakeConfig(createTestConfigDesc(), undefined, true))
402-
.toThrow(ConfigCoercionError)
403-
expect(() => twakeConfig(createTestConfigDesc(), undefined, true))
404-
.toThrow(/Empty string values are not allowed/)
396+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
397+
ConfigCoercionError
398+
)
399+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
400+
/Empty string values are not allowed/
401+
)
405402
})
406403

407404
test('Default value is a string but needs coercion to target type', async () => {
@@ -475,11 +472,13 @@ describe('twakeConfig - Edge Cases and Error Handling', () => {
475472
test('Should throw ConfigCoercionError if environment variable is empty string', () => {
476473
process.env.STRING_KEY = ''
477474

478-
expect(() => twakeConfig(createTestConfigDesc(), undefined, true))
479-
.toThrow(ConfigCoercionError)
475+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
476+
ConfigCoercionError
477+
)
480478

481-
expect(() => twakeConfig(createTestConfigDesc(), undefined, true))
482-
.toThrow(/Empty string values are not allowed/)
479+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
480+
/Empty string values are not allowed/
481+
)
483482
})
484483

485484
test('Should fall back to default if environment variable is null/undefined (not set)', () => {
@@ -497,13 +496,13 @@ describe('twakeConfig - Edge Cases and Error Handling', () => {
497496
UNWANTED_KEY_FROM_OBJECT: 'bad'
498497
}
499498

500-
expect(() => twakeConfig(createTestConfigDesc(), initialConfig))
501-
.toThrow(UnacceptedKeyError)
499+
expect(() => twakeConfig(createTestConfigDesc(), initialConfig)).toThrow(
500+
UnacceptedKeyError
501+
)
502502

503-
expect(() => twakeConfig(createTestConfigDesc(), initialConfig))
504-
.toThrow(
505-
"Configuration key 'UNWANTED_KEY_FROM_OBJECT' isn't accepted as it's not defined in the ConfigDescription."
506-
)
503+
expect(() => twakeConfig(createTestConfigDesc(), initialConfig)).toThrow(
504+
"Configuration key 'UNWANTED_KEY_FROM_OBJECT' isn't accepted as it's not defined in the ConfigDescription."
505+
)
507506
})
508507

509508
test('Should throw UnacceptedKeyError for unwanted key in defaultConfigurationFile (JSON file)', () => {
@@ -514,96 +513,86 @@ describe('twakeConfig - Edge Cases and Error Handling', () => {
514513
unwanted_value: 'bad'
515514
})
516515
})
517-
expect(
518-
() => twakeConfig(createTestConfigDesc(), mockFilePath)
519-
).toThrow(UnacceptedKeyError)
520-
expect(
521-
() => twakeConfig(createTestConfigDesc(), mockFilePath)
522-
).toThrow(
516+
expect(() => twakeConfig(createTestConfigDesc(), mockFilePath)).toThrow(
517+
UnacceptedKeyError
518+
)
519+
expect(() => twakeConfig(createTestConfigDesc(), mockFilePath)).toThrow(
523520
"Configuration key 'unwanted_value' isn't accepted as it's not defined in the ConfigDescription."
524521
)
525522
})
526523

527524
test('Should throw ConfigCoercionError for invalid boolean format from environment variable', () => {
528525
process.env.BOOLEAN_KEY = 'not_a_boolean'
529-
expect(
530-
() => twakeConfig(createTestConfigDesc(), undefined, true)
531-
).toThrow(ConfigCoercionError)
532-
expect(
533-
() => twakeConfig(createTestConfigDesc(), undefined, true)
534-
).toThrow(
526+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
527+
ConfigCoercionError
528+
)
529+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
535530
/Configuration error for 'BOOLEAN_KEY' from environment variable 'BOOLEAN_KEY': Invalid boolean format for value: 'not_a_boolean'/
536531
)
537532
})
538533

539534
test('Should throw ConfigCoercionError for invalid number format from environment variable', () => {
540535
process.env.NUMBER_KEY = 'not_a_number'
541-
expect(
542-
() => twakeConfig(createTestConfigDesc(), undefined, true)
543-
).toThrow(ConfigCoercionError)
544-
expect(
545-
() => twakeConfig(createTestConfigDesc(), undefined, true)
546-
).toThrow(
536+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
537+
ConfigCoercionError
538+
)
539+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
547540
/Configuration error for 'NUMBER_KEY' from environment variable 'NUMBER_KEY': Invalid number format for value: 'not_a_number'/
548541
)
549542
})
550543

551544
test('Should throw ConfigCoercionError for invalid JSON format from environment variable (JSON type)', () => {
552545
process.env.JSON_KEY = '{invalid json'
553-
expect(
554-
() => twakeConfig(createTestConfigDesc(), undefined, true)
555-
).toThrow(ConfigCoercionError)
556-
expect(
557-
() => twakeConfig(createTestConfigDesc(), undefined, true)
558-
).toThrow(
546+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
547+
ConfigCoercionError
548+
)
549+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
559550
/Configuration error for 'JSON_KEY' from environment variable 'JSON_KEY': Invalid JSON format for value: '\{invalid json'/
560551
)
561552
})
562553

563554
test('Should throw ConfigCoercionError for invalid JSON format from environment variable (OBJECT type)', () => {
564555
process.env.OBJECT_KEY = 'invalid object json'
565-
expect(
566-
() => twakeConfig(createTestConfigDesc(), undefined, true)
567-
).toThrow(ConfigCoercionError)
568-
expect(
569-
() => twakeConfig(createTestConfigDesc(), undefined, true)
570-
).toThrow(
556+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
557+
ConfigCoercionError
558+
)
559+
expect(() => twakeConfig(createTestConfigDesc(), undefined, true)).toThrow(
571560
/Configuration error for 'OBJECT_KEY' from environment variable 'OBJECT_KEY': Invalid JSON format for value: 'invalid object json'/
572561
)
573562
})
574563

575564
test('Should throw FileReadParseError if config file is not found', () => {
576565
const nonExistentPath = 'non_existent_config.json'
577566

578-
; (fs.existsSync as jest.Mock).mockReturnValue(false)
579-
; (fs.promises.readFile as jest.Mock).mockImplementation(() => {
580-
const error = new Error(
581-
`ENOENT: no such file or directory, open '${nonExistentPath}'`
582-
)
583-
; (error as any).code = 'ENOENT'
584-
throw error
585-
})
567+
;(fs.existsSync as jest.Mock).mockReturnValue(false)
568+
;(fs.promises.readFile as jest.Mock).mockImplementation(() => {
569+
const error = new Error(
570+
`ENOENT: no such file or directory, open '${nonExistentPath}'`
571+
)
572+
;(error as any).code = 'ENOENT'
573+
throw error
574+
})
586575

587-
expect(() => twakeConfig(createTestConfigDesc(), nonExistentPath))
588-
.toThrow(FileReadParseError)
576+
expect(() => twakeConfig(createTestConfigDesc(), nonExistentPath)).toThrow(
577+
FileReadParseError
578+
)
589579

590580
expect(consoleWarnSpy).not.toHaveBeenCalled()
591581
})
592582

593-
594583
test('Should throw FileReadParseError if config file contains invalid JSON', () => {
595584
const invalidJsonPath = 'invalid.json'
596585
setupMockFs({
597586
[invalidJsonPath]: '{ "key": "value", "another": }'
598587
})
599588

600-
expect(() => twakeConfig(createTestConfigDesc(), invalidJsonPath))
601-
.toThrow(FileReadParseError)
589+
expect(() => twakeConfig(createTestConfigDesc(), invalidJsonPath)).toThrow(
590+
FileReadParseError
591+
)
602592

603593
expect(consoleWarnSpy).not.toHaveBeenCalled()
604594
})
605595

606-
607596
test('Should handle null default values correctly', async () => {
608597
const res: Configuration = twakeConfig(createTestConfigDesc())
609598
expect(res.NULL_KEY).toBeNull()
@@ -632,11 +621,7 @@ describe('twakeConfig - Edge Cases and Error Handling', () => {
632621
MY_REQUIRED_KEY: { type: 'string', required: true }
633622
}
634623
process.env.MY_REQUIRED_KEY = 'present'
635-
const res: Configuration = twakeConfig(
636-
descWithRequired,
637-
undefined,
638-
true
639-
)
624+
const res: Configuration = twakeConfig(descWithRequired, undefined, true)
640625
expect(res.MY_REQUIRED_KEY).toBe('present')
641626
})
642627

@@ -651,4 +636,4 @@ describe('twakeConfig - Edge Cases and Error Handling', () => {
651636
const res: Configuration = twakeConfig(descWithRequired)
652637
expect(res.MY_REQUIRED_KEY).toBe('default_value')
653638
})
654-
})
639+
})

packages/config-parser/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ const twakeConfig = (
215215
// Determine if we should use the old parser
216216
const shouldUseOldParser =
217217
useOldParser && process.env.TWAKE_CONFIG_PARSER_NEW == null
218-
218+
219219
// Start with an empty config
220220
let config: Configuration = {}
221221

packages/config-parser/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export type OldConfigDescription = Record<
5353
*/
5454
export type ConfigDescription = NewConfigDescription | OldConfigDescription
5555

56-
5756
/**
5857
* Defines the possible types for the default configuration file input.
5958
* It can be an object representing configuration or a file path.

packages/logger/src/index.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ describe('Logger', () => {
4141
)
4242
.toString()
4343
)
44-
expect(() => getLogger(conf)).toThrow("Configuration key 'falsy' isn't accepted as it's not defined in the ConfigDescription.")
44+
expect(() => getLogger(conf)).toThrow(
45+
"Configuration key 'falsy' isn't accepted as it's not defined in the ConfigDescription."
46+
)
4547
})
4648

4749
it('should throw an error if log_level is not a string', () => {
@@ -1394,8 +1396,8 @@ describe('Logger', () => {
13941396
logging: {
13951397
...confDesc.logging,
13961398
log_transports: {
1397-
type: "array",
1398-
required: false,
1399+
type: 'array',
1400+
required: false
13991401
}
14001402
}
14011403
}
@@ -1524,11 +1526,11 @@ describe('Logger', () => {
15241526
logging: {
15251527
...confDesc.logging,
15261528
rejection_handlers: {
1527-
type: "array",
1529+
type: 'array',
15281530
required: false
15291531
},
15301532
exception_handlers: {
1531-
type: "array",
1533+
type: 'array',
15321534
required: false
15331535
}
15341536
}
@@ -1569,11 +1571,11 @@ describe('Logger', () => {
15691571
logging: {
15701572
...confDesc.logging,
15711573
rejection_handlers: {
1572-
type: "array",
1574+
type: 'array',
15731575
required: false
15741576
},
15751577
exception_handlers: {
1576-
type: "array",
1578+
type: 'array',
15771579
required: false
15781580
}
15791581
}

packages/logger/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ export const getLogger = (
1919
confDesc ??
2020
defaultConfDesc.logging
2121
// Parsing the configuration using the new config parser with using environment variables enabled
22-
const loggingConf = configParser(confDesc, getConfigurationFile(conf), true, false)
22+
const loggingConf = configParser(
23+
confDesc,
24+
getConfigurationFile(conf),
25+
true,
26+
false
27+
)
2328
return createLogger(
2429
new TwakeLoggerOptions(loggingConf).convertToWinstonLoggerOptions()
2530
)

0 commit comments

Comments
 (0)