@cappitolian/http-local-server 0.0.9 → 0.0.10

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 +12 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -34,13 +34,19 @@ import { HttpLocalServer } from '@cappitolian/http-local-server';
34
34
 
35
35
  ```typescript
36
36
  // 1. Set up the listener for incoming requests
37
- HttpLocalServer.addListener('onRequest', async (request) => {
38
- console.log('Request received:', request.path, request.body);
37
+ await HttpLocalServer.addListener('onRequest', async (data) => {
38
+ console.log(`${data.method} ${data.path}`);
39
+ console.log('Body:', data.body);
40
+ console.log('Headers:', data.headers);
41
+ console.log('Query:', data.query);
39
42
 
40
43
  // 2. Send a response back to the client using the requestId
41
44
  await HttpLocalServer.sendResponse({
42
- requestId: request.requestId,
43
- body: JSON.stringify({ message: "Hello from Ionic!" })
45
+ requestId: data.requestId,
46
+ body: JSON.stringify({
47
+ success: true,
48
+ message: 'Request processed!'
49
+ })
44
50
  });
45
51
  });
46
52
 
@@ -53,7 +59,8 @@ HttpLocalServer.connect().then(result => {
53
59
  ### Stop Server
54
60
 
55
61
  ```typescript
56
- HttpLocalServer.disconnect()
62
+ // 4. Stop the server
63
+ await HttpLocalServer.disconnect();
57
64
  ```
58
65
 
59
66
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cappitolian/http-local-server",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Runs a local HTTP server on your device, accessible over LAN. Supports connect, disconnect, GET, and POST methods with IP and port discovery.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",