@moogodev/client 0.1.0 → 0.1.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.
- package/README.md +54 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# @moogodev/client
|
|
2
|
+
|
|
3
|
+
Official JavaScript/TypeScript client for Moogo object storage.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @moogodev/client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { MoogoClient, createClientFromEnv } from '@moogodev/client';
|
|
15
|
+
|
|
16
|
+
// Reads from environment variables:
|
|
17
|
+
// MOOGO_API_URL, MOOGO_PROJECT_ID, MOOGO_BUCKET_ACCESS_KEY_ID, MOOGO_BUCKET_SECRET_KEY
|
|
18
|
+
const client = createClientFromEnv();
|
|
19
|
+
|
|
20
|
+
// Upload with custom Cache-Control
|
|
21
|
+
const response = await client.upload('avatars/user.png', fileBlob, {
|
|
22
|
+
contentType: 'image/png',
|
|
23
|
+
cacheControl: 'public, max-age=31536000, immutable',
|
|
24
|
+
onProgress: (loaded, total) => console.log(`${loaded}/${total}`),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
console.log(response.object.public_url);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- **Full TypeScript support** — complete type definitions for all API responses
|
|
33
|
+
- **Cursor-based pagination** — stable `nextCursor` + `total` for listings
|
|
34
|
+
- **Range requests** — `206 Partial Content`, `416 Range Not Satisfiable`, `If-Range`
|
|
35
|
+
- **Custom Cache-Control** — send `Cache-Control` header on upload to override defaults
|
|
36
|
+
- **Presigned URLs** — GET (download) and PUT (browser direct upload)
|
|
37
|
+
- **Signed uploads** — returns upload URL + object metadata
|
|
38
|
+
- **Bucket operations** — list, create, update, delete, get info, toggle public
|
|
39
|
+
- **Credential management** — list, create, rotate, revoke storage credentials
|
|
40
|
+
- **Rate-limit handling** — `X-RateLimit-Reset` header parsing, `RateLimitedError` with `retryAfter`/`resetAt`
|
|
41
|
+
- **Typed errors** — all API error codes as distinct classes
|
|
42
|
+
- **Zero dependencies** — uses Web Crypto API (native in Node 18+, browsers, edge runtimes)
|
|
43
|
+
- **Works everywhere** — Node 18+, Deno, Bun, Cloudflare Workers, Vercel Edge, browsers (via bundler)
|
|
44
|
+
|
|
45
|
+
## Documentation
|
|
46
|
+
|
|
47
|
+
- [Full API Reference](https://moogo.dev/docs/javascript-client)
|
|
48
|
+
- [Object Storage API](https://moogo.dev/docs/object-storage)
|
|
49
|
+
- [Rate Limits](https://moogo.dev/docs/limits)
|
|
50
|
+
- [Error Codes](https://moogo.dev/docs/errors)
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moogodev/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Official JavaScript/TypeScript client for Moogo object storage",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=18.0.0"
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
}
|