gateway is a Node.js middleware designed to facilitate the execution of CGI scripts, such as PHP files, within a Node.js HTTP server environment. It was initially developed around 2012 to support development tools like Yeoman and Livestyle in serving dynamic content. The package's current stable version is 1.0.0, released over a decade ago, indicating it is no longer actively maintained. Unlike `node-cgi`, `gateway` focuses on serving individual script files rather than `cgi-bin` directories, requiring the corresponding CGI binary (e.g., `php-cgi`) to be installed and accessible in the system's PATH. This approach allows Node.js applications to integrate with existing CGI-based applications but comes with the inherent security and maintenance implications of executing external processes.
npm install gatewayVerified import paths — ran on the pinned version, not inferred.
This example sets up a basic Node.js HTTP server using `gateway` to serve a dynamically created `info.php` file, demonstrating how to execute PHP scripts through `php-cgi`.
Migrate to actively maintained alternatives or use more secure methods for serving dynamic content. If absolutely necessary, thoroughly audit any external scripts executed.
If `cgi-bin` functionality is required, consider using alternative packages like `node-cgi` or setting up a dedicated web server (e.g., Nginx, Apache) to handle `cgi-bin`.
Install the necessary CGI binaries for your scripting language (e.g., `brew install php@XX` for PHP on macOS) and ensure their location is included in your system's PATH.
Be aware of this redirect behavior in your application's routing. Ensure client requests for directories include a trailing slash if redirects are undesired.
Always use `const gateway = require('gateway');` for importing. For TypeScript projects, you may need to create a custom declaration file (`.d.ts`) if type safety is desired.Install the required CGI binary and ensure its installation directory is correctly added to your system's PATH environment variable.
Verify that the `gateway` options correctly map the file extension (e.g., `'.php': 'php-cgi'`) and confirm that the CGI binary (e.g., `php-cgi`) is installed and can execute the script from the command line.
Use the CommonJS `require` syntax: `const gateway = require('gateway');`.No dependency data recorded yet.