reserve-cmd

command handler for REserve

Usage no npm install needed!

<script type="module">
  import reserveCmd from 'https://cdn.skypack.dev/reserve-cmd';
</script>

README

REserve/cmd

Command line handler for REserve. It allows execution and output capturing of command lines.

Travis-CI Coverage Status Maintainability Package Quality Known Vulnerabilities dependencies Status devDependencies Status reserve reserve install size MIT License

Usage

{
  "handlers": {
    "cmd": "reserve-cmd"
  },
  "mappings": [{
    "match": "\\/test",
    "cmd": "./test.cmd"
  }]
}

Capturing group values substitutions can be used, space escaping is done with the character `.

Options

Option Default Value Explanation
env {} Additional variables to be used in the created process (see child_process.execFile) (interpolated)
html-footer '' Additional content to be added in the footer of the HTML output (interpolated)
html-header '' Additional content to be added in the header of the HTML output (interpolated)
html-tracking false Injects JavaScript code to scroll the HTML output while executing
text-only false When set, the output is always text
timeout 0 Automatic kill of the process (see child_process.execFile)

NOTE : interpolated values are transformed as described in the custom handlers section of REserve.

Any command can be executed (use it carefully). If a process can not be started, the request ends with a 500 error.

Supported verbs

GET

The handler adapts the output based on the accepted mime-type. If text/html is found in the accept header, the content is formatted to HTML. Otherwise, the output uses text format.