Simplest wrapper to execute shell commands via HTTP. To be used as internal medium only, with pre-validated inputs.
The HTTP port gets pulled from the PORT
environment variable, and 3000
is used as default.
gulp
(has live reload enabled on *.js and *.json files)
npm start
- GET
/
- To be used for healthchecks, replies with HTTP code 200. - POST
/cmd
- Execute a command and return its output, can return codes 200 (command has succeeded), 400 (bad command input), 500 (the command has failed and/or something bad has happened).
All replies will be JSON-encoded. Errors and generic messages will have the following schema:
{
"message": "",
"error": {},
}
Executes a command in a spawned shell (output redirects, file globbings, etc. will work correctly). Accepts application/x-www-form-urlencoded
data:
Field | Type | Meaning | Example |
---|---|---|---|
cmd | string | The command to execute. | echo "This goes to stderr" >&2 |
Will reply with the following schema:
{
"err": {},
"stdout": "",
"stderr": ""
}