@tinacms/datalayer 0.0.0-a6daef4-20250115020754 → 0.0.0-ab51af8-20251124045003
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/dist/index.js +16 -14
- package/dist/index.mjs +6 -2
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -17,8 +17,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
19
|
// src/index.ts
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
22
|
AuditFileSystemBridge: () => import_graphql.AuditFileSystemBridge,
|
|
23
23
|
FilesystemBridge: () => import_graphql.FilesystemBridge,
|
|
24
24
|
IsomorphicBridge: () => import_graphql.IsomorphicBridge,
|
|
@@ -29,7 +29,7 @@ __export(src_exports, {
|
|
|
29
29
|
createLocalDatabase: () => import_graphql.createLocalDatabase,
|
|
30
30
|
resolve: () => import_graphql.resolve
|
|
31
31
|
});
|
|
32
|
-
module.exports = __toCommonJS(
|
|
32
|
+
module.exports = __toCommonJS(index_exports);
|
|
33
33
|
var import_graphql = require("@tinacms/graphql");
|
|
34
34
|
|
|
35
35
|
// src/backend/index.ts
|
|
@@ -42,10 +42,10 @@ function TinaNodeBackend({
|
|
|
42
42
|
options
|
|
43
43
|
}) {
|
|
44
44
|
const { initialize, isAuthorized, extraRoutes } = authProvider;
|
|
45
|
-
initialize
|
|
45
|
+
initialize?.().catch((e) => {
|
|
46
46
|
console.error(e);
|
|
47
47
|
});
|
|
48
|
-
const basePath =
|
|
48
|
+
const basePath = options?.basePath ? `/${options.basePath.replace(/^\/?/, "").replace(/\/?$/, "")}/` : "/api/tina/";
|
|
49
49
|
const opts = {
|
|
50
50
|
basePath
|
|
51
51
|
};
|
|
@@ -64,14 +64,15 @@ function MakeNodeApiHandler({
|
|
|
64
64
|
opts
|
|
65
65
|
}) {
|
|
66
66
|
const tinaBackendHandler = async (req, res) => {
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const routes = (_d = (_c = url.pathname) == null ? void 0 : _c.replace(opts.basePath, "")) == null ? void 0 : _d.split("/");
|
|
67
|
+
const path = req.url?.startsWith("/") ? req.url.slice(1) : req.url;
|
|
68
|
+
const url = new URL(path, `http://${req.headers?.host || "localhost"}`);
|
|
69
|
+
const routes = url.pathname?.replace(opts.basePath, "")?.split("/");
|
|
71
70
|
if (typeof routes === "string") {
|
|
72
|
-
throw new Error(
|
|
71
|
+
throw new Error(
|
|
72
|
+
"Please name your next api route [...routes] not [route]"
|
|
73
|
+
);
|
|
73
74
|
}
|
|
74
|
-
if (!
|
|
75
|
+
if (!routes?.length) {
|
|
75
76
|
console.error(
|
|
76
77
|
`A request was made to ${opts.basePath} but no route was found`
|
|
77
78
|
);
|
|
@@ -83,7 +84,6 @@ function MakeNodeApiHandler({
|
|
|
83
84
|
const allRoutes = {
|
|
84
85
|
gql: {
|
|
85
86
|
handler: async (req2, res2, _opts) => {
|
|
86
|
-
var _a2;
|
|
87
87
|
if (req2.method !== "POST") {
|
|
88
88
|
res2.statusCode = 405;
|
|
89
89
|
res2.write(
|
|
@@ -120,7 +120,7 @@ function MakeNodeApiHandler({
|
|
|
120
120
|
query,
|
|
121
121
|
variables,
|
|
122
122
|
// @ts-ignore
|
|
123
|
-
user:
|
|
123
|
+
user: req2?.session?.user
|
|
124
124
|
});
|
|
125
125
|
res2.statusCode = 200;
|
|
126
126
|
res2.write(JSON.stringify(result));
|
|
@@ -146,7 +146,9 @@ function MakeNodeApiHandler({
|
|
|
146
146
|
const isAuth = await isAuthorized(req, res);
|
|
147
147
|
if (isAuth.isAuthorized === false) {
|
|
148
148
|
res.statusCode = isAuth.errorCode;
|
|
149
|
-
res.write(
|
|
149
|
+
res.write(
|
|
150
|
+
JSON.stringify({ error: isAuth.errorMessage || "not found" })
|
|
151
|
+
);
|
|
150
152
|
res.end();
|
|
151
153
|
return;
|
|
152
154
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -45,7 +45,9 @@ function MakeNodeApiHandler({
|
|
|
45
45
|
const url = new URL(path, `http://${req.headers?.host || "localhost"}`);
|
|
46
46
|
const routes = url.pathname?.replace(opts.basePath, "")?.split("/");
|
|
47
47
|
if (typeof routes === "string") {
|
|
48
|
-
throw new Error(
|
|
48
|
+
throw new Error(
|
|
49
|
+
"Please name your next api route [...routes] not [route]"
|
|
50
|
+
);
|
|
49
51
|
}
|
|
50
52
|
if (!routes?.length) {
|
|
51
53
|
console.error(
|
|
@@ -121,7 +123,9 @@ function MakeNodeApiHandler({
|
|
|
121
123
|
const isAuth = await isAuthorized(req, res);
|
|
122
124
|
if (isAuth.isAuthorized === false) {
|
|
123
125
|
res.statusCode = isAuth.errorCode;
|
|
124
|
-
res.write(
|
|
126
|
+
res.write(
|
|
127
|
+
JSON.stringify({ error: isAuth.errorMessage || "not found" })
|
|
128
|
+
);
|
|
125
129
|
res.end();
|
|
126
130
|
return;
|
|
127
131
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/datalayer",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-ab51af8-20251124045003",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"typings": "dist/index",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tinacms/graphql": "0.0.0-
|
|
34
|
+
"@tinacms/graphql": "0.0.0-ab51af8-20251124045003"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"registry": "https://registry.npmjs.org"
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"@types/level": "^6.0.3",
|
|
48
48
|
"@types/lodash.camelcase": "^4.3.9",
|
|
49
49
|
"@types/lodash.upperfirst": "^4.3.9",
|
|
50
|
-
"@types/node": "^22.
|
|
50
|
+
"@types/node": "^22.13.1",
|
|
51
51
|
"@types/normalize-path": "^3.0.2",
|
|
52
52
|
"@types/yup": "^0.29.14",
|
|
53
53
|
"jest": "^29.7.0",
|
|
54
54
|
"jest-diff": "^29.7.0",
|
|
55
55
|
"jest-file-snapshot": "^0.5.0",
|
|
56
56
|
"jest-matcher-utils": "^29.7.0",
|
|
57
|
-
"typescript": "^5.
|
|
58
|
-
"@tinacms/scripts": "
|
|
57
|
+
"typescript": "^5.7.3",
|
|
58
|
+
"@tinacms/scripts": "0.0.0-ab51af8-20251124045003"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"types": "pnpm tsc",
|