diff --git a/changelog.md b/changelog.md index 42a93c1..5594971 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,21 @@ Changelog ========= +0.18.0.alpha.0 (2022-04-09) +--------------------------- + +* The `Context` interface has been removed, and the `BaseContext` class is + renamed to `Context`. This is a BC break, but should only be an issue if + you used the `Context` interface directly. `BaseContext` is still + exported but simply aliased to `Context`. This alias will be removed from + a future version. This change should make ite asier to use interface + declaration merging to extend Context. +* The `ws` dependency has been updated to version 8. There are some [breaking + changes][ws8] in this release. The most likely you'll hit is that incoming + messages are now of type `Buffer` instead of `string`. Check out the + [ws changelog][ws8] for more details. + + 0.17.0 (2022-02-08) ------------------- @@ -333,3 +348,5 @@ Happy birthday Mom! ------------------ * First published on npm.js to claim package name. + +[ws8]: https://github.com/websockets/ws/releases/tag/8.0.0 diff --git a/package-lock.json b/package-lock.json index 721f412..adbef63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@curveball/core", - "version": "0.17.0", + "version": "0.18.0-alpha.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@curveball/core", - "version": "0.17.0", + "version": "0.18.0-alpha.0", "license": "MIT", "dependencies": { "@curveball/http-errors": "^0.4.0", diff --git a/package.json b/package.json index ebeddf1..d017be1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@curveball/core", - "version": "0.17.0", + "version": "0.18.0-alpha.0", "description": "Curveball is a framework writting in Typescript for Node.js", "main": "dist/index.js", "scripts": { diff --git a/src/context.ts b/src/context.ts index 16b7564..3c5dc41 100644 --- a/src/context.ts +++ b/src/context.ts @@ -194,3 +194,17 @@ export class Context { } +/** + * WsContext always has a 'webSocket' property defined. + */ +export type WsContext = Context & { + + /** + * WebSocket object. + * + * If the current request is a websocket request, this proprerty will be set + * + * @see https://github.com/websockets/ws#simple-server + */ + webSocket: WebSocket; +}; diff --git a/src/index.ts b/src/index.ts index 4d482c2..080ff5a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,10 @@ import { default as Application, invokeMiddlewares, Middleware, middlewareCall } from './application'; -export { Context } from './context'; +export { + Context, + // For backwards compatibility + Context as BaseContext, + WsContext +} from './context'; import Headers from './headers'; import MemoryRequest from './memory-request'; import MemoryResponse from './memory-response';