logging & npmignore

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-08-04 22:47:15 +02:00
parent 7ffbd718cd
commit 1aed7af731
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
6 changed files with 17 additions and 13 deletions

View File

@ -14,6 +14,6 @@
// limitations under the License. // limitations under the License.
// //
const start = require('@anticrm/dev-server') import start from '@anticrm/dev-server'
start (3333) start.default(3333)

View File

@ -5,20 +5,20 @@
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@anticrm/core": { "@anticrm/core": {
"version": "0.6.4", "version": "0.6.5",
"resolved": "https://registry.npmjs.org/@anticrm/core/-/core-0.6.4.tgz", "resolved": "https://registry.npmjs.org/@anticrm/core/-/core-0.6.5.tgz",
"integrity": "sha512-R4sy4iOJn+7mTLOmeS03KTLmDlPFLvT4gLAIo7VWSStpslVex+YoyRXulnhTIbBZikQFW88nAvAm5e4fhoiVgA==", "integrity": "sha512-+Ap6OGh8o+79yGgYlxbZOoLeQ+bTPFH3B+r29yioFuqZ4M8E+k8gGgToZiYuyHZFI+pKLodwAoN8u347XqmYjA==",
"requires": { "requires": {
"@anticrm/platform": "~0.6.1", "@anticrm/platform": "~0.6.1",
"simplytyped": "^3.3.0" "simplytyped": "^3.3.0"
} }
}, },
"@anticrm/dev-server": { "@anticrm/dev-server": {
"version": "0.6.1", "version": "0.6.2",
"resolved": "https://registry.npmjs.org/@anticrm/dev-server/-/dev-server-0.6.1.tgz", "resolved": "https://registry.npmjs.org/@anticrm/dev-server/-/dev-server-0.6.2.tgz",
"integrity": "sha512-Zh04YOsHprDMjCybAzizImZtRntEmuyS7ko8gdTZKgmHq3Bypf4jRIai0WF8sjULVrcOKRAGEAVqdPBhwkwz2Q==", "integrity": "sha512-vsCMWeCpwdZVh6Jch2RD0AXChOhQ8+7RyUzN924KWupEMN8H4lshytXVPPpCOTOmK5IIt9OlB6E7XKef1PcZPA==",
"requires": { "requires": {
"@anticrm/core": "~0.6.1", "@anticrm/core": "~0.6.5",
"@anticrm/dev-storage": "~0.6.1", "@anticrm/dev-storage": "~0.6.1",
"@anticrm/platform": "~0.6.1", "@anticrm/platform": "~0.6.1",
"@anticrm/server-ws": "~0.6.1" "@anticrm/server-ws": "~0.6.1"

View File

@ -7,6 +7,6 @@
"start": "node ./index.js" "start": "node ./index.js"
}, },
"dependencies": { "dependencies": {
"@anticrm/dev-server": "^0.6.1" "@anticrm/dev-server": "^0.6.2"
} }
} }

View File

@ -14,4 +14,4 @@
// limitations under the License. // limitations under the License.
// //
export { start as default } from './server' export { start } from './server'

View File

@ -0,0 +1,4 @@
*
!/lib/**
!CHANGELOG.md
/lib/**/__tests__/

View File

@ -56,8 +56,7 @@ export interface JsonRpcServer {
* @param host - * @param host -
*/ */
export function start (sessionFactory: (server: JsonRpcServer) => Session, port: number, host?: string): void { export function start (sessionFactory: (server: JsonRpcServer) => Session, port: number, host?: string): void {
// console.log('starting server on port ' + port + '...') console.log(`starting server on port ${port} ...`)
// console.log('host: ' + host)
const sessions: [Session, WebSocket][] = [] const sessions: [Session, WebSocket][] = []
@ -86,6 +85,7 @@ export function start (sessionFactory: (server: JsonRpcServer) => Session, port:
const payload = decode(token ?? '', 'secret', false) const payload = decode(token ?? '', 'secret', false)
wss.handleUpgrade(request, socket, head, ws => wss.emit('connection', ws, request, payload)) wss.handleUpgrade(request, socket, head, ws => wss.emit('connection', ws, request, payload))
} catch (err) { } catch (err) {
console.log('unauthorized')
socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n') socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n')
socket.destroy() socket.destroy()
} }