koapache
v3.0.0
Published
A Web server which is easy to use in Command-line or as a forked Child process based on Koa
Maintainers
Readme
KoApache
A Web server which is easy to use in Command-line or as a forked Child process based on Koa.
Versions
| SemVer | status | Node.js | Koa |
| :----: | :----------: | :-----: | :------: |
| >=3 | ✅developing | >=20 | >=3 |
| <3 | ❌deprecated | >=14 | >=2 <3 |
Feature
index.htmlomissible in URLLog HTTP request & response in Command-line output
Listening port supports Random, Number or Environment variable name
Support CORS headers
Reverse proxy can be configurated in
package.jsonSupport to open
http://your_LAN_IP:port/in your default browser on Command-line mode
Usage
Command-line
web-server ./path/of/public/folder/Help information output from web-server -h:
web-server [dir] [options]
A Web server which is easy to use in Command-line or as a forked Child process based on Koa
Options:
--CORS Enable CORS middleware
-h, --help show Help information
-o, --open [path] Open the Index or specific page in default browser
-p, --port <value> Listening port number (support Environment variable name)
-v, --version show Version numberModule
import WebServer from 'koapache';
const server = new WebServer({
staticPath: './path/of/public/folder/',
netPort: 'DOCKER_INTERNAL_PORT', // Get listening port from Shell environment
XDomain: true, // enable CORS
proxyMap: { // Reverse proxy map based on String#replace()
"^/github/(.+)": "https://api.github.com/$1"
}
});
server.workerHost().then(address => console.dir( address ));API document is accessed through npm start (offline), npm docs (online) or Official Website.
Typical case
https://www.npmjs.com/package/koapache?activeTab=dependencies

