@furystack/websocket-api
Advanced tools
Comparing version 8.1.23 to 9.0.0
{ | ||
"name": "@furystack/websocket-api", | ||
"version": "8.1.23", | ||
"version": "9.0.0", | ||
"description": "HTTP Api FuryStack package", | ||
"main": "dist/index.js", | ||
"type": "module", | ||
"scripts": { | ||
"build:es6": "tsc --outDir ./esm" | ||
}, | ||
"exports": { | ||
".": { | ||
"import": "./esm/index.js", | ||
"types": "./types/index.d.ts" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"types/*" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
@@ -29,14 +46,14 @@ "dist", | ||
"dependencies": { | ||
"@furystack/core": "^11.3.1", | ||
"@furystack/inject": "^7.1.9", | ||
"@furystack/rest-service": "^6.2.23", | ||
"@furystack/utils": "^3.1.8", | ||
"@furystack/core": "^12.0.0", | ||
"@furystack/inject": "^8.0.0", | ||
"@furystack/rest-service": "^7.0.0", | ||
"@furystack/utils": "^4.0.0", | ||
"ws": "^8.13.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.5.0", | ||
"@types/ws": "^8.5.4" | ||
"@types/ws": "^8.5.4", | ||
"typescript": "^5.0.4", | ||
"vitest": "^0.30.1" | ||
}, | ||
"typings": "./types/index.d.ts", | ||
"gitHead": "1045d854bfd8c475b7035471d130d401417a2321" | ||
} |
@@ -7,2 +7,3 @@ import { WhoAmI } from './whoami' | ||
import { Injector } from '@furystack/inject' | ||
import { describe, it, expect, vi } from 'vitest' | ||
@@ -16,3 +17,3 @@ describe('Whoami action', () => { | ||
const wsMock: ws = { | ||
send: jest.fn(() => undefined), | ||
send: vi.fn(() => undefined), | ||
} as unknown as ws | ||
@@ -19,0 +20,0 @@ |
@@ -5,2 +5,3 @@ import { usingAsync } from '@furystack/utils' | ||
import { WebSocketApi, WebSocketApiSettings } from '.' | ||
import { describe, it, expect } from 'vitest' | ||
@@ -7,0 +8,0 @@ describe('WebSocket Helpers', () => { |
@@ -10,7 +10,6 @@ import type { Injector } from '@furystack/inject' | ||
* injector.useWebsockets({ | ||
* path: "/sockets", | ||
* actions: [...my custom actions] | ||
* path: "/sockets", | ||
* actions: [...my custom actions] | ||
* }) | ||
* ```` | ||
* | ||
* @param injector The injector instance | ||
@@ -17,0 +16,0 @@ * @param settings The Settings object for the WebSocket API |
@@ -7,2 +7,3 @@ import { Injector, Injectable } from '@furystack/inject' | ||
import { useWebsockets } from './helpers' | ||
import { describe, it, expect } from 'vitest' | ||
@@ -9,0 +10,0 @@ describe('WebSocketApi', () => { |
@@ -8,3 +8,4 @@ import { URL } from 'url' | ||
import type { Data } from 'ws' | ||
import ws, { Server as WebSocketServer } from 'ws' | ||
import { WebSocketServer } from 'ws' | ||
import ws from 'ws' | ||
import { WebSocketApiSettings } from './websocket-api-settings' | ||
@@ -11,0 +12,0 @@ import type { WebSocketAction } from './models' |
@@ -8,2 +8,3 @@ import { Injector } from '@furystack/inject' | ||
import { useWebsockets } from './helpers' | ||
import { describe, it, expect, beforeEach, afterEach } from 'vitest' | ||
@@ -17,3 +18,3 @@ describe('WebSocket Integration tests', () => { | ||
beforeEach((done) => { | ||
beforeEach(async () => { | ||
i = new Injector() | ||
@@ -32,12 +33,15 @@ useRestService({ | ||
useWebsockets(i, { actions: [WhoAmI], path, port, host }) | ||
i.getInstance(ServerManager) | ||
.getOrCreate({ port }) | ||
.then(() => { | ||
client = new ws(`ws://${host}:${port}/ws`) | ||
client | ||
.on('open', () => { | ||
done() | ||
}) | ||
.on('error', done) | ||
}) | ||
await new Promise<void>((done, reject) => { | ||
i.getInstance(ServerManager) | ||
.getOrCreate({ port }) | ||
.then(() => { | ||
client = new ws(`ws://${host}:${port}/ws`) | ||
client | ||
.on('open', () => { | ||
done() | ||
}) | ||
.on('error', reject) | ||
}) | ||
}) | ||
}) | ||
@@ -49,10 +53,12 @@ | ||
it('Should be connected', (done) => { | ||
client.on('message', (data) => { | ||
expect(data.toString()).toBe('{"currentUser":null}') | ||
client.close() | ||
done() | ||
it('Should be connected', async () => { | ||
await new Promise<void>((done) => { | ||
client.on('message', (data) => { | ||
expect(data.toString()).toBe('{"currentUser":null}') | ||
client.close() | ||
done() | ||
}) | ||
client.send('whoami') | ||
}) | ||
client.send('whoami') | ||
}) | ||
}) |
@@ -7,2 +7,3 @@ import { Injector } from '@furystack/inject' | ||
import { WebsocketUserContext } from './websocket-user-context' | ||
import { describe, it, expect, vi } from 'vitest' | ||
@@ -16,3 +17,3 @@ describe('WebSocket User Context', () => { | ||
await usingAsync(new Injector(), async (i) => { | ||
const authFn = jest.fn(async () => mockUser) | ||
const authFn = vi.fn(async () => mockUser) | ||
const incomingMessage = {} | ||
@@ -29,3 +30,3 @@ i.setExplicitInstance(incomingMessage, IncomingMessage) | ||
await usingAsync(new Injector(), async (i) => { | ||
const authFn = jest.fn(() => Promise.reject('Hey! No user here!')) | ||
const authFn = vi.fn(() => Promise.reject('Hey! No user here!')) | ||
const incomingMessage = {} | ||
@@ -44,3 +45,3 @@ i.setExplicitInstance(incomingMessage, IncomingMessage) | ||
await usingAsync(new Injector(), async (i) => { | ||
const authFn = jest.fn(async () => mockAdmin) | ||
const authFn = vi.fn(async () => mockAdmin) | ||
const incomingMessage = {} | ||
@@ -56,3 +57,3 @@ i.setExplicitInstance(incomingMessage, IncomingMessage) | ||
await usingAsync(new Injector(), async (i) => { | ||
const authFn = jest.fn(async () => mockUser) | ||
const authFn = vi.fn(async () => mockUser) | ||
const incomingMessage = {} | ||
@@ -68,3 +69,3 @@ i.setExplicitInstance(incomingMessage, IncomingMessage) | ||
await usingAsync(new Injector(), async (i) => { | ||
const authFn = jest.fn(() => Promise.reject('Hey! No user here!')) | ||
const authFn = vi.fn(() => Promise.reject('Hey! No user here!')) | ||
const incomingMessage = {} | ||
@@ -71,0 +72,0 @@ i.setExplicitInstance(incomingMessage, IncomingMessage) |
@@ -8,7 +8,6 @@ import type { Injector } from '@furystack/inject'; | ||
* injector.useWebsockets({ | ||
* path: "/sockets", | ||
* actions: [...my custom actions] | ||
* path: "/sockets", | ||
* actions: [...my custom actions] | ||
* }) | ||
* ```` | ||
* | ||
* @param injector The injector instance | ||
@@ -15,0 +14,0 @@ * @param settings The Settings object for the WebSocket API |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
0
Yes
49136
3
33
551
+ Added@furystack/core@12.0.18(transitive)
+ Added@furystack/inject@8.1.8(transitive)
+ Added@furystack/repository@7.0.18(transitive)
+ Added@furystack/rest@5.0.19(transitive)
+ Added@furystack/rest-service@7.0.20(transitive)
+ Added@furystack/security@3.0.18(transitive)
+ Added@furystack/utils@4.0.17(transitive)
- Removed@furystack/core@11.3.1(transitive)
- Removed@furystack/inject@7.1.9(transitive)
- Removed@furystack/repository@6.1.17(transitive)
- Removed@furystack/rest@4.2.1(transitive)
- Removed@furystack/rest-service@6.2.23(transitive)
- Removed@furystack/security@2.1.16(transitive)
- Removed@furystack/utils@3.1.8(transitive)
Updated@furystack/core@^12.0.0
Updated@furystack/inject@^8.0.0
Updated@furystack/utils@^4.0.0