@lowdefy/server-dev 4.0.0-alpha.9 → 4.0.0-rc.0

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 (50) hide show
  1. package/.npmrc +1 -0
  2. package/lib/App.js +67 -0
  3. package/lib/Page.js +50 -0
  4. package/lib/Reload.js +52 -0
  5. package/lib/RestartingPage.js +47 -0
  6. package/lib/auth/Auth.js +35 -0
  7. package/lib/auth/AuthConfigured.js +47 -0
  8. package/lib/auth/AuthNotConfigured.js +32 -0
  9. package/lib/auth/getServerSession.js +28 -0
  10. package/lib/fileCache.js +20 -0
  11. package/lib/setPageId.js +30 -0
  12. package/lib/utils/request.js +38 -0
  13. package/lib/utils/useMutateCache.js +34 -0
  14. package/lib/utils/usePageConfig.js +27 -0
  15. package/lib/utils/useRootConfig.js +26 -0
  16. package/lib/utils/waitForRestartedServer.js +38 -0
  17. package/manager/getContext.mjs +77 -0
  18. package/manager/processes/initialBuild.mjs +27 -0
  19. package/manager/processes/installPlugins.mjs +31 -0
  20. package/manager/processes/lowdefyBuild.mjs +34 -0
  21. package/manager/processes/nextBuild.mjs +31 -0
  22. package/manager/processes/readDotEnv.mjs +26 -0
  23. package/manager/processes/reloadClients.mjs +26 -0
  24. package/manager/processes/restartServer.mjs +28 -0
  25. package/manager/processes/shutdownServer.mjs +35 -0
  26. package/manager/processes/startServer.mjs +45 -0
  27. package/manager/processes/startWatchers.mjs +31 -0
  28. package/manager/run.mjs +109 -0
  29. package/manager/utils/BatchChanges.mjs +64 -0
  30. package/manager/utils/createCustomPluginTypesMap.mjs +72 -0
  31. package/manager/utils/createLogger.mjs +34 -0
  32. package/manager/utils/getLowdefyVersion.mjs +51 -0
  33. package/manager/utils/getNextBin.mjs +36 -0
  34. package/manager/utils/setupWatcher.mjs +50 -0
  35. package/manager/watchers/envWatcher.mjs +35 -0
  36. package/manager/watchers/lowdefyBuildWatcher.mjs +55 -0
  37. package/manager/watchers/nextBuildWatcher.mjs +99 -0
  38. package/next.config.js +2 -7
  39. package/package.json +46 -37
  40. package/pages/404.js +19 -0
  41. package/pages/[pageId].js +19 -0
  42. package/pages/_app.js +37 -0
  43. package/pages/_document.js +50 -0
  44. package/pages/api/auth/[...nextauth].js +45 -0
  45. package/pages/api/page/[pageId].js +40 -0
  46. package/pages/api/ping.js +19 -0
  47. package/pages/api/reload.js +50 -0
  48. package/pages/api/request/[pageId]/[requestId].js +50 -0
  49. package/pages/api/root.js +35 -0
  50. package/pages/index.js +19 -0
