@lowdefy/server-dev 4.0.0-rc.9 → 4.0.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.
Files changed (57) hide show
  1. package/lib/{App.js → client/App.js} +5 -5
  2. package/lib/{Page.js → client/Page.js} +1 -1
  3. package/lib/{Reload.js → client/Reload.js} +1 -1
  4. package/lib/{RestartingPage.js → client/RestartingPage.js} +1 -1
  5. package/lib/{auth → client/auth}/Auth.js +2 -2
  6. package/lib/{auth → client/auth}/AuthConfigured.js +2 -2
  7. package/lib/{auth → client/auth}/AuthNotConfigured.js +1 -1
  8. package/lib/{setPageId.js → client/setPageId.js} +1 -1
  9. package/lib/{utils → client/utils}/request.js +1 -1
  10. package/lib/{utils → client/utils}/useMutateCache.js +1 -1
  11. package/lib/{utils → client/utils}/usePageConfig.js +1 -1
  12. package/lib/{utils → client/utils}/useRootConfig.js +1 -1
  13. package/lib/{utils → client/utils}/waitForRestartedServer.js +1 -1
  14. package/lib/server/apiWrapper.js +68 -0
  15. package/lib/server/auth/getAuthOptions.js +35 -0
  16. package/lib/{auth → server/auth}/getServerSession.js +4 -4
  17. package/lib/{fileCache.js → server/fileCache.js} +1 -1
  18. package/lib/server/log/createLogger.js +29 -0
  19. package/lib/server/log/logError.js +40 -0
  20. package/lib/server/log/logRequest.js +33 -0
  21. package/lib/server/validateLicense.js +40 -0
  22. package/manager/getContext.mjs +11 -6
  23. package/manager/processes/initialBuild.mjs +1 -1
  24. package/manager/processes/installPlugins.mjs +1 -1
  25. package/manager/processes/lowdefyBuild.mjs +3 -2
  26. package/manager/processes/nextBuild.mjs +1 -1
  27. package/manager/processes/readDotEnv.mjs +1 -1
  28. package/manager/processes/reloadClients.mjs +1 -1
  29. package/manager/processes/restartServer.mjs +1 -1
  30. package/manager/processes/shutdownServer.mjs +1 -1
  31. package/manager/processes/startServer.mjs +3 -2
  32. package/manager/processes/startWatchers.mjs +1 -1
  33. package/manager/run.mjs +1 -1
  34. package/manager/utils/BatchChanges.mjs +1 -1
  35. package/manager/utils/createCustomPluginTypesMap.mjs +2 -1
  36. package/manager/utils/createLogger.mjs +1 -2
  37. package/manager/utils/createStdOutLineHandler.mjs +33 -0
  38. package/manager/utils/getLowdefyVersion.mjs +1 -1
  39. package/manager/utils/getNextBin.mjs +1 -1
  40. package/manager/utils/setupWatcher.mjs +1 -1
  41. package/manager/watchers/envWatcher.mjs +1 -1
  42. package/manager/watchers/lowdefyBuildWatcher.mjs +1 -1
  43. package/manager/watchers/nextBuildWatcher.mjs +2 -2
  44. package/package.json +50 -46
  45. package/package.original.json +43 -38
  46. package/pages/404.js +2 -2
  47. package/pages/[pageId].js +2 -2
  48. package/pages/_app.js +9 -5
  49. package/pages/_document.js +1 -1
  50. package/pages/api/auth/[...nextauth].js +7 -20
  51. package/pages/api/license.js +22 -0
  52. package/pages/api/page/[pageId].js +8 -16
  53. package/pages/api/ping.js +1 -1
  54. package/pages/api/reload.js +1 -1
  55. package/pages/api/request/[pageId]/[requestId].js +13 -31
  56. package/pages/api/root.js +7 -17
  57. package/pages/index.js +2 -2
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ async function sha1(filePath) {
55
55
  return crypto
56
56
  .createHash('sha1')
57
57
  .update(content || '')
58
- .digest('hex');
58
+ .digest('base64');
59
59
  }
