feat!: big feature changes

BREAKING CHANGES:
- Heartbeating removed
- `config.consoleLogLevel` -> `config.logLevel`

NEW FEATURES:
- Training messages
- Sequence number system
- WebSocket close codes used instead of disconnect packets

FIXES:
- Improved error handling
- Some performance improvements
- Made code more clean
- Updated dependencies
This commit is contained in:
PalmDevs
2024-03-28 21:41:59 +07:00
parent 77f1a9cb3e
commit b3b7723b4f
33 changed files with 562 additions and 506 deletions

View File

@@ -0,0 +1,36 @@
import { existsSync } from 'fs'
import { resolve as resolvePath } from 'path'
import { pathToFileURL } from 'url'
const configPath = resolvePath(process.cwd(), 'config.json')
const userConfig: Partial<Config> = existsSync(configPath)
? (
await import(pathToFileURL(configPath).href, {
with: {
type: 'json',
},
})
).default
: {}
type BaseTypeOf<T> = T extends (infer U)[]
? U[]
: T extends (...args: unknown[]) => infer U
? (...args: unknown[]) => U
: T extends object
? { [K in keyof T]: T[K] }
: T
export type Config = Omit<BaseTypeOf<typeof import('../../config.json')>, '$schema'>
export const defaultConfig: Config = {
address: '127.0.0.1',
port: 8080,
ocrConcurrentQueues: 1,
logLevel: 'info',
}
export function getConfig() {
return Object.assign(defaultConfig, userConfig) satisfies Config
}