CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-http-proxy-middleware

The one-liner node.js proxy middleware for connect, express, next.js and more

92

1.24x
Quality

Pending

Does it follow best practices?

Impact

92%

1.24x

Average score across 10 eval scenarios

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

task.mdevals/scenario-5/

Body-Parsing Proxy Server

Build a proxy server that forwards POST requests to a backend service while using body-parser middleware to log request details.

Requirements

The proxy server should:

  1. Accept POST requests to /api/submit endpoint
  2. Use Express body-parser middleware to parse incoming request bodies (json, urlencoded, and text formats)
  3. Log the parsed request body to the console
  4. Forward the POST request to a configured backend server
  5. Return the backend's response to the client

The server must correctly proxy POST requests even though body-parser consumes the request stream. The proxied requests should arrive at the backend with the correct body content and appropriate Content-Length headers.

Test Cases

  • POST request with JSON body is logged and correctly forwarded to backend @test
  • POST request with URL-encoded form data is logged and correctly forwarded to backend @test
  • POST request with plain text is logged and correctly forwarded to backend @test

Implementation

@generates

API

/**
 * Creates and starts an Express server that proxies POST requests to a backend.
 *
 * @param {Object} config - Server configuration
 * @param {number} config.port - Port for the proxy server to listen on
 * @param {string} config.backendUrl - URL of the backend server to proxy to
 * @returns {Object} Express app instance
 */
function createProxyServer(config) {
  // Implementation here
}

module.exports = { createProxyServer };

Dependencies { .dependencies }

express { .dependency }

Provides web server framework.

@satisfied-by

body-parser { .dependency }

Provides request body parsing middleware.

@satisfied-by

http-proxy-middleware { .dependency }

Provides HTTP proxy middleware with request body handling support.

@satisfied-by

tile.json