Skip to content

Commit fec864c

Browse files
committed
feat: no need for another middleware (#4630)
Signed-off-by: Mariusz Jasuwienas <[email protected]>
1 parent 25b5953 commit fec864c

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

packages/server/src/compliance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const makeSureBodyExistsAndCanBeChecked = (ctx: IResponseContext) => {
5656
*
5757
* @param {IResponseContext & ParameterizedContext} ctx - Koa context containing status and body.
5858
*/
59-
export const jsonRpcComplianceLayer = async (ctx: IResponseContext & ParameterizedContext) => {
59+
export const jsonRpcComplianceLayer = (ctx: IResponseContext & ParameterizedContext) => {
6060
if (!makeSureBodyExistsAndCanBeChecked(ctx)) return;
6161
if (ctx.status === 400) {
6262
if (!ctx.body.error || !ctx.body.error.code) ctx.body.error = FALLBACK_RESPONSE_BODY.error;

packages/server/src/server.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,11 @@ export async function initializeServer() {
309309

310310
const rpcApp = koaJsonRpc.rpcApp();
311311

312-
app.use(async (ctx, next) => {
312+
app.use(async (ctx) => {
313313
await rpcApp(ctx);
314-
await next();
314+
jsonRpcComplianceLayer(ctx);
315315
});
316316

317-
app.use(jsonRpcComplianceLayer);
318-
319317
process.on('unhandledRejection', (reason, p) => {
320318
logger.error(`Unhandled Rejection at: Promise: ${JSON.stringify(p)}, reason: ${reason}`);
321319
});

0 commit comments

Comments
 (0)