Skip to content

Commit 0196266

Browse files
chore(release): 2.0.0 [skip ci]
## [2.0.0](v1.5.2...v2.0.0) (2023-03-30) ### ⚠ BREAKING CHANGES * **websocket:** Now minimum Node.js required for running is v16 ### ✨ Features * upgrade uWebSockets.js ([a7dc98e](a7dc98e)) ### 🐛 Fixes * **nanoexpress:** remove unnecessary log file ([15c986a](15c986a)) * **websocket:** typescript typing improved and fixed ([a0d0069](a0d0069)) ### 🔁 Chore * **ci:** fix exec for `npm` ([e4b19c7](e4b19c7)) * **ci:** GH Actions and Yarn compatiblity fix ([100ed0d](100ed0d)) * **deps-dev:** bump @types/node from 18.14.4 to 18.14.6 ([b74caeb](b74caeb)) * **deps-dev:** bump @types/node from 18.14.6 to 18.15.0 ([6591e48](6591e48)) * **deps-dev:** bump rollup from 3.18.0 to 3.19.0 ([1d217ab](1d217ab)) * upgrade lockfile and upgrade to latest linter configs ([320d728](320d728)) * **vscode:** update local terminal path ([996deda](996deda))
1 parent e4b19c7 commit 0196266

File tree

11 files changed

+30
-13
lines changed

11 files changed

+30
-13
lines changed

cjs/nanoexpress.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ function exposeWebsocket(handler, options = {}) {
15041504
if (typeof options.open === 'function') {
15051505
return options;
15061506
}
1507-
return {
1507+
const behavior = {
15081508
...options,
15091509
open(ws) {
15101510
ws.emit('connection', ws);
@@ -1547,6 +1547,7 @@ function exposeWebsocket(handler, options = {}) {
15471547
ws.emit('close', code, message);
15481548
}
15491549
};
1550+
return behavior;
15501551
}
15511552

15521553
const useCallback = register(false, true);

cjs/nanoexpress.cjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

esm/nanoexpress.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

esm/nanoexpress.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nanoexpress/ultimate",
33
"type": "module",
4-
"version": "1.5.2",
4+
"version": "2.0.0",
55
"description": "Ultimate solution based on nanoexpress and best-practices",
66
"main": "cjs/nanoexpress.js",
77
"module": "esm/nanoexpress.js",

typings/app.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ declare class App extends RouterTemplate {
2626
setNotFoundHandler(handler: HttpHandler<HttpMethod, RequestSchema>): this;
2727
setErrorHandler(handler: (err: Error, req: HttpRequest, res: HttpResponse) => void): this;
2828
handleError(error: Error, req: HttpRequest, res: HttpResponse): this;
29-
ws(path: RecognizedString, options: WebSocketBehavior): this;
29+
ws<T>(path: RecognizedString, options: WebSocketBehavior<T>): this;
3030
publish(topic: RecognizedString, message: RecognizedString, isBinary?: boolean, compress?: boolean): boolean;
3131
run(): this;
3232
listenSocket(port: number, host?: string, is_ssl?: boolean, handler?: () => void): Promise<us_listen_socket>;

typings/app.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typings/exposes/websocket.d.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1-
import { HttpRequest, HttpResponse, WebSocketBehavior } from 'uWebSockets.js';
2-
export default function exposeWebsocket(handler: (req: HttpRequest, res: HttpResponse) => void | Promise<void>, options?: {}): WebSocketBehavior;
1+
import { HttpRequest, HttpResponse, WebSocketBehavior, WebSocket } from 'uWebSockets.js';
2+
interface IWebSocket<UserData> extends WebSocket<UserData> {
3+
on(eventName: 'connection' | 'error' | 'upgrade' | 'willUpgrade' | 'upgraded' | 'message' | 'drain' | 'close', listener: (...args: any[]) => void): void;
4+
emit(eventName: 'message', message: ArrayBuffer, isBinary: boolean): void;
5+
emit(eventName: 'connection', ws: IWebSocket<UserData>): void;
6+
emit(eventName: 'drain', drained: number): void;
7+
emit(eventName: 'close', code: number, message: ArrayBuffer): void;
8+
}
9+
type WebSocketOptions<UserData> = Omit<WebSocketBehavior<UserData>, 'open' | 'message' | 'drain' | 'close'>;
10+
interface IWebSocketBehavior<UserData> extends WebSocketOptions<UserData> {
11+
open: (ws: IWebSocket<UserData>) => void;
12+
message: (ws: IWebSocket<UserData>, message: ArrayBuffer, isBinary: boolean) => void;
13+
drain: (ws: IWebSocket<UserData>) => void;
14+
close: (ws: IWebSocket<UserData>, code: number, message: ArrayBuffer) => void;
15+
}
16+
export default function exposeWebsocket<UserData>(handler: (req: HttpRequest, res: HttpResponse) => void | Promise<void>, options?: WebSocketBehavior<UserData> | WebSocketOptions<UserData>): IWebSocketBehavior<UserData> | WebSocketBehavior<UserData>;
17+
export {};
318
//# sourceMappingURL=websocket.d.ts.map

typings/exposes/websocket.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typings/router.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class Router {
88
protected [appInstance]: App | Router;
99
protected _engine?: RouteEngine;
1010
[routerInstances]: UnpreparedRoute[];
11-
[wsInstances]: IWebsocketRoute[];
11+
[wsInstances]: IWebsocketRoute<any>[];
1212
_basePath: string;
1313
constructor();
1414
on<T>(method: HttpMethod, path: string | RegExp, handlers: MiddlewareHandler | MiddlewareHandler[] | RouteHandler<HttpMethod, T> | RouteHandler<HttpMethod, T>[], baseUrl: string, originalUrl: string): this;
@@ -20,7 +20,7 @@ export default class Router {
2020
del<T = RequestSchema>(path: string | RegExp, ...handlers: RouteHandler<'DEL', T>[]): this;
2121
delete<T = RequestSchema>(path: string | RegExp, ...handlers: RouteHandler<'DEL', T>[]): this;
2222
all<T = RequestSchemaWithBody>(path: string | RegExp, ...handlers: RouteHandler<'ANY', T>[]): this;
23-
ws(path: RecognizedString, options?: WebSocketBehavior): this;
23+
ws<UserData>(path: RecognizedString, options?: WebSocketBehavior<UserData>): this;
2424
publish(topic: RecognizedString, message: RecognizedString, isBinary?: boolean, compress?: boolean): boolean;
2525
}
2626
//# sourceMappingURL=router.d.ts.map

typings/router.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)