next-tinacms-dos 0.0.0-cacbd0e-20250306051805 → 0.0.0-ccab7a5-20251124054446
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 +1 -1
- package/dist/handlers.js +4 -6
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -92,7 +92,7 @@ Call `createMediaHandler` to set up routes and connect your instance of the Medi
|
|
|
92
92
|
|
|
93
93
|
Import `isAuthorized` from [`@tinacms/auth`](https://github.com/tinacms/tinacms/tree/main/packages/%40tinacms/auth).
|
|
94
94
|
|
|
95
|
-
The `authorized` key will make it so only authorized users within
|
|
95
|
+
The `authorized` key will make it so only authorized users within TinaCloud can upload and make media edits.
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
```
|
package/dist/handlers.js
CHANGED
|
@@ -55,7 +55,7 @@ var createMediaHandler = (config, options) => {
|
|
|
55
55
|
mediaRoot = mediaRoot.substr(1);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
let cdnUrl =
|
|
58
|
+
let cdnUrl = options?.cdnUrl || config.config.endpoint.toString().replace(/http(s|):\/\//i, `https://${bucket}.`);
|
|
59
59
|
cdnUrl = cdnUrl + (cdnUrl.endsWith("/") ? "" : "/");
|
|
60
60
|
return async (req, res) => {
|
|
61
61
|
const isAuthorized = await config.authorized(req, res);
|
|
@@ -76,7 +76,6 @@ var createMediaHandler = (config, options) => {
|
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
78
|
async function uploadMedia(req, res, client, bucket, mediaRoot, cdnUrl) {
|
|
79
|
-
var _a;
|
|
80
79
|
const upload = (0, import_util.promisify)(
|
|
81
80
|
(0, import_multer.default)({
|
|
82
81
|
storage: import_multer.default.diskStorage({
|
|
@@ -96,7 +95,7 @@ async function uploadMedia(req, res, client, bucket, mediaRoot, cdnUrl) {
|
|
|
96
95
|
let prefix = directory.replace(/^\//, "").replace(/\/$/, "");
|
|
97
96
|
if (prefix) prefix = prefix + "/";
|
|
98
97
|
const filePath = req.file.path;
|
|
99
|
-
const fileType =
|
|
98
|
+
const fileType = req.file?.mimetype;
|
|
100
99
|
const blob = import_fs.default.readFileSync(filePath);
|
|
101
100
|
const filename = import_path.default.basename(filePath);
|
|
102
101
|
const params = {
|
|
@@ -145,7 +144,6 @@ function stripMediaRoot(mediaRoot, key) {
|
|
|
145
144
|
return keyParts.join("/");
|
|
146
145
|
}
|
|
147
146
|
async function listMedia(req, res, client, bucket, mediaRoot, cdnUrl) {
|
|
148
|
-
var _a;
|
|
149
147
|
try {
|
|
150
148
|
const {
|
|
151
149
|
directory = "",
|
|
@@ -158,12 +156,12 @@ async function listMedia(req, res, client, bucket, mediaRoot, cdnUrl) {
|
|
|
158
156
|
Bucket: bucket,
|
|
159
157
|
Delimiter: "/",
|
|
160
158
|
Prefix: mediaRoot ? import_path.default.join(mediaRoot, prefix) : prefix,
|
|
161
|
-
Marker: offset
|
|
159
|
+
Marker: offset?.toString(),
|
|
162
160
|
MaxKeys: directory && !offset ? +limit + 1 : +limit
|
|
163
161
|
};
|
|
164
162
|
const response = await client.send(new import_client_s3.ListObjectsCommand(params));
|
|
165
163
|
const items = [];
|
|
166
|
-
|
|
164
|
+
response.CommonPrefixes?.forEach(({ Prefix }) => {
|
|
167
165
|
const strippedPrefix = stripMediaRoot(mediaRoot, Prefix);
|
|
168
166
|
if (!strippedPrefix) {
|
|
169
167
|
return;
|
package/dist/index.js
CHANGED
|
@@ -13,27 +13,27 @@
|
|
|
13
13
|
const E_DEFAULT = new MediaListError({
|
|
14
14
|
title: "An Error Occurred",
|
|
15
15
|
message: "Something went wrong fetching your media from Digital Ocean Space.",
|
|
16
|
-
docsLink: "https://tina.io/
|
|
16
|
+
docsLink: "https://tina.io/docs/r/digital-ocean-spaces"
|
|
17
17
|
});
|
|
18
18
|
const E_UNAUTHORIZED = new MediaListError({
|
|
19
19
|
title: "Unauthorized",
|
|
20
20
|
message: "You don't have access to this resource.",
|
|
21
|
-
docsLink: "https://tina.io/
|
|
21
|
+
docsLink: "https://tina.io/docs/r/digital-ocean-spaces"
|
|
22
22
|
});
|
|
23
23
|
const E_CONFIG = new MediaListError({
|
|
24
24
|
title: "Missing Credentials",
|
|
25
25
|
message: "Unable to connect to Digital Ocean Space because one or more environment variables are missing.",
|
|
26
|
-
docsLink: "https://tina.io/docs/
|
|
26
|
+
docsLink: "https://tina.io/docs/r/digital-ocean-spaces/"
|
|
27
27
|
});
|
|
28
28
|
const E_KEY_FAIL = new MediaListError({
|
|
29
29
|
title: "Bad Credentials",
|
|
30
30
|
message: "Unable to connect to Digital Ocean Space because one or more environment variables are misconfigured.",
|
|
31
|
-
docsLink: "https://tina.io/docs/
|
|
31
|
+
docsLink: "https://tina.io/docs/r/digital-ocean-spaces/"
|
|
32
32
|
});
|
|
33
33
|
const E_BAD_ROUTE = new MediaListError({
|
|
34
34
|
title: "Bad Route",
|
|
35
35
|
message: "The Digital Ocean Space API route is missing or misconfigured.",
|
|
36
|
-
docsLink: "https://tina.io/
|
|
36
|
+
docsLink: "https://tina.io/docs/r/digital-ocean-spaces/#set-up-api-routes"
|
|
37
37
|
});
|
|
38
38
|
const interpretErrorMessage = (message) => {
|
|
39
39
|
switch (message) {
|
package/dist/index.mjs
CHANGED
|
@@ -10,27 +10,27 @@ class MediaListError extends Error {
|
|
|
10
10
|
const E_DEFAULT = new MediaListError({
|
|
11
11
|
title: "An Error Occurred",
|
|
12
12
|
message: "Something went wrong fetching your media from Digital Ocean Space.",
|
|
13
|
-
docsLink: "https://tina.io/
|
|
13
|
+
docsLink: "https://tina.io/docs/r/digital-ocean-spaces"
|
|
14
14
|
});
|
|
15
15
|
const E_UNAUTHORIZED = new MediaListError({
|
|
16
16
|
title: "Unauthorized",
|
|
17
17
|
message: "You don't have access to this resource.",
|
|
18
|
-
docsLink: "https://tina.io/
|
|
18
|
+
docsLink: "https://tina.io/docs/r/digital-ocean-spaces"
|
|
19
19
|
});
|
|
20
20
|
const E_CONFIG = new MediaListError({
|
|
21
21
|
title: "Missing Credentials",
|
|
22
22
|
message: "Unable to connect to Digital Ocean Space because one or more environment variables are missing.",
|
|
23
|
-
docsLink: "https://tina.io/docs/
|
|
23
|
+
docsLink: "https://tina.io/docs/r/digital-ocean-spaces/"
|
|
24
24
|
});
|
|
25
25
|
const E_KEY_FAIL = new MediaListError({
|
|
26
26
|
title: "Bad Credentials",
|
|
27
27
|
message: "Unable to connect to Digital Ocean Space because one or more environment variables are misconfigured.",
|
|
28
|
-
docsLink: "https://tina.io/docs/
|
|
28
|
+
docsLink: "https://tina.io/docs/r/digital-ocean-spaces/"
|
|
29
29
|
});
|
|
30
30
|
const E_BAD_ROUTE = new MediaListError({
|
|
31
31
|
title: "Bad Route",
|
|
32
32
|
message: "The Digital Ocean Space API route is missing or misconfigured.",
|
|
33
|
-
docsLink: "https://tina.io/
|
|
33
|
+
docsLink: "https://tina.io/docs/r/digital-ocean-spaces/#set-up-api-routes"
|
|
34
34
|
});
|
|
35
35
|
const interpretErrorMessage = (message) => {
|
|
36
36
|
switch (message) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-tinacms-dos",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-ccab7a5-20251124054446",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"files": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"tinacms": "0.0.0-
|
|
21
|
+
"tinacms": "0.0.0-ccab7a5-20251124054446"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/crypto-js": "^3.1.47",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"react": "^18.3.1",
|
|
29
29
|
"react-dom": "^18.3.1",
|
|
30
30
|
"typescript": "^5.7.3",
|
|
31
|
-
"@tinacms/scripts": "
|
|
32
|
-
"tinacms": "0.0.0-
|
|
31
|
+
"@tinacms/scripts": "0.0.0-ccab7a5-20251124054446",
|
|
32
|
+
"tinacms": "0.0.0-ccab7a5-20251124054446"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"registry": "https://registry.npmjs.org"
|