@nuxt-atelier/storage-vercel-blob 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/module.d.mts +5 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +17 -0
- package/dist/runtime/driver.d.ts +9 -0
- package/dist/runtime/driver.js +45 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.js +11 -0
- package/dist/types.d.mts +7 -0
- package/package.json +44 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ano Rebel
|
|
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,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nuxt-atelier/storage-vercel-blob
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vercel Blob media storage driver for Nuxt Atelier
|
|
4
|
+
|
|
5
|
+
Part of [Nuxt Atelier](https://nuxt-atelier.anorebel.net), a visual CMS for Nuxt. See the [documentation](https://nuxt-atelier.anorebel.net) to get started, or try the [live demo](https://nuxt-atelier-demo.anorebel.net).
|
|
6
|
+
|
|
7
|
+
MIT License
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addServerPlugin } from '@nuxt/kit';
|
|
2
|
+
|
|
3
|
+
const module$1 = defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "@nuxt-atelier/storage-vercel-blob",
|
|
6
|
+
compatibility: {
|
|
7
|
+
nuxt: ">=4.6.0"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
setup(_, nuxt) {
|
|
11
|
+
const { resolve } = createResolver(import.meta.url);
|
|
12
|
+
nuxt.options.runtimeConfig.atelierVercelBlob = { token: "", ...nuxt.options.runtimeConfig.atelierVercelBlob };
|
|
13
|
+
addServerPlugin(resolve("./runtime/plugin"));
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StorageDriver } from 'nuxt-atelier/storage';
|
|
2
|
+
import * as blob from '@vercel/blob';
|
|
3
|
+
export interface VercelBlobOptions {
|
|
4
|
+
/** The store's read-write token (BLOB_READ_WRITE_TOKEN). */
|
|
5
|
+
token: string;
|
|
6
|
+
}
|
|
7
|
+
/** The SDK functions the driver uses: the real ones, or a stand-in in tests. */
|
|
8
|
+
export type BlobSdk = Pick<typeof blob, 'put' | 'get' | 'head' | 'del' | 'list' | 'BlobNotFoundError'>;
|
|
9
|
+
export declare function createVercelBlobDriver(options: VercelBlobOptions, sdk?: BlobSdk): StorageDriver;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as blob from "@vercel/blob";
|
|
2
|
+
export function createVercelBlobDriver(options, sdk = blob) {
|
|
3
|
+
const { token } = options;
|
|
4
|
+
const { put, get, head, del } = sdk;
|
|
5
|
+
const missing = (error) => error instanceof sdk.BlobNotFoundError;
|
|
6
|
+
return {
|
|
7
|
+
name: "vercel-blob",
|
|
8
|
+
async put(key, body, info) {
|
|
9
|
+
await put(key, body, { access: "private", token, contentType: info.contentType, addRandomSuffix: false, allowOverwrite: true, multipart: true });
|
|
10
|
+
},
|
|
11
|
+
async get(key) {
|
|
12
|
+
try {
|
|
13
|
+
const result = await get(key, { access: "private", token });
|
|
14
|
+
if (!result || result.statusCode !== 200)
|
|
15
|
+
return void 0;
|
|
16
|
+
return { stream: result.stream, size: result.blob.size };
|
|
17
|
+
} catch (error) {
|
|
18
|
+
if (missing(error))
|
|
19
|
+
return void 0;
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
async head(key) {
|
|
24
|
+
try {
|
|
25
|
+
return { size: (await head(key, { token })).size };
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (missing(error))
|
|
28
|
+
return void 0;
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
async delete(key) {
|
|
33
|
+
await del(key, { token });
|
|
34
|
+
},
|
|
35
|
+
async deletePrefix(prefix) {
|
|
36
|
+
let cursor;
|
|
37
|
+
do {
|
|
38
|
+
const page = await sdk.list({ prefix, token, cursor });
|
|
39
|
+
if (page.blobs.length)
|
|
40
|
+
await del(page.blobs.map((b) => b.url), { token });
|
|
41
|
+
cursor = page.hasMore ? page.cursor : void 0;
|
|
42
|
+
} while (cursor);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { registerStorageDriver } from "#atelier/server";
|
|
2
|
+
import { useRuntimeConfig } from "nuxt/server";
|
|
3
|
+
import { createVercelBlobDriver } from "./driver.js";
|
|
4
|
+
export default () => {
|
|
5
|
+
registerStorageDriver(() => {
|
|
6
|
+
const token = useRuntimeConfig().atelierVercelBlob.token || process.env.BLOB_READ_WRITE_TOKEN;
|
|
7
|
+
if (!token)
|
|
8
|
+
throw new Error("[@nuxt-atelier/storage-vercel-blob] Connect a Blob store to the project (it sets BLOB_READ_WRITE_TOKEN), or set NUXT_ATELIER_VERCEL_BLOB_TOKEN");
|
|
9
|
+
return createVercelBlobDriver({ token });
|
|
10
|
+
});
|
|
11
|
+
};
|
package/dist/types.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt-atelier/storage-vercel-blob",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/AnoRebel/nuxt-atelier.git",
|
|
9
|
+
"directory": "packages/storage-vercel-blob"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://nuxt-atelier.anorebel.net",
|
|
12
|
+
"description": "Vercel Blob media storage driver for Nuxt Atelier",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/types.d.mts",
|
|
16
|
+
"import": "./dist/module.mjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"main": "./dist/module.mjs",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
"*": {
|
|
22
|
+
".": [
|
|
23
|
+
"./dist/types.d.mts"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "nuxt-module-build build",
|
|
32
|
+
"prepack": "nuxt-module-build build",
|
|
33
|
+
"check:pkg": "publint --pack bun && attw --pack . --profile esm-only"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"nuxt": ">=4.6.0"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@nuxt/kit": "^4.6.3",
|
|
40
|
+
"@vercel/blob": "2.8.2",
|
|
41
|
+
"nuxt-atelier": "0.1.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@nuxt/schema": "4.6.3"
|
|
45
|
+
}
|
|
46
|
+
}
|