Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 1b09363

Browse files
authored
refactor: remove DI and the pub sub client from GW service (#84)
1 parent 18294b4 commit 1b09363

File tree

5 files changed

+83
-200
lines changed

5 files changed

+83
-200
lines changed

libs/common/src/constants.ts

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,44 +30,3 @@ export const ENDPOINTS = {
3030
} as const;
3131

3232
Object.freeze(ENDPOINTS);
33-
34-
/**
35-
* Interface representing configuration for the gateway service
36-
*/
37-
export interface GatewayServiceConfig {
38-
auth: string;
39-
amqpHost: string;
40-
debug: boolean;
41-
shardCount: number | 'auto';
42-
startingShard: number;
43-
totalShardCount: number | 'auto';
44-
ws: {
45-
compress: boolean;
46-
encoding: 'json' | 'etf';
47-
timeouts: {
48-
open: number;
49-
hello: number;
50-
ready: number;
51-
guild: number;
52-
reconnect: number;
53-
};
54-
largeThreshold: number;
55-
intents: string[];
56-
};
57-
}
58-
59-
/**
60-
* Injection tokens used by the gateway service
61-
*/
62-
export const GATEWAY_INJECTION_TOKENS = {
63-
kConfig: Symbol('parsed configuration options'),
64-
amqp: {
65-
kChannel: Symbol('amqp channel object'),
66-
kConnection: Symbol('amqp connection object'),
67-
kService: Symbol('RoutingServer instance for distributing the incoming packets'),
68-
kCommandsServer: Symbol('"server" recieving payloads (called commands) to send to Discord')
69-
},
70-
kCluster: Symbol('Cluster instance')
71-
} as const;
72-
73-
Object.freeze(GATEWAY_INJECTION_TOKENS);

pnpm-lock.yaml

Lines changed: 8 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/gateway/package.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,15 @@
2222
},
2323
"homepage": "https://github.com/cordis-lib/cordis#readme",
2424
"devDependencies": {
25+
"@cordis/common": "workspace:^0.3.0",
2526
"@types/node": "^14.14.44",
2627
"@types/yargs": "^15.0.13",
27-
"discord-api-types": "^0.12.1",
2828
"typescript": "^4.2.4"
2929
},
3030
"dependencies": {
3131
"@cordis/brokers": "workspace:^0.3.0",
32-
"@cordis/common": "workspace:^0.3.0",
3332
"@cordis/gateway": "workspace:^0.3.0",
34-
"erlpack": "github:discord/erlpack",
35-
"reflect-metadata": "^0.1.13",
3633
"tslib": "^2.2.0",
37-
"tsyringe": "^4.5.0",
38-
"yargs": "^15.4.1",
39-
"zlib-sync": "^0.1.7"
34+
"yargs": "^15.4.1"
4035
}
4136
}

services/gateway/src/args.ts

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
import * as yargs from 'yargs';
2+
import type { IntentKeys } from '@cordis/gateway';
23

3-
export default yargs
4-
.env('CORDIS')
4+
export interface GatewayServiceConfig {
5+
auth: string;
6+
amqpHost: string;
7+
debug: boolean;
8+
shardCount: number | 'auto';
9+
startingShard: number;
10+
totalShardCount: number | 'auto';
11+
ws: {
12+
compress: boolean;
13+
encoding: 'json' | 'etf';
14+
timeouts: {
15+
open: number;
16+
hello: number;
17+
ready: number;
18+
guild: number;
19+
reconnect: number;
20+
};
21+
largeThreshold: number;
22+
intents: IntentKeys[];
23+
};
24+
}
25+
26+
const { argv } = yargs
527
.option('auth', {
628
global: true,
729
description: 'The token used to identify to Discord',
@@ -102,5 +124,28 @@ export default yargs
102124
'demandOption': false,
103125
'default': ['nonPrivileged']
104126
})
105-
.help()
106-
.argv;
127+
.help();
128+
129+
const config: GatewayServiceConfig = {
130+
auth: argv.auth,
131+
amqpHost: argv['amqp-host'],
132+
debug: argv.debug,
133+
shardCount: argv['shard-count'],
134+
startingShard: argv['starting-shard'],
135+
totalShardCount: argv['total-shard-count'],
136+
ws: {
137+
compress: argv['ws-compress'],
138+
encoding: argv['ws-encoding'] as 'json' | 'etf',
139+
timeouts: {
140+
open: argv['ws-open-timeout'],
141+
hello: argv['ws-hello-timeout'],
142+
ready: argv['ws-ready-timeout'],
143+
guild: argv['ws-guild-timeout'],
144+
reconnect: argv['ws-reconnect-timeout']
145+
},
146+
largeThreshold: argv['ws-large-threshold'],
147+
intents: argv['ws-intents'] as IntentKeys[]
148+
}
149+
};
150+
151+
export default config;

0 commit comments

Comments
 (0)