Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to latest npm dependencies #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
// tslint:disable:no-console

import * as http from 'http'
import {
import type {
AddressInfo,
} from 'net'

import {
IoServer,
log,
} from '../src/mod'
} from '../src/mod.js'

async function main (): Promise<number> {

const httpServer = http.createServer()
const port = process.env.PORT || 8080 // process.env.PORT is set by Heroku/Cloud9
const port = process.env['PORT'] || 8080 // process.env.PORT is set by Heroku/Cloud9

httpServer.listen(port, () => {
const address = httpServer.address() as AddressInfo
Expand Down
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,22 @@
"test": "tests"
},
"dependencies": {
"brolog": "^1.8.3",
"is-port-reachable": "3.1",
"brolog": "^1.14.2",
"is-port-reachable": "^3.1",
"json-rpc-peer": "^0.17.0",
"moment": "^2.24.0",
"moment": "^2.29.1",
"p-timeout": "^4.0.0",
"request-ip": "^2.1.3",
"ws": "^7.2.3"
"ws": "^8.4.2"
},
"devDependencies": {
"@chatie/eslint-config": "^0.12.1",
"@chatie/eslint-config": "^1.0.4",
"@chatie/git-scripts": "^0.6.2",
"@chatie/semver": "^0.4.7",
"@chatie/tsconfig": "^0.14.1",
"@types/request-ip": "0.0.35",
"@types/ws": "^7.2.2",
"pkg-jq": "^0.2.4",
"shx": "^0.3.2",
"tstest": "^0.4.10"
"@chatie/tsconfig": "^4.6.2",
"@types/request-ip": "0.0.37",
"@types/ws": "^8.2.2",
"tstest": "^1.0.1"
},
"scripts": {
"clean": "shx rm -fr dist/*",
Expand All @@ -39,7 +37,7 @@
"lint:ts": "tsc --noEmit",
"test": "npm run lint && npm run test:unit",
"test:pack": "bash -x scripts/npm-pack-testing.sh",
"test:unit": "blue-tape -r ts-node/register \"src/**/*.spec.ts\" \"src/*.spec.ts\" \"tests/*.spec.ts\" \"tests/**/*.spec.ts\""
"test:unit": "tap -r ts-node/register \"src/**/*.spec.ts\" \"src/*.spec.ts\" \"tests/*.spec.ts\" \"tests/**/*.spec.ts\""
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export {
/**
* VERSION
*/
export { VERSION } from './version'
export { VERSION } from './version.js'
2 changes: 1 addition & 1 deletion src/io-peer/json-rpc-peer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ declare module 'json-rpc-peer' {
export * from 'json-rpc-protocol'

declare module 'json-rpc-peer' {
export class Peer extends EventEmitter implements NodeJS.WritableStream {
export class Peer extends EventEmitter implements NodeJS.ReadableStream {

constructor(onmessage?: (message: JsonRpcPayload, data: any) => Promise<any>)

Expand Down
4 changes: 2 additions & 2 deletions src/mod.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export {
VERSION,
log,
} from './config'
} from './config.js'

export {
IoServer,
} from './server/io-server'
} from './server/io-server.js'

// export {
// IoClient,
Expand Down
8 changes: 4 additions & 4 deletions src/server/io-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* https://github.com/chatie/io
*
*/
import http from 'http'
import type http from 'http'

import { log } from '../config'
import { log } from '../config.js'

export class IoAuth {

Expand Down Expand Up @@ -53,7 +53,7 @@ export class IoAuth {
*/
const matches = url.match(/token\/(.+)$/i)
if (matches) {
return matches[1]
return matches[1] || null
}

return null
Expand All @@ -71,7 +71,7 @@ export class IoAuth {
return null
}

const scheme = parts[0]
const scheme = parts[0]!
const headerToken = parts[1]

if (!/Token/i.test(scheme) || !headerToken) {
Expand Down
8 changes: 4 additions & 4 deletions src/server/io-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import isPortReachable from 'is-port-reachable'
// import { Listag } from 'listag'
import pTimeout from 'p-timeout'

import { log } from '../config'
import { log } from '../config.js'

import {
IoSocket,
SocketMetadata,
} from './io-socket'
} from './io-socket.js'

export type ServerEventName =
'sys'
Expand Down Expand Up @@ -78,7 +78,7 @@ export class IoManager {
, metadata.token
, metadata.protocol
, metadata.version
, metadata.id
, metadata.id,
)

log.info('IoManager', '◉ register() token online: %s', metadata.token)
Expand Down Expand Up @@ -347,7 +347,7 @@ export class IoManager {
}

// console.info('metadata', metadata)
const { host, jsonRpc } = metaList[0]
const { host, jsonRpc } = metaList[0]!

let port = 8788
try {
Expand Down
4 changes: 2 additions & 2 deletions src/server/io-server.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env ts-node

import test from 'blue-tape'
import { test } from 'tstest'
// import sinon from 'sinon'

import http from 'http'

import {
IoServer,
} from './io-server'
} from './io-server.js'

test('IoServer smoking test', async t => {
const httpServer = http.createServer()
Expand Down
15 changes: 5 additions & 10 deletions src/server/io-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,22 @@
*
*/

// tslint:disable:arrow-parens
// tslint:disable:max-line-length
// tslint:disable:member-ordering
// tslint:disable:unified-signatures

import http from 'http'
import type http from 'http'

import {
log,
VERSION,
} from '../config'
} from '../config.js'

import {
IoAuth,
} from './io-auth'
} from './io-auth.js'
import {
IoManager,
} from './io-manager'
} from './io-manager.js'
import {
IoSocket,
} from './io-socket'
} from './io-socket.js'

export interface IoServerOptions {
httpServer : http.Server,
Expand Down
8 changes: 4 additions & 4 deletions src/server/io-socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
* https://github.com/chatie/io
*
*/
import http from 'http'
import type http from 'http'

import WebSocket from 'ws'
import { getClientIp } from 'request-ip'

import Peer from 'json-rpc-peer'

import { log } from '../config'
import { log } from '../config.js'

export type IoProtocol = 'io' | 'web'

Expand Down Expand Up @@ -53,7 +53,7 @@ export class IoSocket /* implements WebSocketInterface */ {

public static metadata (
socket : WebSocket,
newMetadata? : SocketMetadata
newMetadata? : SocketMetadata,
): void | SocketMetadata {
const existingMetadata = this.socketMetadataDict.get(socket)

Expand Down Expand Up @@ -209,7 +209,7 @@ export class IoSocket /* implements WebSocketInterface */ {
secure : boolean,
req : http.IncomingMessage,
},
done: (res: boolean, code?: number, message?: string) => void
done: (res: boolean, code?: number, message?: string) => void,
): Promise<void> {
// log.verbose('IoSocket', 'verifyClient(info: {%s}, done: %s)',
// Object.keys(info).join(', '),
Expand Down
6 changes: 3 additions & 3 deletions src/version.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env ts-node

import test from 'blue-tape'
import { test } from 'tstest'

import {
GIT_COMMIT_HASH,
VERSION,
} from './version'
} from './version.js'

test('Make sure the VERSION is fresh in source code', async (t) => {
test('Make sure the VERSION is fresh in source code', async t => {
t.equal(VERSION, '0.0.0', 'version should be 0.0.0 in source code, only updated before publish to NPM')
t.equal(GIT_COMMIT_HASH, '', 'git commit hash should be empty')
})