@push-rpc/next
Advanced tools
Comparing version 2.0.14 to 2.0.15
/// <reference types="node" /> | ||
import { IncomingMessage, ServerResponse } from "http"; | ||
import { RpcConnectionContext } from "../rpc.js"; | ||
export declare function serveHttpRequest(req: IncomingMessage, res: ServerResponse, path: string, hooks: HttpServerHooks, createConnectionContext: (req: IncomingMessage) => Promise<RpcConnectionContext>): Promise<void>; | ||
export declare function serveHttpRequest(req: IncomingMessage, res: ServerResponse, path: string, hooks: HttpServerHooks, createConnectionContext: (req: IncomingMessage, res: ServerResponse) => Promise<RpcConnectionContext>): Promise<void>; | ||
export type HttpServerHooks = { | ||
@@ -6,0 +6,0 @@ call(ctx: RpcConnectionContext, itemName: string, parameters: unknown[]): Promise<unknown>; |
@@ -12,3 +12,3 @@ "use strict"; | ||
try { | ||
const ctx = await createConnectionContext(req); | ||
const ctx = await createConnectionContext(req, res); | ||
const itemName = req.url.slice(path.length + 1); | ||
@@ -15,0 +15,0 @@ const isJson = req.headers["content-type"]?.includes("application/json") ?? false; |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
import { Middleware } from "../utils/middleware.js"; | ||
import http, { IncomingMessage } from "http"; | ||
import http, { IncomingMessage, ServerResponse } from "http"; | ||
import { HttpServerHooks } from "./http"; | ||
@@ -27,3 +27,3 @@ export declare function publishServices<S extends Services<S>, C extends RpcContext>(services: S, overrideOptions: Partial<PublishServicesOptions<C>> & ({ | ||
subscriptions: boolean; | ||
createConnectionContext(req: IncomingMessage): Promise<RpcConnectionContext>; | ||
createConnectionContext(req: IncomingMessage, res: ServerResponse): Promise<RpcConnectionContext>; | ||
createServerHooks?(hooks: HttpServerHooks, req: IncomingMessage): HttpServerHooks; | ||
@@ -30,0 +30,0 @@ } & ({ |
@@ -26,3 +26,3 @@ "use strict"; | ||
subscriptions: true, | ||
async createConnectionContext(req) { | ||
async createConnectionContext(req, res) { | ||
const header = req.headers[rpc_js_1.CLIENT_ID_HEADER]; | ||
@@ -29,0 +29,0 @@ return { |
{ | ||
"name": "@push-rpc/next", | ||
"version": "2.0.14", | ||
"version": "2.0.15", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -13,3 +13,3 @@ import * as http from "http" | ||
hooks: HttpServerHooks, | ||
createConnectionContext: (req: IncomingMessage) => Promise<RpcConnectionContext>, | ||
createConnectionContext: (req: IncomingMessage, res: ServerResponse) => Promise<RpcConnectionContext>, | ||
) { | ||
@@ -21,3 +21,3 @@ // if port is in options - response 404 on other URLs | ||
try { | ||
const ctx = await createConnectionContext(req) | ||
const ctx = await createConnectionContext(req, res) | ||
@@ -24,0 +24,0 @@ const itemName = req.url.slice(path.length + 1) |
@@ -5,3 +5,3 @@ import {CLIENT_ID_HEADER, RpcConnectionContext, RpcContext, Services} from "../rpc.js" | ||
import {RpcServerImpl} from "./RpcServerImpl.js" | ||
import http, {IncomingMessage} from "http" | ||
import http, {IncomingMessage, ServerResponse} from "http" | ||
import {HttpServerHooks} from "./http" | ||
@@ -11,3 +11,3 @@ | ||
services: S, | ||
overrideOptions: Partial<PublishServicesOptions<C>> & ({port: number} | {server: http.Server}) | ||
overrideOptions: Partial<PublishServicesOptions<C>> & ({port: number} | {server: http.Server}), | ||
): Promise<{ | ||
@@ -46,13 +46,13 @@ server: RpcServer | ||
subscriptions: boolean | ||
createConnectionContext(req: IncomingMessage): Promise<RpcConnectionContext> | ||
createConnectionContext(req: IncomingMessage, res: ServerResponse): Promise<RpcConnectionContext> | ||
createServerHooks?(hooks: HttpServerHooks, req: IncomingMessage): HttpServerHooks | ||
} & ( | ||
| { | ||
server: http.Server | ||
} | ||
server: http.Server | ||
} | ||
| { | ||
port: number | ||
} | ||
port: number | ||
} | ||
| {} | ||
) | ||
) | ||
@@ -66,3 +66,3 @@ const defaultOptions: Omit<PublishServicesOptions<RpcContext>, "port"> = { | ||
async createConnectionContext(req: IncomingMessage): Promise<RpcConnectionContext> { | ||
async createConnectionContext(req: IncomingMessage, res: ServerResponse): Promise<RpcConnectionContext> { | ||
const header = req.headers[CLIENT_ID_HEADER] | ||
@@ -69,0 +69,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
225611