@wooch-tickets/wookster-cli
v1.0.3
Published
A TypeScript cli library for connecting to Wookster's services
Readme
Wookster CLI
Wookster CLI is a command-line tool for managing Wookster virtual hooks. It allows you to execute custom scripts or proxy webhook requests to a target server.
Table of Contents
Installation
Global installation via npm
npm install -g @wooch-tickets/wookster-cliUsage with npx (without installation)
npx @wooch-tickets/wookster-cli [commands]Configuration
The CLI can be configured via environment variables or command-line options. Command-line options take precedence over environment variables.
Environment Variables
WOOKSTER_URL: Wookster server URLWOOKSTER_API_KEY: API key for authenticationWOOKSTER_WORKER_ID: Worker identifierWOOKSTER_LOGGER: Logger type (json,pretty,noop)WOOKSTER_VERBOSE: Enable verbose logging (if defined)
Global Options
-u, --server-url <serverUrl>: Server URL to connect to-k, --api-key <apiKey>: API key for authentication--logger <type>: Specify logger type (json,pretty,noop)--verbose: Enable verbose logging
Commands
execute
Starts a virtual hook client and executes a provided script for each request.
wookster execute --worker <worker_id> --script <script_path>Scripts
Scripts must contain a specific header to indicate how they should be executed.
Method Mode (//@wookster/method:<function_name>)
Exports a specific function to handle the request. If the function name is omitted, handle is used by default.
//@wookster/method:handle
exports.handle = (request, response) => {
console.log('Received request:', request.id);
return response.ok('Processed successfully');
};File Mode (//@wookster/file)
Executes the entire file for each request. The request and response objects are available in the global context.
//@wookster/file
console.log('Processing request:', request.id);
response.ok('File script executed');Script API
Scripts have access to the following objects:
request (WebhookRequest)
id(string): Unique request identifier.method(string): HTTP method (GET, POST, etc.).body(string): Request body.headers(Record<string, string>): Request headers.type('JSON' | 'XML' | 'FORM_URLENCODED' | 'PLAIN_TEXT'): Detected content type.signature(string): Request signature.
response (ResponseFactory)
ok(message: string, code?: number): Returns a success response (default code: 200).error(message: string, code?: number): Returns an error response (default code: 500).
console
The console object is intercepted and redirected to the CLI logger. You can use console.log, console.info, console.warn, console.error, console.debug.
proxy
Starts a virtual hook client and proxies requests to another server.
wookster proxy --worker <worker_id> --target <target_url>Proxied requests include the X-Webhook-Signature header and preserve the original content type.
For more help, use wookster --help.