60
60
 
61
61
  async function nextBuildWatcher(context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "4.0.0-rc.9",
3
+ "version": "4.0.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -35,61 +35,65 @@
35
35
  ".eslintrc.yaml",
36
36
  ".npmrc"
37
37
  ],
38
- "scripts": {
39
- "build": "cp package.json package.original.json || copy package.json package.original.json",
40
- "start": "node manager/run.mjs",
41
- "lint": "next lint",
42
- "next": "next"
43
- },
44
38
  "dependencies": {
45
- "@lowdefy/actions-core": "4.0.0-rc.9",
46
- "@lowdefy/api": "4.0.0-rc.9",
47
- "@lowdefy/blocks-antd": "4.0.0-rc.9",
48
- "@lowdefy/blocks-basic": "4.0.0-rc.9",
49
- "@lowdefy/blocks-color-selectors": "4.0.0-rc.9",
50
- "@lowdefy/blocks-echarts": "4.0.0-rc.9",
51
- "@lowdefy/blocks-loaders": "4.0.0-rc.9",
52
- "@lowdefy/blocks-markdown": "4.0.0-rc.9",
53
- "@lowdefy/blocks-qr": "4.0.0-rc.9",
54
- "@lowdefy/build": "4.0.0-rc.9",
55
- "@lowdefy/client": "4.0.0-rc.9",
56
- "@lowdefy/connection-axios-http": "4.0.0-rc.9",
57
- "@lowdefy/engine": "4.0.0-rc.9",
58
- "@lowdefy/helpers": "4.0.0-rc.9",
59
- "@lowdefy/layout": "4.0.0-rc.9",
60
- "@lowdefy/node-utils": "4.0.0-rc.9",
61
- "@lowdefy/operators-change-case": "4.0.0-rc.9",
62
- "@lowdefy/operators-diff": "4.0.0-rc.9",
63
- "@lowdefy/operators-js": "4.0.0-rc.9",
64
- "@lowdefy/operators-mql": "4.0.0-rc.9",
65
- "@lowdefy/operators-nunjucks": "4.0.0-rc.9",
66
- "@lowdefy/operators-uuid": "4.0.0-rc.9",
67
- "@lowdefy/operators-yaml": "4.0.0-rc.9",
68
- "@lowdefy/plugin-next-auth": "4.0.0-rc.9",
39
+ "@lowdefy/actions-core": "4.0.1",
40
+ "@lowdefy/api": "4.0.1",
41
+ "@lowdefy/block-utils": "4.0.1",
42
+ "@lowdefy/blocks-aggrid": "4.0.1",
43
+ "@lowdefy/blocks-antd": "4.0.1",
44
+ "@lowdefy/blocks-basic": "4.0.1",
45
+ "@lowdefy/blocks-color-selectors": "4.0.1",
46
+ "@lowdefy/blocks-echarts": "4.0.1",
47
+ "@lowdefy/blocks-loaders": "4.0.1",
48
+ "@lowdefy/blocks-markdown": "4.0.1",
49
+ "@lowdefy/blocks-qr": "4.0.1",
50
+ "@lowdefy/build": "4.0.1",
51
+ "@lowdefy/client": "4.0.1",
52
+ "@lowdefy/connection-axios-http": "4.0.1",
53
+ "@lowdefy/engine": "4.0.1",
54
+ "@lowdefy/helpers": "4.0.1",
55
+ "@lowdefy/layout": "4.0.1",
56
+ "@lowdefy/node-utils": "4.0.1",
57
+ "@lowdefy/operators-change-case": "4.0.1",
58
+ "@lowdefy/operators-diff": "4.0.1",
59
+ "@lowdefy/operators-js": "4.0.1",
60
+ "@lowdefy/operators-moment": "4.0.1",
61
+ "@lowdefy/operators-mql": "4.0.1",
62
+ "@lowdefy/operators-nunjucks": "4.0.1",
63
+ "@lowdefy/operators-uuid": "4.0.1",
64
+ "@lowdefy/operators-yaml": "4.0.1",
65
+ "@lowdefy/plugin-next-auth": "4.0.1",
69
66
  "chokidar": "3.5.3",
70
- "dotenv": "16.0.3",
71
- "next": "12.3.1",
72
- "next-auth": "4.20.1",
67
+ "dotenv": "16.3.1",
68
+ "next": "13.5.4",
69
+ "next-auth": "4.24.5",
73
70
  "opener": "1.5.2",
74
- "pino": "8.8.0",
71
+ "pino": "8.16.2",
75
72
  "process": "0.11.10",
76
73
  "react": "18.2.0",
77
74
  "react-dom": "18.2.0",
78
- "react-icons": "4.7.1",
79
- "swr": "2.0.0",
80
- "yaml": "2.2.2",
81
- "yargs": "17.6.2"
75
+ "react-icons": "4.12.0",
76
+ "swr": "2.2.4",
77
+ "yaml": "2.3.4",
78
+ "yargs": "17.7.2"
82
79
  },