@@ -0,0 +1,36 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import path from 'path';
18
+ import { createRequire } from 'module';
19
+
20
+ function getNextBin() {
21
+ const require = createRequire(import.meta.url);
22
+ const nextPackageJson = require('next/package.json');
23
+
24
+ const nextPath = require.resolve('next');
25
+ let nextMainFragment = nextPackageJson.main.substring(1);
26
+ let nextBinFragment = nextPackageJson.bin.next;
27
+
28
+ if (process.platform === 'win32') {
29
+ nextMainFragment = nextMainFragment.replaceAll('/', '\\');
30
+ nextBinFragment = nextBinFragment.replaceAll('/', '\\');
31
+ }
32
+
33
+ return path.join(nextPath.replace(nextMainFragment, ''), nextBinFragment);
34
+ }
35
+
36
+ export default getNextBin;
@@ -0,0 +1,50 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import chokidar from 'chokidar';
18
+ import BatchChanges from './BatchChanges.mjs';
19
+
20
+ function setupWatcher({
21
+ callback,
22
+ context,
23
+ watchDotfiles = false,
24
+ ignorePaths = [],
25
+ watchPaths,
26
+ delay = 500,
27
+ }) {
28
+ return new Promise((resolve) => {
29
+ // const { watch = [], watchIgnore = [] } = context.options;
30
+ // const resolvedWatchPaths = watch.map((pathName) => path.resolve(pathName));
31
+
32
+ const batchChanges = new BatchChanges({ context, fn: callback, delay });
33
+ const defaultIgnorePaths = watchDotfiles
34
+ ? []
35
+ : [
36
+ /(^|[/\\])\../, // ignore dotfiles
37
+ ];
38
+ const configWatcher = chokidar.watch(watchPaths, {
39
+ ignored: [...defaultIgnorePaths, ...ignorePaths],
40
+ persistent: true,
41
+ ignoreInitial: true,
42
+ });
43
+ configWatcher.on('add', (...args) => batchChanges.newChange(...args));
44
+ configWatcher.on('change', (...args) => batchChanges.newChange(...args));
45
+ configWatcher.on('unlink', (...args) => batchChanges.newChange(...args));
46
+ configWatcher.on('ready', () => resolve());
47
+ });
48
+ }
49
+
50
+ export default setupWatcher;
@@ -0,0 +1,35 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import path from 'path';
18
+ import setupWatcher from '../utils/setupWatcher.mjs';
19
+
20
+ function envWatcher(context) {
21
+ const callback = async () => {
22
+ context.logger.warn('.env file changed.');
23
+ context.readDotEnv();
24
+ await context.lowdefyBuild();
25
+ context.restartServer();
26
+ };
27
+ return setupWatcher({
28
+ callback,
29
+ context,
30
+ watchDotfiles: true,
31
+ watchPaths: [path.join(context.directories.config, '.env')],
32
+ });
33
+ }
34
+
35
+ export default envWatcher;
@@ -0,0 +1,55 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import path from 'path';
18
+ import getLowdefyVersion from '../utils/getLowdefyVersion.mjs';
19
+ import setupWatcher from '../utils/setupWatcher.mjs';
20
+
21
+ function lowdefyBuildWatcher(context) {
22
+ const fixRelativePathConfigDir = (item) =>
23
+ path.isAbsolute(item) ? item : path.resolve(context.directories.config, item);
24
+
25
+ const callback = async (filePaths) => {
26
+ const lowdefyYamlModified = filePaths
27
+ .flat()
28
+ .some((filePath) => filePath.includes('lowdefy.yaml') || filePath.includes('lowdefy.yml'));
29
+ if (lowdefyYamlModified) {
30
+ const lowdefyVersion = await getLowdefyVersion(context);
31
+ if (lowdefyVersion !== context.version && lowdefyVersion !== 'local') {
32
+ context.shutdownServer();
33
+ context.logger.warn('Lowdefy version changed. You should restart your development server.');
34
+ process.exit();
35
+ }
36
+ }
37
+
38
+ await context.lowdefyBuild();
39
+ context.reloadClients();
40
+ };
41
+ return setupWatcher({
42
+ callback,
43
+ context,
44
+ ignorePaths: [
45
+ '**/node_modules/**',
46
+ ...context.options.watchIgnore.map(fixRelativePathConfigDir),
47
+ ],
48
+ watchPaths: [
49
+ context.directories.config,
50
+ ...context.options.watch.map(fixRelativePathConfigDir),
51
+ ],
52
+ });
53
+ }
54
+
55
+ export default lowdefyBuildWatcher;
@@ -0,0 +1,99 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import crypto from 'crypto';
18
+ import path from 'path';
19
+ import { readFile } from '@lowdefy/node-utils';
20
+ import setupWatcher from '../utils/setupWatcher.mjs';
21
+
22
+ const hashes = {};
23
+
24
+ const watchedFiles = [
25
+ 'build/app.json',
26
+ 'build/auth.json',
27
+ 'build/config.json',
28
+ 'build/plugins/actions.js',
29
+ 'build/plugins/auth/adapters.js',
30
+ 'build/plugins/auth/callbacks.js',
31
+ 'build/plugins/auth/events.js',
32
+ 'build/plugins/auth/providers.js',
33
+ 'build/plugins/blocks.js',
34
+ 'build/plugins/connections.js',
35
+ 'build/plugins/icons.js',
36
+ 'build/plugins/operators/client.js',
37
+ 'build/plugins/operators/server.js',
38
+ 'build/plugins/styles.less',
39
+ 'public/styles.less',
40
+ 'package.json',
41
+ ];
42
+
43
+ async function sha1(filePath) {
44
+ const content = await readFile(filePath);
45
+ return crypto
46
+ .createHash('sha1')
47
+ .update(content || '')
48
+ .digest('hex');
49
+ }
50
+
51
+ async function nextBuildWatcher(context) {
52
+ // Initialize hashes so that app does not rebuild the first time
53
+ // Lowdefy build is run.
54
+ await Promise.all(
55
+ watchedFiles.map(async (filePath) => {
56
+ const fullPath = path.resolve(context.directories.server, filePath);
57
+ hashes[fullPath] = await sha1(fullPath);
58
+ })
59
+ );
60
+
61
+ const callback = async (filePaths) => {
62
+ let install = false;
63
+ let build = false;
64
+ await Promise.all(
65
+ filePaths.flat().map(async (filePath) => {
66
+ const hash = await sha1(filePath);
67
+ if (hashes[filePath] === hash) {
68
+ return;
69
+ }
70
+ build = true;
71
+ if (filePath.endsWith('package.json')) {
72
+ install = true;
73
+ }
74
+ hashes[filePath] = hash;
75
+ })
76
+ );
77
+
78
+ if (!build) {
79
+ context.logger.info({ print: 'succeed' }, 'Reloaded app.');
80
+ return;
81
+ }
82
+
83
+ context.shutdownServer();
84
+ if (install) {
85
+ await context.installPlugins();
86
+ }
87
+ await context.nextBuild();
88
+ context.restartServer();
89
+ };
90
+
91
+ return setupWatcher({
92
+ callback,
93
+ context,
94
+ watchDotfiles: true,
95
+ watchPaths: watchedFiles.map((filePath) => path.join(context.directories.server, filePath)),
96
+ });
97
+ }
98
+
99
+ export default nextBuildWatcher;
package/next.config.js CHANGED
@@ -2,11 +2,6 @@ const withLess = require('next-with-less');
2
2
  const lowdefyConfig = require('./build/config.json');
