chore: apply code fixes with biome

This commit is contained in:
PalmDevs
2023-11-28 22:03:41 +07:00
parent c80bd068fa
commit f2d85c32a4
32 changed files with 1384 additions and 1383 deletions

View File

@@ -1,27 +1,27 @@
/**
* Disconnect reasons for clients
*/
enum DisconnectReason {
/**
* Unknown reason
*/
Generic = 1,
/**
* The client did not respond in time
*/
TimedOut,
/**
* The client sent an invalid packet (unserializable or invalid JSON)
*/
InvalidPacket,
/**
* The server has encountered an internal error
*/
ServerError,
/**
* The client had never connected to the server (**CLIENT-ONLY**)
*/
NeverConnected,
}
export default DisconnectReason
/**
* Disconnect reasons for clients
*/
enum DisconnectReason {
/**
* Unknown reason
*/
Generic = 1,
/**
* The client did not respond in time
*/
TimedOut = 2,
/**
* The client sent an invalid packet (unserializable or invalid JSON)
*/
InvalidPacket = 3,
/**
* The server has encountered an internal error
*/
ServerError = 4,
/**
* The client had never connected to the server (**CLIENT-ONLY**)
*/
NeverConnected = 5,
}
export default DisconnectReason

View File

@@ -1,15 +1,15 @@
import DisconnectReason from './DisconnectReason.js'
/**
* Humanized disconnect reasons for logs
*/
const HumanizedDisconnectReason = {
[DisconnectReason.InvalidPacket]: 'has sent invalid packet',
[DisconnectReason.Generic]: 'has been disconnected for unknown reasons',
[DisconnectReason.TimedOut]: 'has timed out',
[DisconnectReason.ServerError]:
'has been disconnected due to an internal server error',
[DisconnectReason.NeverConnected]: 'had never connected to the server',
} as const satisfies Record<DisconnectReason, string>
export default HumanizedDisconnectReason
import DisconnectReason from './DisconnectReason.js'
/**
* Humanized disconnect reasons for logs
*/
const HumanizedDisconnectReason = {
[DisconnectReason.InvalidPacket]: 'has sent invalid packet',
[DisconnectReason.Generic]: 'has been disconnected for unknown reasons',
[DisconnectReason.TimedOut]: 'has timed out',
[DisconnectReason.ServerError]:
'has been disconnected due to an internal server error',
[DisconnectReason.NeverConnected]: 'had never connected to the server',
} as const satisfies Record<DisconnectReason, string>
export default HumanizedDisconnectReason

View File

@@ -1,57 +1,57 @@
/**
* Client operation codes for the gateway
*/
export enum ClientOperation {
/**
* Client's heartbeat (to check if the connection is dead or not)
*/
Heartbeat = 100,
/**
* Client's request to parse text
*/
ParseText = 110,
/**
* Client's request to parse image
*/
ParseImage,
}
/**
* Server operation codes for the gateway
*/
export enum ServerOperation {
/**
* Server's acknowledgement of a client's heartbeat
*/
HeartbeatAck = 1,
/**
* Server's initial response to a client's connection
*/
Hello,
/**
* Server's response to client's request to parse text
*/
ParsedText = 10,
/**
* Server's response to client's request to parse image
*/
ParsedImage,
/**
* Server's failure response to client's request to parse text
*/
ParseTextFailed,
/**
* Server's failure response to client's request to parse image
*/
ParseImageFailed,
/**
* Server's disconnect message
*/
Disconnect = 20,
}
export const Operation = { ...ClientOperation, ...ServerOperation } as const
export type Operation = ClientOperation | ServerOperation
/**
* Client operation codes for the gateway
*/
export enum ClientOperation {
/**
* Client's heartbeat (to check if the connection is dead or not)
*/
Heartbeat = 100,
/**
* Client's request to parse text
*/
ParseText = 110,
/**
* Client's request to parse image
*/
ParseImage = 111,
}
/**
* Server operation codes for the gateway
*/
export enum ServerOperation {
/**
* Server's acknowledgement of a client's heartbeat
*/
HeartbeatAck = 1,
/**
* Server's initial response to a client's connection
*/
Hello = 2,
/**
* Server's response to client's request to parse text
*/
ParsedText = 10,
/**
* Server's response to client's request to parse image
*/
ParsedImage = 11,
/**
* Server's failure response to client's request to parse text
*/
ParseTextFailed = 12,
/**
* Server's failure response to client's request to parse image
*/
ParseImageFailed = 13,
/**
* Server's disconnect message
*/
Disconnect = 20,
}
export const Operation = { ...ClientOperation, ...ServerOperation } as const
export type Operation = ClientOperation | ServerOperation

View File

@@ -1,3 +1,3 @@
export { default as DisconnectReason } from './DisconnectReason.js'
export { default as HumanizedDisconnectReason } from './HumanizedDisconnectReason.js'
export * from './Operation.js'
export { default as DisconnectReason } from './DisconnectReason.js'
export { default as HumanizedDisconnectReason } from './HumanizedDisconnectReason.js'
export * from './Operation.js'