83
80
  "devDependencies": {
84
- "@next/eslint-plugin-next": "12.1.6",
81
+ "@next/eslint-plugin-next": "13.5.4",
85
82
  "less": "4.1.3",
86
- "less-loader": "11.1.0",
87
- "next-with-less": "2.0.5",
88
- "webpack": "5.76.0"
83
+ "less-loader": "11.1.3",
84
+ "next-with-less": "3.0.1",
85
+ "webpack": "5.89.0"
86
+ },
87
+ "engines": {
88
+ "node": ">=18"
89
89
  },
90
- "packageManager": "pnpm@7.11.0",
91
90
  "publishConfig": {
92
91
  "access": "public"
93
92
  },
94
- "gitHead": "d20e6ac424643feca527a732dc2b0710713c8243"
95
- }
93
+ "scripts": {
94
+ "build": "cp package.json package.original.json || copy package.json package.original.json",
95
+ "start": "node manager/run.mjs",
96
+ "lint": "next lint",
97
+ "next": "next"
98
+ }
99
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "4.0.0-rc.9",
3
+ "version": "4.0.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -42,52 +42,57 @@
42
42
  "next": "next"
43
43
  },
44
44
  "dependencies": {
45
- "@lowdefy/actions-core": "4.0.0-rc.9",
46
- "@lowdefy/api": "4.0.0-rc.9",
47
- "@lowdefy/blocks-antd": "4.0.0-rc.9",
48
- "@lowdefy/blocks-basic": "4.0.0-rc.9",
49
- "@lowdefy/blocks-color-selectors": "4.0.0-rc.9",
50
- "@lowdefy/blocks-echarts": "4.0.0-rc.9",
51
- "@lowdefy/blocks-loaders": "4.0.0-rc.9",
52
- "@lowdefy/blocks-markdown": "4.0.0-rc.9",
53
- "@lowdefy/blocks-qr": "4.0.0-rc.9",
54
- "@lowdefy/build": "4.0.0-rc.9",
55
- "@lowdefy/client": "4.0.0-rc.9",
56
- "@lowdefy/connection-axios-http": "4.0.0-rc.9",
57
- "@lowdefy/engine": "4.0.0-rc.9",
58
- "@lowdefy/helpers": "4.0.0-rc.9",
59
- "@lowdefy/layout": "4.0.0-rc.9",
60
- "@lowdefy/node-utils": "4.0.0-rc.9",
61
- "@lowdefy/operators-change-case": "4.0.0-rc.9",
62
- "@lowdefy/operators-diff": "4.0.0-rc.9",
63
- "@lowdefy/operators-js": "4.0.0-rc.9",
64
- "@lowdefy/operators-mql": "4.0.0-rc.9",
65
- "@lowdefy/operators-nunjucks": "4.0.0-rc.9",
66
- "@lowdefy/operators-uuid": "4.0.0-rc.9",
67
- "@lowdefy/operators-yaml": "4.0.0-rc.9",
68
- "@lowdefy/plugin-next-auth": "4.0.0-rc.9",
45
+ "@lowdefy/actions-core": "4.0.1",
46
+ "@lowdefy/api": "4.0.1",
47
+ "@lowdefy/block-utils": "4.0.1",
48
+ "@lowdefy/blocks-aggrid": "4.0.1",
49
+ "@lowdefy/blocks-antd": "4.0.1",
50
+ "@lowdefy/blocks-basic": "4.0.1",
51
+ "@lowdefy/blocks-color-selectors": "4.0.1",
52
+ "@lowdefy/blocks-echarts": "4.0.1",
53
+ "@lowdefy/blocks-loaders": "4.0.1",
54
+ "@lowdefy/blocks-markdown": "4.0.1",
55
+ "@lowdefy/blocks-qr": "4.0.1",
56
+ "@lowdefy/build": "4.0.1",
57
+ "@lowdefy/client": "4.0.1",
58
+ "@lowdefy/connection-axios-http": "4.0.1",
59
+ "@lowdefy/engine": "4.0.1",
60
+ "@lowdefy/helpers": "4.0.1",
61
+ "@lowdefy/layout": "4.0.1",
62
+ "@lowdefy/node-utils": "4.0.1",
63
+ "@lowdefy/operators-change-case": "4.0.1",
64
+ "@lowdefy/operators-diff": "4.0.1",
65
+ "@lowdefy/operators-js": "4.0.1",
66
+ "@lowdefy/operators-moment": "4.0.1",
67
+ "@lowdefy/operators-mql": "4.0.1",
68
+ "@lowdefy/operators-nunjucks": "4.0.1",
69
+ "@lowdefy/operators-uuid": "4.0.1",
70
+ "@lowdefy/operators-yaml": "4.0.1",
71
+ "@lowdefy/plugin-next-auth": "4.0.1",
69
72
  "chokidar": "3.5.3",
70
- "dotenv": "16.0.3",
71
- "next": "12.3.1",
72
- "next-auth": "4.20.1",
73
+ "dotenv": "16.3.1",
74
+ "next": "13.5.4",
75
+ "next-auth": "4.24.5",
73
76
  "opener": "1.5.2",
74
- "pino": "8.8.0",
77
+ "pino": "8.16.2",
75
78
  "process": "0.11.10",
76
79
  "react": "18.2.0",
77
80
  "react-dom": "18.2.0",
78
- "react-icons": "4.7.1",
79
- "swr": "2.0.0",
80
- "yaml": "2.2.2",
81
- "yargs": "17.6.2"
81
+ "react-icons": "4.12.0",
82
+ "swr": "2.2.4",
83
+ "yaml": "2.3.4",
84
+ "yargs": "17.7.2"
82
85
  },
