braid-blob 0.0.15 → 0.0.16

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.
package/LICENSE.txt ADDED
@@ -0,0 +1,11 @@
1
+ Invisible Property License
2
+
3
+ 1. You have the right to use this IP for any purpose.
4
+ 2. If you make profit, you agree to give back a fair share of the profit to
5
+ the creators of this IP.
6
+ 3. The creators will tell you how much they think is a fair share, if your
7
+ usage matters to them, and promise not to take you to court to enforce
8
+ the agreement.
9
+
10
+ (In other words, this license thus runs on the honor system. You are invited
11
+ to participate in our community with honor.)
package/README.md CHANGED
@@ -1,5 +1,87 @@
1
1
  # braid-blob
2
- Blob Synchronization libraries over Braid-HTTP
2
+
3
+ A simple, self-contained library for synchronizing binary blobs (files, images, etc.) over HTTP using [Braid-HTTP](https://braid.org). It provides real-time synchronization with last-write-wins (LWW) conflict resolution and persistent storage.
4
+
5
+ ## Quick Start
6
+
7
+ ### Installation
8
+
9
+ ```bash
10
+ npm install braid-blob
11
+ ```
12
+
13
+ ### Basic Server
14
+
15
+ ```javascript
16
+ var braid_blob = require('braid-blob')
17
+
18
+ require('http').createServer((req, res) => {
19
+ braid_blob.serve(req, res)
20
+ }).listen(8888)
21
+ ```
22
+
23
+ That's it! You now have a blob synchronization server.
24
+
25
+ ### Usage Examples
26
+
27
+ First let's upload a file:
28
+ ```bash
29
+ curl -X PUT -H "Content-Type: image/png" -T blob.png http://localhost:8888/image.png
30
+ ```
31
+
32
+ View image in browser at http://localhost:8888/image.png
33
+
34
+ To see updates, let's do a textual example for easy viewing:
35
+
36
+ ```
37
+ curl -X PUT -H "Content-Type: text/plain" -d "hello" http://localhost:8888/text
38
+ ```
39
+
40
+ Next, subscribe for updates:
41
+ ```
42
+ curl -H "Subscribe: true" http://localhost:8888/text
43
+ ```
44
+
45
+ Now, in another terminal, write over the file:
46
+ ```bash
47
+ curl -X PUT -H "Content-Type: text/plain" -d "world" http://localhost:8888/text
48
+ ```
49
+
50
+ Should see activity in the first terminal showing the update.
51
+
52
+ ```
53
+ # Delete a file
54
+ curl -X DELETE http://localhost:8888/text
55
+ ```
56
+
57
+ ## API
58
+
59
+ ### Configuration
60
+
61
+ ```javascript
62
+ var braid_blob = require('braid-blob')
63
+
64
+ // Set custom storage location (default: './braid-blob-db')
65
+ braid_blob.db_folder = './custom_files_folder'
66
+
67
+ // Set custom peer ID (default: auto-generated and persisted)
68
+ braid_blob.peer = 'my-server-id'
69
+ ```
70
+
71
+ ### `braid_blob.serve(req, res, options)`
72
+
73
+ Handles HTTP requests for blob storage and synchronization.
74
+
75
+ **Parameters:**
76
+ - `req` - HTTP request object
77
+ - `res` - HTTP response object
78
+ - `options` - Optional configuration object
79
+ - `key` - Override the resource key (default: URL path)
80
+
81
+ **Supported HTTP Methods:**
82
+ - `GET` - Retrieve a blob (with optional `Subscribe: true` header)
83
+ - `PUT` - Store/update a blob
84
+ - `DELETE` - Remove a blob
3
85
 
4
86
  ## Testing
5
87
 
package/blob.png ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-blob",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "Library for collaborative blobs over http using braid.",
5
5
  "author": "Braid Working Group",
6
6
  "repository": "braid-org/braid-blob",
package/plop.png ADDED
Binary file