@crypticat/core
Advanced tools
Comparing version 0.1.4 to 0.1.5
/// <reference types="node" /> | ||
import WebSocket from 'ws'; | ||
import { EventEmitter } from 'events'; | ||
import { Server as HttpServer } from 'http'; | ||
import { Server as HttpsServer } from 'https'; | ||
export interface Room { | ||
@@ -22,4 +24,4 @@ name: string; | ||
constructor(); | ||
listen(port: number): void; | ||
listen(location: HttpServer | HttpsServer | number, path?: string): void; | ||
} | ||
export { CrypticatServer }; |
@@ -20,2 +20,4 @@ "use strict"; | ||
const events_1 = require("events"); | ||
const http_1 = require("http"); | ||
const https_1 = require("https"); | ||
class CrypticatServer extends events_1.EventEmitter { | ||
@@ -27,4 +29,15 @@ constructor() { | ||
} | ||
listen(port) { | ||
this.wss = new ws_1.default.Server({ port }); | ||
listen(location, path) { | ||
if (location instanceof http_1.Server || location instanceof https_1.Server) { | ||
this.wss = new ws_1.default.Server({ | ||
server: location, | ||
path | ||
}); | ||
} | ||
else if (typeof location === 'number') { | ||
this.wss = new ws_1.default.Server({ | ||
port: location, | ||
path | ||
}); | ||
} | ||
this.wss.on('connection', (ws) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -31,0 +44,0 @@ const uid = yield uid_promise_1.default(20); |
{ | ||
"name": "@crypticat/core", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Crypticat's core client and server implementation", | ||
@@ -21,5 +21,7 @@ "author": "Kognise <felix.mattick@gmail.com>", | ||
"scripts": { | ||
"tsc": "tsc -p tsconfig.build.json" | ||
"tsc": "tsc -p tsconfig.build.json", | ||
"watch": "tsc --watch" | ||
}, | ||
"dependencies": { | ||
"typescript": "^3.8.3", | ||
"uid-promise": "^1.1.0", | ||
@@ -29,6 +31,7 @@ "ws": "^7.2.3" | ||
"devDependencies": { | ||
"@types/node": "^13.9.5", | ||
"@types/ws": "^7.2.3", | ||
"typescript": "^3.8.3" | ||
}, | ||
"gitHead": "23aefb44f27494bab3b6b4b0ea394f1b4c2446e4" | ||
"gitHead": "611a587b42e6320bcfa7afca71062b24d9d46994" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30003
415
3
3
2
+ Addedtypescript@^3.8.3
+ Addedtypescript@3.9.10(transitive)