@tinacms/datalayer 1.3.16 → 1.3.18

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.
Files changed (2) hide show
  1. package/dist/index.js +7 -9
  2. package/package.json +3 -3
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,16 +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
71
  throw new Error(
73
72
  "Please name your next api route [...routes] not [route]"
74
73
  );
75
74
  }
76
- if (!(routes == null ? void 0 : routes.length)) {
75
+ if (!routes?.length) {
77
76
  console.error(
78
77
  `A request was made to ${opts.basePath} but no route was found`
79
78
  );
@@ -85,7 +84,6 @@ function MakeNodeApiHandler({
85
84
  const allRoutes = {
86
85
  gql: {
87
86
  handler: async (req2, res2, _opts) => {
88
- var _a2;
89
87
  if (req2.method !== "POST") {
90
88
  res2.statusCode = 405;
91
89
  res2.write(
@@ -122,7 +120,7 @@ function MakeNodeApiHandler({
122
120
  query,
123
121
  variables,
124
122
  // @ts-ignore
125
- user: (_a2 = req2 == null ? void 0 : req2.session) == null ? void 0 : _a2.user
123
+ user: req2?.session?.user
126
124
  });
127
125
  res2.statusCode = 200;
128
126
  res2.write(JSON.stringify(result));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/datalayer",
3
- "version": "1.3.16",
3
+ "version": "1.3.18",
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": "1.5.16"
34
+ "@tinacms/graphql": "1.5.18"
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": "1.3.4"
58
+ "@tinacms/scripts": "1.3.5"
59
59
  },
60
60
  "scripts": {
61
61
  "types": "pnpm tsc",