3
3
 
4
4
  module.exports = withLess({
5
- lessLoaderOptions: {
6
- lessOptions: {
7
- modifyVars: lowdefyConfig.theme.lessVariables,
8
- },
9
- },
10
5
  basePath: process.env.LOWDEFY_BASE_PATH || lowdefyConfig.basePath,
11
6
  // reactStrictMode: true,
12
7
  webpack: (config, { isServer }) => {
@@ -18,13 +13,13 @@ module.exports = withLess({
18
13
  events: false,
19
14
  fs: false,
20
15
  path: false,
21
- process: false,
16
+ process: require.resolve('process/browser'),
22
17
  util: false,
23
18
  };
24
19
  }
25
20
  return config;
26
21
  },
27
- swcMinify: true,
22
+ swcMinify: false,
28
23
  compress: false,
29
24
  outputFileTracing: false,
30
25
  poweredByHeader: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "4.0.0-alpha.9",
3
+ "version": "4.0.0-rc.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -26,10 +26,13 @@
26
26
  "url": "https://github.com/lowdefy/lowdefy.git"
27
27
  },
28
28
  "files": [
29
- "src/*",
29
+ "lib/*",
30
+ "manager/*",
31
+ "pages/*",
30
32
  "public/*",
31
33
  "next.config.js",
32
- ".eslintrc.yaml"
34
+ ".eslintrc.yaml",
35
+ ".npmrc"
33
36
  ],
34
37
  "scripts": {
35
38
  "start": "node manager/run.mjs",
@@ -37,48 +40,54 @@
37
40
  "next": "next"
38
41
  },
39
42
  "dependencies": {
40
- "@lowdefy/actions-core": "4.0.0-alpha.9",
41
- "@lowdefy/api": "4.0.0-alpha.9",
42
- "@lowdefy/blocks-antd": "4.0.0-alpha.9",
43
- "@lowdefy/blocks-basic": "4.0.0-alpha.9",
44
- "@lowdefy/blocks-color-selectors": "4.0.0-alpha.9",
45
- "@lowdefy/blocks-echarts": "4.0.0-alpha.9",
46
- "@lowdefy/blocks-loaders": "4.0.0-alpha.9",
47
- "@lowdefy/blocks-markdown": "4.0.0-alpha.9",
48
- "@lowdefy/build": "4.0.0-alpha.9",
49
- "@lowdefy/client": "4.0.0-alpha.9",
50
- "@lowdefy/connection-axios-http": "4.0.0-alpha.9",
51
- "@lowdefy/engine": "4.0.0-alpha.9",
52
- "@lowdefy/helpers": "4.0.0-alpha.9",
53
- "@lowdefy/layout": "4.0.0-alpha.9",
54
- "@lowdefy/node-utils": "4.0.0-alpha.9",
55
- "@lowdefy/operators-change-case": "4.0.0-alpha.9",
56
- "@lowdefy/operators-diff": "4.0.0-alpha.9",
57
- "@lowdefy/operators-js": "4.0.0-alpha.9",
58
- "@lowdefy/operators-mql": "4.0.0-alpha.9",
59
- "@lowdefy/operators-nunjucks": "4.0.0-alpha.9",
60
- "@lowdefy/operators-uuid": "4.0.0-alpha.9",
61
- "@lowdefy/operators-yaml": "4.0.0-alpha.9",
43
+ "@lowdefy/actions-core": "4.0.0-rc.0",
44
+ "@lowdefy/api": "4.0.0-rc.0",
45
+ "@lowdefy/blocks-antd": "4.0.0-rc.0",
46
+ "@lowdefy/blocks-basic": "4.0.0-rc.0",
47
+ "@lowdefy/blocks-color-selectors": "4.0.0-rc.0",
48
+ "@lowdefy/blocks-echarts": "4.0.0-rc.0",
49
+ "@lowdefy/blocks-loaders": "4.0.0-rc.0",
50
+ "@lowdefy/blocks-markdown": "4.0.0-rc.0",
51
+ "@lowdefy/blocks-qr": "4.0.0-rc.0",
52
+ "@lowdefy/build": "4.0.0-rc.0",
53
+ "@lowdefy/client": "4.0.0-rc.0",
54
+ "@lowdefy/connection-axios-http": "4.0.0-rc.0",
55
+ "@lowdefy/engine": "4.0.0-rc.0",
56
+ "@lowdefy/helpers": "4.0.0-rc.0",
57
+ "@lowdefy/layout": "4.0.0-rc.0",
58
+ "@lowdefy/node-utils": "4.0.0-rc.0",
59
+ "@lowdefy/operators-change-case": "4.0.0-rc.0",
60
+ "@lowdefy/operators-diff": "4.0.0-rc.0",
61
+ "@lowdefy/operators-js": "4.0.0-rc.0",
62
+ "@lowdefy/operators-mql": "4.0.0-rc.0",
63
+ "@lowdefy/operators-nunjucks": "4.0.0-rc.0",
64
+ "@lowdefy/operators-uuid": "4.0.0-rc.0",
65
+ "@lowdefy/operators-yaml": "4.0.0-rc.0",
66
+ "@lowdefy/plugin-next-auth": "4.0.0-rc.0",
62
67
  "chokidar": "3.5.3",
63
- "dotenv": "15.0.0",
64
- "next": "12.0.10",
65
- "next-auth": "4.1.2",
68
+ "dotenv": "16.0.1",
69
+ "next": "12.3.1",
70
+ "next-auth": "4.10.3",
66
71
  "opener": "1.5.2",
67
- "react": "17.0.2",
68
- "react-dom": "17.0.2",
72
+ "pino": "8.1.0",
73
+ "process": "0.11.10",
74
+ "react": "18.2.0",
75
+ "react-dom": "18.2.0",
69
76
  "react-icons": "4.3.1",
70
- "swr": "1.1.2",
71
- "yaml": "2.0.0-10",
72
- "yargs": "17.3.1"
77
+ "swr": "1.3.0",
78
+ "yaml": "2.1.1",
79
+ "yargs": "17.5.1"
73
80
  },
74
81
  "devDependencies": {
75
- "@next/eslint-plugin-next": "12.0.10",
82
+ "@next/eslint-plugin-next": "12.1.6",
76
83
  "less": "4.1.2",
77
- "less-loader": "10.2.0",
78
- "next-with-less": "2.0.4"
84
+ "less-loader": "11.0.0",
85
+ "next-with-less": "2.0.5",
86
+ "webpack": "5.74.0"
79
87
  },
88
+ "packageManager": "pnpm@7.11.0",
80
89
  "publishConfig": {
81
90
  "access": "public"
82
91
  },
83
- "gitHead": "98b544eca231bdcfca6c3a8601a891835d5ce571"
92
+ "gitHead": "f6872d7ff6da421710096536fce7b2016ef8f35c"
84
93
  }