83
86
  "devDependencies": {
84
- "@next/eslint-plugin-next": "12.1.6",
87
+ "@next/eslint-plugin-next": "13.5.4",
85
88
  "less": "4.1.3",
86
- "less-loader": "11.1.0",
87
- "next-with-less": "2.0.5",
88
- "webpack": "5.76.0"
89
+ "less-loader": "11.1.3",
90
+ "next-with-less": "3.0.1",
91
+ "webpack": "5.89.0"
92
+ },
93
+ "engines": {
94
+ "node": ">=18"
89
95
  },
90
- "packageManager": "pnpm@7.11.0",
91
96
  "publishConfig": {
92
97
  "access": "public"
93
98
  }
package/pages/404.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,6 +14,6 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import App from '../lib/App.js';
17
+ import App from '../lib/client/App.js';
18
18
 
19
19
  export default App;
package/pages/[pageId].js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,6 +14,6 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import App from '../lib/App.js';
17
+ import App from '../lib/client/App.js';
18
18
 
19
19
  export default App;
package/pages/_app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -17,7 +17,9 @@
17
17
  import React, { Suspense, useRef } from 'react';
18
18
  import dynamic from 'next/dynamic';
19
19
 
20
- import Auth from '../lib/auth/Auth.js';
20
+ import { ErrorBoundary } from '@lowdefy/block-utils';
21
+
22
+ import Auth from '../lib/client/auth/Auth.js';
21
23
 
