Skip to content

Commit

Permalink
fix: define request.context as read only (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Feb 10, 2025
1 parent 52f5538 commit f8372f8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,21 @@ export class AdapterHookable {
}

async upgrade(
request: UpgradeRequest & { context?: Peer["context"] },
request: UpgradeRequest & { readonly context?: Peer["context"] },
): Promise<{
upgradeHeaders?: HeadersInit;
endResponse?: Response;
context: Peer["context"];
}> {
const context = (request.context ??= {});
let context = request.context;
if (!context) {
context = {};
Object.defineProperty(request, "context", {
enumerable: true,
value: context,
});
}

try {
const res = await this.callHook(
"upgrade",
Expand Down

0 comments on commit f8372f8

Please sign in to comment.