package/pages/404.js ADDED
@@ -0,0 +1,19 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import App from '../lib/App.js';
18
+
19
+ export default App;
@@ -0,0 +1,19 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import App from '../lib/App.js';
18
+
19
+ export default App;
package/pages/_app.js ADDED
@@ -0,0 +1,37 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import React, { Suspense } from 'react';
18
+ import dynamic from 'next/dynamic';
19
+
20
+ import Auth from '../lib/auth/Auth.js';
21
+
22
+ // Must be in _app due to next specifications.
23
+ import '../build/plugins/styles.less';
24
+
25
+ function App({ Component }) {
26
+ return (
27
+ <Suspense fallback="">
28
+ <Auth>{(auth) => <Component auth={auth} />}</Auth>
29
+ </Suspense>
30
+ );
31
+ }
32
+
33
+ const DynamicApp = dynamic(() => Promise.resolve(App), {
34
+ ssr: false,
35
+ });
36
+
37
+ export default DynamicApp;
@@ -0,0 +1,50 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import React from 'react';
18
+ import Document, { Html, Head, Main, NextScript } from 'next/document';
19
+ import appJson from '../build/app.json';
20
+
21
+ class LowdefyDocument extends Document {
22
+ render() {
23
+ return (
24
+ <Html>
25
+ <Head>
26
+ <link rel="manifest" href="/manifest.webmanifest" />
27
+ <link rel="icon" type="image/svg+xml" href="/icon.svg" />
28
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
29
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
30
+ <script
31
+ dangerouslySetInnerHTML={{
32
+ __html: `/* start of Lowdefy append head */</script>${appJson.html.appendHead}<script>/* end of Lowdefy append head */`,
33
+ }}
34
+ />
35
+ </Head>
36
+ <body>
37
+ <Main />
38
+ <NextScript />
39
+ <script
40
+ dangerouslySetInnerHTML={{
41
+ __html: `/* start of Lowdefy append body */</script>${appJson.html.appendBody}<script>/* end of Lowdefy append body */`,
42
+ }}
43
+ />
44
+ </body>
45
+ </Html>
46
+ );
47
+ }
48
+ }
49
+
50
+ export default LowdefyDocument;
@@ -0,0 +1,45 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import NextAuth from 'next-auth';
18
+ import { createApiContext, getNextAuthConfig } from '@lowdefy/api';
19
+
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) {
38
+ if (authJson.configured === true) {
39
+ return await NextAuth(req, res, authOptions);
40
+ }
41
+
42
+ return res.status(404).json({
43
+ message: 'Auth not configured',
44
+ });
45
+ }
@@ -0,0 +1,40 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { createApiContext, getPageConfig } 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
+
33
+ const { pageId } = req.query;
34
+ const pageConfig = await getPageConfig(apiContext, { pageId });
35
+ if (pageConfig === null) {
36
+ res.status(404).send('Page not found.');
37
+ } else {
38
+ res.status(200).json(pageConfig);
39
+ }
40
+ }
@@ -0,0 +1,19 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ export default async function handler(req, res) {
18
+ res.status(200).json({ timestamp: new Date().toISOString() });
19
+ }