Skip to content

Commit

Permalink
fix: typescript strings
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskbx committed Apr 8, 2021
1 parent 1348ef9 commit 0dd5f12
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/monitor/src/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Storage extends EventEmitter {
* Get all constant values.
*/
async all(): Promise<any> {
const data: Array<{key: String, value: any}> = []
const data: Array<{key: string, value: any}> = []
this.constant.forEach((value, key) => data.push({ key, value }))
return data
}
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Connection {
onClose: (document: Document) => null,
}

socketId: String
socketId: string

lock: AsyncLock

Expand All @@ -39,7 +39,7 @@ class Connection {
request: HTTPIncomingMessage,
document: Document,
timeout: number,
socketId: String,
socketId: string,
context: any,
) {
this.connection = connection
Expand Down
14 changes: 7 additions & 7 deletions packages/server/src/Hocuspocus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export class Hocuspocus {

documents = new Map()

connectionsByIp: Map<String, Array<number>> = new Map()
connectionsByIp: Map<string, Array<number>> = new Map()

bannedIps: Map<String, number> = new Map()
bannedIps: Map<string, number> = new Map()

httpServer?: HTTPServer

Expand Down Expand Up @@ -150,12 +150,12 @@ export class Hocuspocus {
handleConnection(incoming: WebSocket, request: IncomingMessage, context: any = null): void {

// get the remote ip address
const ip = <String>request.headers['x-real-ip']
const ip = request.headers['x-real-ip']
|| request.headers['x-forwarded-for']
|| request.socket.remoteAddress || ''

// throttle the connection
if (this.throttle(ip)) {
if (this.throttle(<string> ip)) {
return incoming.close()
}

Expand Down Expand Up @@ -193,7 +193,7 @@ export class Hocuspocus {
* Handle update of the given document
* @private
*/
private handleDocumentUpdate(document: Document, connection: Connection, update: Uint8Array, request: IncomingMessage, socketId: String): void {
private handleDocumentUpdate(document: Document, connection: Connection, update: Uint8Array, request: IncomingMessage, socketId: string): void {

const hookPayload = {
clientsCount: document.connectionsCount(),
Expand Down Expand Up @@ -256,7 +256,7 @@ export class Hocuspocus {
* Create a new connection by the given request and document
* @private
*/
private createConnection(connection: WebSocket, request: IncomingMessage, document: Document, socketId: String, context?: any): Connection {
private createConnection(connection: WebSocket, request: IncomingMessage, document: Document, socketId: string, context?: any): Connection {

const instance = new Connection(connection, request, document, this.configuration.timeout, socketId, context)

Expand Down Expand Up @@ -326,7 +326,7 @@ export class Hocuspocus {
* Throttle requests
* @private
*/
private throttle(ip: String): Boolean {
private throttle(ip: string): Boolean {
if (!this.configuration.throttle) {
return false
}
Expand Down

0 comments on commit 0dd5f12

Please sign in to comment.