Comparing version 0.1.5 to 0.1.6
@@ -1,5 +0,6 @@ | ||
import { Request, Response, NextFunction } from "express"; | ||
/// <reference types="node" /> | ||
import { IncomingMessage, ServerResponse } from "node:http"; | ||
import { Procedures } from "./types"; | ||
export type RPCMiddleware<TProcedures extends Procedures> = { | ||
(req: Request, res: Response, next: NextFunction): void; | ||
(req: IncomingMessage, res: ServerResponse, next: (err?: Error) => any): void; | ||
_procedures: TProcedures; | ||
@@ -6,0 +7,0 @@ }; |
import { Buffer } from "node:buffer"; | ||
import { handleRPCRequest } from "./handleRPCRequest.js"; | ||
const createRPCMiddleware = (args) => { | ||
const fn = (req, res) => { | ||
const fn = (req, res, next) => { | ||
if (req.method !== "POST") { | ||
res.statusCode = 405; | ||
res.end(); | ||
return; | ||
return next(); | ||
} | ||
@@ -26,2 +26,3 @@ const requestBodyChunks = []; | ||
res.end(Buffer.from(body), "binary"); | ||
next(); | ||
}); | ||
@@ -28,0 +29,0 @@ }; |
{ | ||
"name": "r19", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Simple remote procedure calls in TypeScript", | ||
@@ -65,2 +65,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@fastify/middie": "^8.1.0", | ||
"@size-limit/preset-small-lib": "^8.1.1", | ||
@@ -76,2 +77,4 @@ "@types/express": "^4.17.15", | ||
"express": "^4.18.2", | ||
"fastify": "^4.11.0", | ||
"h3": "^1.0.2", | ||
"msw": "^0.49.2", | ||
@@ -78,0 +81,0 @@ "node-fetch": "^3.3.0", |
import { Buffer } from "node:buffer"; | ||
import { Request, Response, NextFunction } from "express"; | ||
import { IncomingMessage, ServerResponse } from "node:http"; | ||
@@ -8,3 +8,4 @@ import { Procedures } from "./types"; | ||
export type RPCMiddleware<TProcedures extends Procedures> = { | ||
(req: Request, res: Response, next: NextFunction): void; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(req: IncomingMessage, res: ServerResponse, next: (err?: Error) => any): void; | ||
_procedures: TProcedures; | ||
@@ -20,3 +21,3 @@ }; | ||
): RPCMiddleware<TProcedures> => { | ||
const fn: RPCMiddleware<TProcedures> = (req, res) => { | ||
const fn: RPCMiddleware<TProcedures> = (req, res, next) => { | ||
if (req.method !== "POST") { | ||
@@ -27,3 +28,3 @@ res.statusCode = 405; | ||
return; | ||
return next(); | ||
} | ||
@@ -52,2 +53,4 @@ | ||
res.end(Buffer.from(body), "binary"); | ||
next(); | ||
}); | ||
@@ -54,0 +57,0 @@ }; |
Sorry, the diff of this file is not supported yet
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
102611
1244
23