@wooch-tickets/wookster-cli 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +100 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,15 +1,109 @@
1
- # @wookster/client
1
+ # Wookster CLI
2
2
 
3
- To install dependencies:
3
+ 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.
4
4
 
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Global installation via npm](#global-installation-via-npm)
9
+ - [Usage with npx (without installation)](#usage-with-npx-without-installation)
10
+ - [Configuration](#configuration)
11
+ - [Environment Variables](#environment-variables)
12
+ - [Global Options](#global-options)
13
+ - [Commands](#commands)
14
+ - [execute](#execute)
15
+ - [Scripts](#scripts)
16
+ - [Script API](#script-api)
17
+ - [proxy](#proxy)
18
+
19
+ ## Installation
20
+
21
+ ### Global installation via npm
22
+ ```bash
23
+ npm install -g @wooch-tickets/wookster-cli
24
+ ```
25
+
26
+ ### Usage with npx (without installation)
5
27
  ```bash
6
- bun install
28
+ npx @wooch-tickets/wookster-cli [commands]
7
29
  ```
8
30
 
9
- To run:
31
+ ## Configuration
32
+
33
+ The CLI can be configured via environment variables or command-line options. Command-line options take precedence over environment variables.
34
+
35
+ ### Environment Variables
36
+
37
+ - `WOOKSTER_URL`: Wookster server URL
38
+ - `WOOKSTER_API_KEY`: API key for authentication
39
+ - `WOOKSTER_WORKER_ID`: Worker identifier
40
+ - `WOOKSTER_LOGGER`: Logger type (`json`, `pretty`, `noop`)
41
+ - `WOOKSTER_VERBOSE`: Enable verbose logging (if defined)
42
+
43
+ ### Global Options
44
+
45
+ - `-u, --server-url <serverUrl>`: Server URL to connect to
46
+ - `-k, --api-key <apiKey>`: API key for authentication
47
+ - `--logger <type>`: Specify logger type (`json`, `pretty`, `noop`)
48
+ - `--verbose`: Enable verbose logging
49
+
50
+ ## Commands
51
+
52
+ ### execute
53
+ Starts a virtual hook client and executes a provided script for each request.
54
+ ```bash
55
+ wookster execute --worker <worker_id> --script <script_path>
56
+ ```
57
+
58
+ #### Scripts
59
+ Scripts must contain a specific header to indicate how they should be executed.
60
+
61
+ **Method Mode (`//@wookster/method:<function_name>`)**
62
+ Exports a specific function to handle the request. If the function name is omitted, `handle` is used by default.
63
+
64
+ ```javascript
65
+ //@wookster/method:handle
66
+
67
+ exports.handle = (request, response) => {
68
+ console.log('Received request:', request.id);
69
+ return response.ok('Processed successfully');
70
+ };
71
+ ```
72
+
73
+ **File Mode (`//@wookster/file`)**
74
+ Executes the entire file for each request. The `request` and `response` objects are available in the global context.
75
+
76
+ ```javascript
77
+ //@wookster/file
78
+
79
+ console.log('Processing request:', request.id);
80
+ response.ok('File script executed');
81
+ ```
82
+
83
+ #### Script API
84
+
85
+ Scripts have access to the following objects:
86
+
87
+ **`request` (WebhookRequest)**
88
+ - `id` (string): Unique request identifier.
89
+ - `method` (string): HTTP method (GET, POST, etc.).
90
+ - `body` (string): Request body.
91
+ - `headers` (Record<string, string>): Request headers.
92
+ - `type` ('JSON' | 'XML' | 'FORM_URLENCODED' | 'PLAIN_TEXT'): Detected content type.
93
+ - `signature` (string): Request signature.
94
+
95
+ **`response` (ResponseFactory)**
96
+ - `ok(message: string, code?: number)`: Returns a success response (default code: 200).
97
+ - `error(message: string, code?: number)`: Returns an error response (default code: 500).
98
+
99
+ **`console`**
100
+ The `console` object is intercepted and redirected to the CLI logger. You can use `console.log`, `console.info`, `console.warn`, `console.error`, `console.debug`.
10
101
 
102
+ ### proxy
103
+ Starts a virtual hook client and proxies requests to another server.
11
104
  ```bash
12
- bun run index.ts
105
+ wookster proxy --worker <worker_id> --target <target_url>
13
106
  ```
107
+ Proxied requests include the `X-Webhook-Signature` header and preserve the original content type.
14
108
 
15
- This project was created using `bun init` in bun v1.3.2. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
109
+ For more help, use `wookster --help`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wooch-tickets/wookster-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A TypeScript cli library for connecting to Wookster's services",
5
5
  "peerDependencies": {
6
6
  "typescript": "^5"