@lowdefy/server-dev 3.23.3 → 4.0.0-alpha.10

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 (56) hide show
  1. package/.eslintrc.yaml +1 -0
  2. package/README.md +0 -24
  3. package/lib/App.js +66 -0
  4. package/lib/Page.js +48 -0
  5. package/lib/Reload.js +52 -0
  6. package/lib/RestartingPage.js +47 -0
  7. package/lib/setPageId.js +30 -0
  8. package/lib/utils/request.js +38 -0
  9. package/lib/utils/useMutateCache.js +34 -0
  10. package/lib/utils/usePageConfig.js +29 -0
  11. package/lib/utils/useRootConfig.js +29 -0
  12. package/lib/utils/waitForRestartedServer.js +32 -0
  13. package/manager/getContext.mjs +81 -0
  14. package/manager/processes/initialBuild.mjs +27 -0
  15. package/manager/processes/installPlugins.mjs +36 -0
  16. package/manager/processes/lowdefyBuild.mjs +32 -0
  17. package/manager/processes/nextBuild.mjs +31 -0
  18. package/manager/processes/readDotEnv.mjs +28 -0
  19. package/manager/processes/reloadClients.mjs +26 -0
  20. package/manager/processes/restartServer.mjs +27 -0
  21. package/manager/processes/shutdownServer.mjs +35 -0
  22. package/manager/processes/startNextServer.mjs +45 -0
  23. package/manager/processes/startServer.mjs +31 -0
  24. package/manager/processes/startWatchers.mjs +31 -0
  25. package/manager/run.mjs +92 -0
  26. package/manager/utils/BatchChanges.mjs +67 -0
  27. package/manager/utils/createCustomPluginTypesMap.mjs +66 -0
  28. package/manager/utils/getLowdefyVersion.mjs +51 -0
  29. package/manager/utils/setupWatcher.mjs +49 -0
  30. package/manager/utils/spawnProcess.mjs +55 -0
  31. package/manager/watchers/envWatcher.mjs +34 -0
  32. package/manager/watchers/lowdefyBuildWatcher.mjs +45 -0
  33. package/manager/watchers/nextBuildWatcher.mjs +94 -0
  34. package/next.config.js +36 -0
  35. package/package.json +48 -34
  36. package/pages/404.js +19 -0
  37. package/pages/[pageId].js +19 -0
  38. package/pages/_app.js +35 -0
  39. package/pages/_document.js +38 -0
  40. package/pages/api/auth/[...nextauth].js +28 -0
  41. package/pages/api/page/[pageId].js +29 -0
  42. package/pages/api/ping.js +19 -0
  43. package/pages/api/reload.js +50 -0
  44. package/pages/api/request/[pageId]/[requestId].js +45 -0
  45. package/pages/api/root.js +25 -0
  46. package/pages/index.js +19 -0
  47. package/public/apple-touch-icon.png +0 -0
  48. package/public/favicon.ico +0 -0
  49. package/public/icon-512.png +0 -0
  50. package/public/icon.svg +17 -0
  51. package/public/logo-dark-theme.png +0 -0
  52. package/public/logo-light-theme.png +0 -0
  53. package/public/logo-square-dark-theme.png +0 -0
  54. package/public/logo-square-light-theme.png +0 -0
  55. package/public/manifest.webmanifest +16 -0
  56. package/dist/server.js +0 -47
