Skip to content

Commit

Permalink
fix(framework): order of scoped services to allow injecting HttpReque…
Browse files Browse the repository at this point in the history
…st in RpcKernelSecurity
  • Loading branch information
marcj committed Feb 24, 2024
1 parent 52fd21f commit 9a5e300
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/framework/src/worker.ts
Expand Up @@ -8,7 +8,14 @@
* You should have received a copy of the MIT License along with this program.
*/

import { ConnectionWriter, RpcConnectionWriter, RpcKernel, RpcKernelBaseConnection, RpcKernelConnection, SessionState } from '@deepkit/rpc';
import {
ConnectionWriter,
RpcConnectionWriter,
RpcKernel,
RpcKernelBaseConnection,
RpcKernelConnection,
SessionState,
} from '@deepkit/rpc';
import http, { Server } from 'http';
import https from 'https';
import type { Server as WebSocketServer, ServerOptions as WebSocketServerOptions } from 'ws';
Expand Down Expand Up @@ -172,14 +179,14 @@ export class WebMemoryWorkerFactory extends WebWorkerFactory {

export function createRpcConnection(rootScopedContext: InjectorContext, rpcKernel: RpcKernel, writer: RpcConnectionWriter, request?: HttpRequest) {
const injector = rootScopedContext.createChildScope('rpc');
const connection = rpcKernel.createConnection(writer, injector);

injector.set(HttpRequest, request);
injector.set(RpcInjectorContext, injector);
injector.set(ConnectionWriter, writer);

const connection = rpcKernel.createConnection(writer, injector);
injector.set(SessionState, connection.sessionState);
injector.set(RpcKernelConnection, connection);
injector.set(RpcKernelBaseConnection, connection);
injector.set(ConnectionWriter, writer);

return connection;
}
Expand Down

0 comments on commit 9a5e300

Please sign in to comment.