@tinacms/datalayer 0.0.0-db8aa8e-20250228034006 → 0.0.0-ddc5e8e-20250611011547

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 CHANGED
@@ -42,10 +42,10 @@ function TinaNodeBackend({
42
42
  options
43
43
  }) {
44
44
  const { initialize, isAuthorized, extraRoutes } = authProvider;
45
- initialize == null ? void 0 : initialize().catch((e) => {
45
+ initialize?.().catch((e) => {
46
46
  console.error(e);
47
47
  });
48
- const basePath = (options == null ? void 0 : options.basePath) ? `/${options.basePath.replace(/^\/?/, "").replace(/\/?$/, "")}/` : "/api/tina/";
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
- var _a, _b, _c, _d;
68
- const path = ((_a = req.url) == null ? void 0 : _a.startsWith("/")) ? req.url.slice(1) : req.url;
69
- const url = new URL(path, `http://${((_b = req.headers) == null ? void 0 : _b.host) || "localhost"}`);
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("Please name your next api route [...routes] not [route]");
71
+ throw new Error(
72
+ "Please name your next api route [...routes] not [route]"
73
+ );
73
74
  }
74
- if (!(routes == null ? void 0 : routes.length)) {
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: (_a2 = req2 == null ? void 0 : req2.session) == null ? void 0 : _a2.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(JSON.stringify({ error: isAuth.errorMessage || "not found" }));
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("Please name your next api route [...routes] not [route]");
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(JSON.stringify({ error: isAuth.errorMessage || "not found" }));
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-db8aa8e-20250228034006",
3
+ "version": "0.0.0-ddc5e8e-20250611011547",
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-db8aa8e-20250228034006"
34
+ "@tinacms/graphql": "0.0.0-ddc5e8e-20250611011547"
35
35
  },
36
36
  "publishConfig": {
37
37
  "registry": "https://registry.npmjs.org"
@@ -55,7 +55,7 @@
55
55
  "jest-file-snapshot": "^0.5.0",
56
56
  "jest-matcher-utils": "^29.7.0",
57
57
  "typescript": "^5.7.3",
58
- "@tinacms/scripts": "0.0.0-db8aa8e-20250228034006"
58
+ "@tinacms/scripts": "0.0.0-ddc5e8e-20250611011547"
59
59
  },
60
60
  "scripts": {
61
61
  "types": "pnpm tsc",