22
24
  // Must be in _app due to next specifications.
23
25
  import '../build/plugins/styles.less';
@@ -25,9 +27,11 @@ import '../build/plugins/styles.less';
25
27
  function App({ Component }) {
26
28
  const lowdefyRef = useRef({});
27
29
  return (
28
- <Suspense fallback="">
29
- <Auth>{(auth) => <Component auth={auth} lowdefy={lowdefyRef.current} />}</Auth>
30
- </Suspense>
30
+ <ErrorBoundary fullPage>
31
+ <Suspense fallback="">
32
+ <Auth>{(auth) => <Component auth={auth} lowdefy={lowdefyRef.current} />}</Auth>
33
+ </Suspense>
34
+ </ErrorBoundary>
31
35
  );
32
36
  }
33
37
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -15,36 +15,23 @@
15
15
  */
16
16
 
17
17
  import NextAuth from 'next-auth';
18
- import { createApiContext, getNextAuthConfig } from '@lowdefy/api';
19
18
 
19
+ import apiWrapper from '../../../lib/server/apiWrapper.js';
20
20
  import authJson from '../../../build/auth.json';
21
- import config from '../../../build/config.json';
22
- import adapters from '../../../build/plugins/auth/adapters.js';
23
- import callbacks from '../../../build/plugins/auth/callbacks.js';
24
- import events from '../../../build/plugins/auth/events.js';
25
- import fileCache from '../../../lib/fileCache.js';
26
- import providers from '../../../build/plugins/auth/providers.js';
27
-
28
- export const authOptions = getNextAuthConfig(
29
- createApiContext({
30
- config,
31
- fileCache,
32
- logger: console,
33
- }),
34
- { authJson, plugins: { adapters, callbacks, events, providers } }
35
- );
36
-
37
- export default async function auth(req, res) {
21
+
22
+ async function handler({ context, req, res }) {
38
23
  if (authJson.configured === true) {
39
24
  // Required for emails in corporate networks, see:
40
25
  // https://next-auth.js.org/tutorials/avoid-corporate-link-checking-email-provider
41
26
  if (req.method === 'HEAD') {
42
27
  return res.status(200).end();
43
28
  }
44
- return await NextAuth(req, res, authOptions);
29
+ return await NextAuth(req, res, context.authOptions);
45
30
  }
46
31
 
47
32
  return res.status(404).json({
48
33
  message: 'Auth not configured',
49
34
  });
50
35
  }
36
+
37
+ export default apiWrapper(handler);
@@ -0,0 +1,22 @@
1
+ /*
2
+ Copyright (C) 2023 Lowdefy, Inc
3
+ Use of this software is governed by the Business Source License included in the LICENSE file and at www.mariadb.com/bsl11.
4
+
5
+ Change Date: 2027-10-09
6
+
7
+ On the date above, in accordance with the Business Source License, use
8
+ of this software will be governed by the Apache License, Version 2.0.
9
+ */
10
+ import apiWrapper from '../../lib/server/apiWrapper.js';
11
+ import validateLicense from '../../lib/server/validateLicense.js';
12
+
13
+ async function handler({ req, res }) {
14
+ if (req.method !== 'GET') {
15
+ throw new Error('Only GET requests are supported.');
16
+ }
17
+
18
+ const { code, entitlements } = await validateLicense();
19
+ return res.status(200).json({ code, entitlements });
20
+ }
21
+
22
+ export default apiWrapper(handler);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,27 +14,19 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import { createApiContext, getPageConfig } from '@lowdefy/api';
17
+ import { getPageConfig } from '@lowdefy/api';
18
18
 
19
- import config from '../../../build/config.json';
20
- import fileCache from '../../../lib/fileCache.js';
21
- import getServerSession from '../../../lib/auth/getServerSession.js';
22
-
23
- export default async function handler(req, res) {
24
- const session = await getServerSession({ req, res });
25
- const apiContext = createApiContext({
26
- buildDirectory: './build',
27
- config,
28
- fileCache,
29
- logger: console,
30
- session,
31
- });
19
+ import apiWrapper from '../../../lib/server/apiWrapper.js';
32
20
 
21
+ async function handler({ context, req, res }) {
33
22
  const { pageId } = req.query;
34
- const pageConfig = await getPageConfig(apiContext, { pageId });
23
+ const pageConfig = await getPageConfig(context, { pageId });
24
+ // TODO: Do we log here?
35
25
  if (pageConfig === null) {
36
26
  res.status(404).send('Page not found.');
37
27
  } else {
38
28
  res.status(200).json(pageConfig);
39
29
  }
40
30
  }
31
+
32
+ export default apiWrapper(handler);
package/pages/api/ping.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,37 +14,19 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import { callRequest, createApiContext } from '@lowdefy/api';
18
- import { getSecretsFromEnv } from '@lowdefy/node-utils';
17
+ import { callRequest } from '@lowdefy/api';
19
18
 
20
- import config from '../../../../build/config.json';
21
- import connections from '../../../../build/plugins/connections.js';
22
- import fileCache from '../../../../lib/fileCache.js';
23
- import getServerSession from '../../../../lib/auth/getServerSession.js';
24
- import operators from '../../../../build/plugins/operators/server.js';
19
+ import apiWrapper from '../../../../lib/server/apiWrapper.js';
25
20
 
26
- export default async function handler(req, res) {
27
- try {
28
- if (req.method !== 'POST') {
29
- throw new Error('Only POST requests are supported.');
30
- }
31
- const session = await getServerSession({ req, res });
32
- const apiContext = createApiContext({
33
- buildDirectory: './build',
34
- config,
35
- connections,
36
- fileCache,
37
- logger: console,
38
- operators,
39
- secrets: getSecretsFromEnv(),
40
- session,
41
- });
42
-
43
- const { blockId, pageId, requestId } = req.query;
44
- const { payload } = req.body;
45
- const response = await callRequest(apiContext, { blockId, pageId, payload, requestId });
46
- res.status(200).json(response);
47
- } catch (error) {
48
- res.status(500).json({ name: error.name, message: error.message });
21
+ async function handler({ context, req, res }) {
22
+ if (req.method !== 'POST') {
23
+ throw new Error('Only POST requests are supported.');
49
24
  }
25
+ const { pageId, requestId } = req.query;
26
+ const { blockId, payload } = req.body;
27
+ context.logger.info({ event: 'call_request', pageId, requestId, blockId });
28
+ const response = await callRequest(context, { blockId, pageId, payload, requestId });
29
+ res.status(200).json(response);
50
30
  }
31
+
32
+ export default apiWrapper(handler);
package/pages/api/root.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,22 +14,12 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import { createApiContext, getRootConfig } from '@lowdefy/api';
18
-
19
- import config from '../../build/config.json';
20
- import fileCache from '../../lib/fileCache.js';
21
- import getServerSession from '../../lib/auth/getServerSession.js';
22
-
23
- export default async function handler(req, res) {
24
- const session = await getServerSession({ req, res });
25
- const apiContext = createApiContext({
26
- buildDirectory: './build',
27
- config,
28
- fileCache,
29
- logger: console,
30
- session,
31
- });
32
- const rootConfig = await getRootConfig(apiContext);
17
+ import { getRootConfig } from '@lowdefy/api';
18
+ import apiWrapper from '../../lib/server/apiWrapper.js';
33
19
 
20
+ async function handler({ context, res }) {
21
+ const rootConfig = await getRootConfig(context);
34
22
  res.status(200).json(rootConfig);
35
23
  }
24
+
25
+ export default apiWrapper(handler);
package/pages/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,6 +14,6 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import App from '../lib/App.js';
17
+ import App from '../lib/client/App.js';
18
18
 
19
19
  export default App;