https://github.com/jet2jet/cgi-express
Executes Express.js application as CGI program.
https://github.com/jet2jet/cgi-express
cgi cgi-script express-js expressjs web
Last synced: 3 months ago
JSON representation
Executes Express.js application as CGI program.
- Host: GitHub
- URL: https://github.com/jet2jet/cgi-express
- Owner: jet2jet
- License: mit
- Created: 2021-04-24T09:11:04.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-02-04T04:40:57.000Z (about 3 years ago)
- Last Synced: 2023-12-23T18:01:36.462Z (over 2 years ago)
- Topics: cgi, cgi-script, express-js, expressjs, web
- Language: TypeScript
- Homepage:
- Size: 180 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# cgi-express
[](https://www.npmjs.com/package/cgi-express)
[](https://www.travis-ci.com/jet2jet/cgi-express)
\[EXPERIMENTAL; Not tested well\] Executes Express.js application as CGI program.
> - Since this library is not tested well, please be HIGHLY CAREFUL with using this in production.
> - This library may be uncompatible with some CGI executors.
## Requirements
- Express.js (tested with 4.x)
- For TypeScript, `@types/express` is necessary to build
- Node.js >=10
## Example
```js
#!/usr/bin/env node
const express = require('express');
const cgiExpress = require('cgi-express');
const app = express();
// initialize 'app' as usual Express.js application here...
// call 'execute' with the default configuration
// (using process.stdout, process.stdin, and process.env)
cgiExpress.execute(app);
```
## API
### `function execute(app: express.Application, opts?: Options): Promise`
Executes Express.js application as a CGI program. This function uses `process.stdin`,
`process.stdout`, and `process.env` properties as default.
#### Parameters
- `app` -- An Express.js application instance
- `opts` -- Additional options (`Options`) for execution
#### Returns
Promise object which resolves when execution finishes
### `function executeCore(app: express.Application, opts?: Options & Required>): Promise`
Executes Express.js application as a CGI program, with custom stdin/stdout/env data.
#### Parameters
- `app` -- An Express.js application instance
- `opts` -- Additional options (`Options`) for execution (stdin/stdout/env are not omittable)
#### Returns
Promise object which resolves when execution finishes
## License
[MIT License](./LICENSE)