@@ -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
+ /* eslint-disable no-console */
17
+
18
+ import getLowdefyVersion from '../utils/getLowdefyVersion.mjs';
19
+ import setupWatcher from '../utils/setupWatcher.mjs';
20
+
21
+ function lowdefyBuildWatcher(context) {
22
+ const callback = async (filePaths) => {
23
+ const lowdefyYamlModified = filePaths
24
+ .flat()
25
+ .some((filePath) => filePath.includes('lowdefy.yaml') || filePath.includes('lowdefy.yml'));
26
+ if (lowdefyYamlModified) {
27
+ const lowdefyVersion = await getLowdefyVersion(context);
28
+ if (lowdefyVersion !== context.version && lowdefyVersion !== 'local') {
29
+ context.shutdownServer();
30
+ console.warn('Lowdefy version changed. You should restart your development server.');
31
+ process.exit();
32
+ }
33
+ }
34
+
35
+ await context.lowdefyBuild();
36
+ context.reloadClients();
37
+ };
38
+ return setupWatcher({
39
+ callback,
40
+ ignorePaths: context.options.watchIgnore,
41
+ watchPaths: [context.directories.config, ...context.options.watch],
42
+ });
43
+ }
44
+
45
+ export default lowdefyBuildWatcher;
@@ -0,0 +1,94 @@
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
+ /* eslint-disable no-console */
17
+
18
+ import crypto from 'crypto';
19
+ import path from 'path';
20
+ import { readFile } from '@lowdefy/node-utils';
21
+ import setupWatcher from '../utils/setupWatcher.mjs';
22
+
23
+ const hashes = {};
24
+
25
+ const watchedFiles = [
26
+ 'build/config.json',
27
+ 'build/plugins/actions.js',
28
+ 'build/plugins/blocks.js',
29
+ 'build/plugins/connections.js',
30
+ 'build/plugins/icons.js',
31
+ 'build/plugins/operatorsClient.js',
32
+ 'build/plugins/operatorsServer.js',
33
+ 'build/plugins/styles.less',
34
+ 'package.json',
35
+ ];
36
+
37
+ async function sha1(filePath) {
38
+ const content = await readFile(filePath);
39
+ return crypto
40
+ .createHash('sha1')
41
+ .update(content || '')
42
+ .digest('hex');
43
+ }
44
+
45
+ async function nextBuildWatcher(context) {
46
+ // Initialize hashes so that app does not rebuild the first time
47
+ // Lowdefy build is run.
48
+ await Promise.all(
49
+ watchedFiles.map(async (filePath) => {
50
+ const fullPath = path.resolve(context.directories.server, filePath);
51
+ hashes[fullPath] = await sha1(fullPath);
52
+ })
53
+ );
54
+
55
+ const callback = async (filePaths) => {
56
+ let install = false;
57
+ let build = false;
58
+ await Promise.all(
59
+ filePaths.flat().map(async (filePath) => {
60
+ const hash = await sha1(filePath);
61
+ if (hashes[filePath] === hash) {
62
+ return;
63
+ }
64
+ build = true;
65
+ if (filePath.endsWith('package.json')) {
66
+ install = true;
67
+ }
68
+ hashes[filePath] = hash;
69
+ })
70
+ );
71
+
72
+ if (!build) {
73
+ return;
74
+ }
75
+
76
+ context.shutdownServer();
77
+ if (install) {
78
+ await context.installPlugins();
79
+ }
80
+ await context.nextBuild();
81
+ context.restartServer();
82
+ };
83
+
84
+ return setupWatcher({
85
+ callback,
86
+ watchPaths: [
87
+ path.join(context.directories.build, 'plugins'),
88
+ path.join(context.directories.build, 'config.json'),
89
+ path.join(context.directories.server, 'package.json'),
90
+ ],
91
+ });
92
+ }
93
+
94
+ export default nextBuildWatcher;
package/next.config.js ADDED
@@ -0,0 +1,36 @@
1
+ const withLess = require('next-with-less');
2
+ const lowdefyConfig = require('./build/config.json');
3
+
4
+ module.exports = withLess({
5
+ lessLoaderOptions: {
6
+ lessOptions: {
7
+ modifyVars: lowdefyConfig.theme.lessVariables,
8
+ },
9
+ },
10
+ basePath: process.env.LOWDEFY_BASE_PATH || lowdefyConfig.basePath,
11
+ // reactStrictMode: true,
12
+ webpack: (config, { isServer }) => {
13
+ if (!isServer) {
14
+ config.resolve.fallback = {
15
+ assert: false,
16
+ buffer: false,
17
+ crypto: false,
18
+ events: false,
19
+ fs: false,
20
+ path: false,
21
+ process: false,
22
+ util: false,
23
+ };
24
+ }
25
+ return config;
26
+ },
27
+ swcMinify: true,
28
+ compress: false,
29
+ outputFileTracing: false,
30
+ poweredByHeader: false,
31
+ generateEtags: false,
32
+ optimizeFonts: false,
33
+ eslint: {
34
+ ignoreDuringBuilds: true,
35
+ },
36
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-dev",
3
- "version": "3.23.3",
3
+ "version": "4.0.0-alpha.10",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -26,47 +26,61 @@
26
26
  "url": "https://github.com/lowdefy/lowdefy.git"
27
27
  },
28
28
  "files": [
29
- "dist/*"
29
+ "lib/*",
30
+ "manager/*",
31
+ "pages/*",
32
+ "public/*",
33
+ "next.config.js",
34
+ ".eslintrc.yaml"
30
35
  ],
31
36
  "scripts": {
32
- "babel": "babel src --out-dir dist",
33
- "build": "yarn babel",
34
- "clean": "rm -rf dist && rm -rf .lowdefy",
35
- "prepare": "yarn build",
36
- "start": "nodemon dist/server.js"
37
+ "start": "node manager/run.mjs",
38
+ "lint": "next lint",
39
+ "next": "next"
37
40
  },
38
41
  "dependencies": {
39
- "@lowdefy/graphql": "3.23.3",
40
- "@lowdefy/node-utils": "3.23.3",
41
- "@lowdefy/server": "3.23.3",
42
- "@lowdefy/shell": "3.23.3",
43
- "apollo-server-express": "2.25.0",
44
- "dotenv": "10.0.0",
45
- "express": "4.17.1",
46
- "graphql": "15.5.0"
47
- },
48
- "devDependencies": {
49
- "@babel/cli": "7.14.3",
50
- "@babel/core": "7.14.3",
51
- "@babel/preset-env": "7.14.4",
52
- "@babel/preset-react": "7.13.13",
53
- "@lowdefy/block-tools": "3.23.3",
54
- "babel-jest": "26.6.3",
55
- "babel-loader": "8.2.2",
56
- "clean-webpack-plugin": "3.0.0",
57
- "copy-webpack-plugin": "9.0.0",
58
- "css-loader": "5.2.6",
59
- "html-webpack-plugin": "5.3.1",
60
- "jest": "26.6.3",
61
- "nodemon": "2.0.7",
42
+ "@lowdefy/actions-core": "4.0.0-alpha.10",
43
+ "@lowdefy/api": "4.0.0-alpha.10",
44
+ "@lowdefy/blocks-antd": "4.0.0-alpha.10",
45
+ "@lowdefy/blocks-basic": "4.0.0-alpha.10",
46
+ "@lowdefy/blocks-color-selectors": "4.0.0-alpha.10",
47
+ "@lowdefy/blocks-echarts": "4.0.0-alpha.10",
48
+ "@lowdefy/blocks-loaders": "4.0.0-alpha.10",
49
+ "@lowdefy/blocks-markdown": "4.0.0-alpha.10",
50
+ "@lowdefy/build": "4.0.0-alpha.10",
51
+ "@lowdefy/client": "4.0.0-alpha.10",
52
+ "@lowdefy/connection-axios-http": "4.0.0-alpha.10",
53
+ "@lowdefy/engine": "4.0.0-alpha.10",
54
+ "@lowdefy/helpers": "4.0.0-alpha.10",
55
+ "@lowdefy/layout": "4.0.0-alpha.10",
56
+ "@lowdefy/node-utils": "4.0.0-alpha.10",
57
+ "@lowdefy/operators-change-case": "4.0.0-alpha.10",
58
+ "@lowdefy/operators-diff": "4.0.0-alpha.10",
59
+ "@lowdefy/operators-js": "4.0.0-alpha.10",
60
+ "@lowdefy/operators-mql": "4.0.0-alpha.10",
61
+ "@lowdefy/operators-nunjucks": "4.0.0-alpha.10",
62
+ "@lowdefy/operators-uuid": "4.0.0-alpha.10",
63
+ "@lowdefy/operators-yaml": "4.0.0-alpha.10",
64
+ "chokidar": "3.5.3",
65
+ "dotenv": "15.0.0",
66
+ "next": "12.0.10",
67
+ "next-auth": "4.1.2",
68
+ "opener": "1.5.2",
62
69
  "react": "17.0.2",
63
70
  "react-dom": "17.0.2",
64
- "style-loader": "2.0.0",
65
- "webpack": "5.38.1",
66
- "webpack-cli": "4.7.0"
71
+ "react-icons": "4.3.1",
72
+ "swr": "1.1.2",
73
+ "yaml": "2.0.0-10",
74
+ "yargs": "17.3.1"
75
+ },
76
+ "devDependencies": {
77
+ "@next/eslint-plugin-next": "12.0.10",
78
+ "less": "4.1.2",
79
+ "less-loader": "10.2.0",
80
+ "next-with-less": "2.0.4"
67
81
  },
68
82
  "publishConfig": {
69
83
  "access": "public"
70
84
  },
71
- "gitHead": "aede980a615d339db496a423820612ef85bcbebf"
85
+ "gitHead": "d697b4b5f354697d9481a371b90a00ca0944f486"
72
86
  }
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,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 React, { Suspense } from 'react';
18
+ import dynamic from 'next/dynamic';
19
+
20
+ // Must be in _app due to next specifications.
21
+ import '../build/plugins/styles.less';
22
+
23
+ function App({ Component, pageProps }) {
24
+ return (
25
+ <Suspense fallback="">
26
+ <Component {...pageProps} />
27
+ </Suspense>
28
+ );
29
+ }
30
+
31
+ const DynamicApp = dynamic(() => Promise.resolve(App), {
32
+ ssr: false,
33
+ });
34
+
35
+ export default DynamicApp;
@@ -0,0 +1,38 @@
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
+
20
+ class LowdefyDocument extends Document {
21
+ render() {
22
+ return (
23
+ <Html>
24
+ <Head>
25
+ <link rel="manifest" href="/manifest.webmanifest" />
26
+ <link rel="icon" type="image/svg+xml" href="/icon.svg" />
27
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
28
+ </Head>
29
+ <body>
30
+ <Main />
31
+ <NextScript />
32
+ </body>
33
+ </Html>
34
+ );
35
+ }
36
+ }
37
+
38
+ export default LowdefyDocument;
@@ -0,0 +1,28 @@
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 Auth0Provider from 'next-auth/providers/auth0';
19
+
20
+ export default NextAuth({
21
+ providers: [
22
+ Auth0Provider({
23
+ clientId: process.env.AUTH0_CLIENT_ID,
24
+ clientSecret: process.env.AUTH0_CLIENT_SECRET,
25
+ issuer: process.env.AUTH0_ISSUER,
26
+ }),
27
+ ],
28
+ });
@@ -0,0 +1,29 @@
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
+ export default async function handler(req, res) {
20
+ const { pageId } = req.query;
21
+ // TODO: get the right api context options
22
+ const apiContext = await createApiContext({ buildDirectory: './build' });
23
+ const pageConfig = await getPageConfig(apiContext, { pageId });
24
+ if (pageConfig === null) {
25
+ res.status(404).send('Page not found.');
26
+ } else {
27
+ res.status(200).json(pageConfig);
28
+ }
29
+ }
@@ -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
+ }
@@ -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
+
19
+ const handler = async (req, res) => {
20
+ res.setHeader('Content-Type', 'text/event-stream;charset=utf-8');
21
+ res.setHeader('Cache-Control', 'no-cache, no-transform');
22
+ res.setHeader('X-Accel-Buffering', 'no');
23
+ res.setHeader('Connection', 'keep-alive');
24
+
25
+ const watcher = chokidar.watch(['./build/reload'], {
26
+ persistent: true,
27
+ ignoreInitial: true,
28
+ });
29
+
30
+ const reload = () => {
31
+ try {
32
+ res.write(`event: reload\ndata: ${JSON.stringify({})}\n\n`);
33
+ } catch (e) {
34
+ console.log(e);
35
+ }
36
+ };
37
+ watcher.on('add', () => reload());
38
+ watcher.on('change', () => reload());
39
+ watcher.on('unlink', () => reload());
40
+
41
+ // TODO: This isn't working.
42
+ req.on('close', () => {
43
+ console.log('req closed');
44
+ watcher.close().then(() => {
45
+ console.log('watcher closed');
46
+ });
47
+ });
48
+ };
49
+
50
+ export default handler;
@@ -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 { callRequest, createApiContext } from '@lowdefy/api';
18
+ import { getSecretsFromEnv } from '@lowdefy/node-utils';
19
+ import connections from '../../../../build/plugins/connections.js';
20
+ import operators from '../../../../build/plugins/operatorsServer.js';
21
+
22
+ export default async function handler(req, res) {
23
+ try {
24
+ if (req.method !== 'POST') {
25
+ throw new Error('Only POST requests are supported.');
26
+ }
27
+ // TODO: configure API context
28
+ // TODO: configure build directory?
29
+ const apiContext = await createApiContext({
30
+ buildDirectory: './build',
31
+ connections,
32
+ // TODO: use a logger like pino
33
+ logger: console,
34
+ operators,
35
+ secrets: getSecretsFromEnv(),
36
+ });
37
+ const { pageId, requestId } = req.query;
38
+ const { payload } = req.body;
39
+
40
+ const response = await callRequest(apiContext, { pageId, payload, requestId });
41
+ res.status(200).json(response);
42
+ } catch (error) {
43
+ res.status(500).json({ name: error.name, message: error.message });
44
+ }
45
+ }
@@ -0,0 +1,25 @@
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, getRootConfig } from '@lowdefy/api';
18
+
19
+ export default async function handler(req, res) {
20
+ // TODO: get the right api context options
21
+ const apiContext = await createApiContext({ buildDirectory: './build' });
22
+ const rootConfig = await getRootConfig(apiContext);
23
+
24
+ res.status(200).json(rootConfig);
25
+ }
package/pages/index.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;
Binary file
Binary file
Binary file
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg width="100%" height="100%" viewBox="0 0 94 94" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
4
+ <g transform="matrix(1,0,0,1,-979.672,-59.6924)">
5
+ <g transform="matrix(1,0,0,1.03297,-38.3284,-294.615)">
6
+ <g transform="matrix(1,0,0,1,952,232)">
7
+ <path d="M160,129.634C160,119.35 151.375,111 140.751,111L85.249,111C74.625,111 66,119.35 66,129.634L66,183.366C66,193.65 74.625,202 85.249,202L140.751,202C151.375,202 160,193.65 160,183.366L160,129.634Z"/>
8
+ </g>
9
+ <g transform="matrix(0.872141,0,0,1,1002.6,346)">
10
+ <rect x="36" y="12" width="36" height="59" style="fill:white;"/>
11
+ </g>
12
+ <g transform="matrix(0.78125,0,0,0.862069,1010.84,356.663)">
13
+ <rect x="77" y="41" width="32" height="29" style="fill:rgb(24,144,255);"/>
14
+ </g>
15
+ </g>
16
+ </g>
17
+ </svg>
Binary file
Binary file