@easy-cms/storage-vercel-blob 0.0.0-stage → 0.36.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kanawoot K.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,31 @@
1
- # Temporary Holding Version
1
+ # @easy-cms/storage-vercel-blob
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Vercel Blob storage for Easy CMS uploads, for sites on Vercel (whose disk doesn't keep files). Part of [Easy CMS](https://github.com/maritonx/easy-cms), the embedded, code-first headless CMS for Nuxt and Next.js.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @easy-cms/storage-vercel-blob
9
+ ```
10
+
11
+ Or `pnpm add`, `yarn add` or `bun add`.
12
+
13
+ ## Usage
14
+
15
+ Connect a Blob store to your Vercel project (Storage → Blob); it sets `BLOB_READ_WRITE_TOKEN`.
16
+
17
+ ```ts
18
+ import { vercelBlobStorage } from '@easy-cms/storage-vercel-blob'
19
+
20
+ export default defineConfig({
21
+ // …
22
+ upload: { storage: vercelBlobStorage() }, // public files on the Blob CDN
23
+ // backups: { storage: vercelBlobStorage({ access: 'private', prefix: 'backups/' }) },
24
+ })
25
+ ```
26
+
27
+ ## Links
28
+
29
+ [Uploads](https://maritonx.github.io/easy-cms/guide/uploads) · [One-click deploy](https://maritonx.github.io/easy-cms/guide/one-click-deploy) · [Documentation](https://maritonx.github.io/easy-cms/) ([ภาษาไทย](https://maritonx.github.io/easy-cms/th/)) · [GitHub](https://github.com/maritonx/easy-cms)
30
+
31
+ MIT License
@@ -0,0 +1,27 @@
1
+ import { StorageAdapter } from '@easy-cms/core';
2
+ import { put, del, get } from '@vercel/blob';
3
+
4
+ interface VercelBlobStorageOptions {
5
+ /** The store's read-write token. Default: `BLOB_READ_WRITE_TOKEN` (set when a store is connected). */
6
+ readonly token?: string;
7
+ /**
8
+ * `public` (default): files are served from the Blob CDN, for uploads. `private`: only through
9
+ * the API, e.g. for `backups.storage`.
10
+ */
11
+ readonly access?: 'public' | 'private';
12
+ /** A folder for the files, e.g. `uploads/`. Default: none. */
13
+ readonly prefix?: string;
14
+ }
15
+ /** Calls to Vercel Blob; replaceable in tests. */
16
+ interface VercelBlobClient {
17
+ put: typeof put;
18
+ del: typeof del;
19
+ get: typeof get;
20
+ }
21
+ /**
22
+ * Stores uploaded files in Vercel Blob, for sites on Vercel (whose disk doesn't keep files).
23
+ * Connect a Blob store to the project and `BLOB_READ_WRITE_TOKEN` is set for you.
24
+ */
25
+ declare function vercelBlobStorage(options?: VercelBlobStorageOptions, client?: VercelBlobClient): StorageAdapter;
26
+
27
+ export { type VercelBlobClient, type VercelBlobStorageOptions, vercelBlobStorage };
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ // src/index.ts
2
+ import { del, get, put } from "@vercel/blob";
3
+ function storeIdOf(token) {
4
+ const id = token.split("_")[3] ?? "";
5
+ if (!id) throw new Error("Vercel Blob: BLOB_READ_WRITE_TOKEN is not a read-write token");
6
+ return id;
7
+ }
8
+ function vercelBlobStorage(options = {}, client = { put, del, get }) {
9
+ const access = options.access ?? "public";
10
+ const prefix = options.prefix ?? "";
11
+ const token = () => {
12
+ const value = options.token ?? process.env.BLOB_READ_WRITE_TOKEN;
13
+ if (!value) throw new Error("Vercel Blob: set BLOB_READ_WRITE_TOKEN (connect a Blob store)");
14
+ return value;
15
+ };
16
+ return {
17
+ name: "vercel-blob",
18
+ async put(key, data, { contentType }) {
19
+ await client.put(`${prefix}${key}`, Buffer.from(data), {
20
+ access,
21
+ contentType,
22
+ token: token(),
23
+ addRandomSuffix: false
24
+ });
25
+ },
26
+ async get(key) {
27
+ const found = await client.get(`${prefix}${key}`, { access, token: token() });
28
+ if (found?.statusCode !== 200) return null;
29
+ const body = new Uint8Array(await new Response(found.stream).arrayBuffer());
30
+ return { body, size: body.byteLength };
31
+ },
32
+ async delete(key) {
33
+ await client.del(`${prefix}${key}`, { token: token() });
34
+ },
35
+ url(key) {
36
+ if (access !== "public") return void 0;
37
+ return `https://${storeIdOf(token())}.public.blob.vercel-storage.com/${prefix}${key}`;
38
+ }
39
+ };
40
+ }
41
+ export {
42
+ vercelBlobStorage
43
+ };
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "@easy-cms/storage-vercel-blob",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.36.0",
4
+ "description": "Vercel Blob upload storage for Easy CMS",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@vercel/blob": "^2.8.0"
20
+ },
21
+ "peerDependencies": {
22
+ "@easy-cms/core": "^0.36.1"
23
+ },
24
+ "devDependencies": {
25
+ "@easy-cms/core": "^0.36.1"
26
+ },
27
+ "engines": {
28
+ "node": ">=22.12"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/maritonx/easy-cms.git",
36
+ "directory": "packages/storage-vercel-blob"
37
+ },
38
+ "keywords": [
39
+ "easy-cms",
40
+ "storage",
41
+ "uploads",
42
+ "vercel",
43
+ "blob"
44
+ ],
45
+ "scripts": {
46
+ "build": "tsup",
47
+ "typecheck": "tsc --noEmit",
48
+ "test": "vitest run"
49
+ }
6
50
  }