@lowdefy/server 4.0.0-alpha.1 → 4.0.0-alpha.12
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/.eslintrc.yaml +1 -0
- package/README.md +17 -1
- package/lib/Page.js +62 -0
- package/lowdefy/build.mjs +51 -0
- package/lowdefy/createCustomPluginTypesMap.mjs +71 -0
- package/next.config.js +36 -0
- package/package.json +30 -20
- package/{src/utils/request.js → pages/404.js} +19 -17
- package/{src/pages → pages}/[pageId].js +10 -5
- package/{src/components/Head.js → pages/_app.js} +17 -8
- package/pages/_document.js +38 -0
- package/{src/pages → pages}/api/auth/[...nextauth].js +8 -11
- package/{src/pages → pages}/api/request/[pageId]/[requestId].js +13 -8
- package/{src/pages → pages}/index.js +15 -13
- package/{src/public → public}/apple-touch-icon.png +0 -0
- package/public/favicon.ico +0 -0
- package/{src/public → public}/icon-512.png +0 -0
- package/{src/public → public}/icon.svg +0 -0
- package/{src/public → public}/logo-dark-theme.png +0 -0
- package/{src/public → public}/logo-light-theme.png +0 -0
- package/{src/public → public}/logo-square-dark-theme.png +0 -0
- package/{src/public → public}/logo-square-light-theme.png +0 -0
- package/{src/public → public}/manifest.webmanifest +0 -0
- package/src/components/Context.js +0 -61
- package/src/components/LowdefyContext.js +0 -47
- package/src/components/Page.js +0 -60
- package/src/components/block/Block.js +0 -57
- package/src/components/block/CategorySwitch.js +0 -120
- package/src/components/block/Container.js +0 -87
- package/src/components/block/List.js +0 -94
- package/src/components/block/LoadingBlock.js +0 -22
- package/src/components/block/MountEvents.js +0 -46
- package/src/components/components.js +0 -25
- package/src/pages/_app.js +0 -37
- package/src/plugins/icons.js +0 -35
- package/src/plugins/style.less +0 -3
- package/src/public/icon-32.png +0 -0
- package/src/utils/callRequest.js +0 -27
- package/src/utils/setupLink.js +0 -44
package/.eslintrc.yaml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
extends: 'plugin:@next/next/core-web-vitals'
|
package/README.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @lowdefy/server
|
|
2
2
|
|
|
3
|
+
## Development
|
|
4
|
+
|
|
5
|
+
To run the server in locally as a development server, run the following:
|
|
6
|
+
|
|
7
|
+
- Run `yarn && yarn build` at the root of the repository.
|
|
8
|
+
- Add a `lowdefy.yaml` file in the server directory (`packages/server`).
|
|
9
|
+
- run `yarn dev` in the server directory.
|
|
10
|
+
|
|
11
|
+
To run the server in locally as a development server, with a next production build, run the following:
|
|
12
|
+
|
|
13
|
+
- Run `yarn && yarn build` at the root of the repository.
|
|
14
|
+
- Add a `lowdefy.yaml` file in the server directory (`packages/server`).
|
|
15
|
+
- run `yarn dev:prod` in the server directory.
|
|
16
|
+
|
|
17
|
+
> When running a development server, the `package.json` file is updated with the plugins used in the Lowdefy app. Please do not commit the changes made to the `package.json`, `.pnp.cjs` and `yarn.lock` files.
|
|
18
|
+
|
|
3
19
|
## Licence
|
|
4
20
|
|
|
5
|
-
[Apache-2.0](https://github.com/lowdefy/lowdefy/blob/main/LICENSE)
|
|
21
|
+
[Apache-2.0](https://github.com/lowdefy/lowdefy/blob/main/LICENSE)
|
package/lib/Page.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
|
|
19
|
+
import { useRouter } from 'next/router';
|
|
20
|
+
import Client from '@lowdefy/client';
|
|
21
|
+
import Head from 'next/head';
|
|
22
|
+
import Link from 'next/link';
|
|
23
|
+
import { signIn, signOut, useSession } from 'next-auth/react';
|
|
24
|
+
|
|
25
|
+
import actions from '../build/plugins/actions.js';
|
|
26
|
+
import blocks from '../build/plugins/blocks.js';
|
|
27
|
+
import icons from '../build/plugins/icons.js';
|
|
28
|
+
import operators from '../build/plugins/operators/client.js';
|
|
29
|
+
|
|
30
|
+
const Page = ({ pageConfig, rootConfig }) => {
|
|
31
|
+
const router = useRouter();
|
|
32
|
+
const { data: session, status } = useSession();
|
|
33
|
+
|
|
34
|
+
// If session is passed to SessionProvider from getServerSideProps
|
|
35
|
+
// we won't have a loading state here.
|
|
36
|
+
// But 404 uses getStaticProps so we have this for 404.
|
|
37
|
+
if (status === 'loading') {
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Client
|
|
43
|
+
auth={{ signIn, signOut }}
|
|
44
|
+
Components={{ Head, Link }}
|
|
45
|
+
config={{
|
|
46
|
+
pageConfig,
|
|
47
|
+
rootConfig,
|
|
48
|
+
}}
|
|
49
|
+
router={router}
|
|
50
|
+
session={session}
|
|
51
|
+
types={{
|
|
52
|
+
actions,
|
|
53
|
+
blocks,
|
|
54
|
+
icons,
|
|
55
|
+
operators,
|
|
56
|
+
}}
|
|
57
|
+
window={window}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default Page;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import path from 'path';
|
|
19
|
+
import yargs from 'yargs';
|
|
20
|
+
import { hideBin } from 'yargs/helpers';
|
|
21
|
+
|
|
22
|
+
import build from '@lowdefy/build';
|
|
23
|
+
import createCustomPluginTypesMap from './createCustomPluginTypesMap.mjs';
|
|
24
|
+
|
|
25
|
+
const argv = yargs(hideBin(process.argv)).argv;
|
|
26
|
+
|
|
27
|
+
async function run() {
|
|
28
|
+
const directories = {
|
|
29
|
+
build: path.resolve(
|
|
30
|
+
argv.buildDirectory ||
|
|
31
|
+
process.env.LOWDEFY_DIRECTORY_BUILD ||
|
|
32
|
+
path.join(process.cwd(), 'build')
|
|
33
|
+
),
|
|
34
|
+
config: path.resolve(
|
|
35
|
+
argv.configDirectory || process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()
|
|
36
|
+
),
|
|
37
|
+
server: path.resolve(
|
|
38
|
+
argv.serverDirectory || process.env.LOWDEFY_DIRECTORY_SERVER || process.cwd()
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const customTypesMap = await createCustomPluginTypesMap({ directories });
|
|
43
|
+
await build({
|
|
44
|
+
customTypesMap,
|
|
45
|
+
directories,
|
|
46
|
+
logger: console,
|
|
47
|
+
refResolver: argv.refResolver || process.env.LOWDEFY_BUILD_REF_RESOLVER,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
run();
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import path from 'path';
|
|
19
|
+
import { get } from '@lowdefy/helpers';
|
|
20
|
+
import { readFile } from '@lowdefy/node-utils';
|
|
21
|
+
import { createPluginTypesMap } from '@lowdefy/build';
|
|
22
|
+
import YAML from 'yaml';
|
|
23
|
+
|
|
24
|
+
async function getPluginDefinitions({ directories }) {
|
|
25
|
+
let lowdefyYaml = await readFile(path.join(directories.config, 'lowdefy.yaml'));
|
|
26
|
+
if (!lowdefyYaml) {
|
|
27
|
+
lowdefyYaml = await readFile(path.join(directories.config, 'lowdefy.yml'));
|
|
28
|
+
}
|
|
29
|
+
const lowdefy = YAML.parse(lowdefyYaml);
|
|
30
|
+
return get(lowdefy, 'plugins', { default: [] });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function createCustomPluginTypesMap({ directories }) {
|
|
34
|
+
const customTypesMap = {
|
|
35
|
+
actions: {},
|
|
36
|
+
auth: {
|
|
37
|
+
callbacks: {},
|
|
38
|
+
events: {},
|
|
39
|
+
providers: {},
|
|
40
|
+
},
|
|
41
|
+
blocks: {},
|
|
42
|
+
connections: {},
|
|
43
|
+
icons: {},
|
|
44
|
+
operators: {
|
|
45
|
+
client: {},
|
|
46
|
+
server: {},
|
|
47
|
+
},
|
|
48
|
+
requests: {},
|
|
49
|
+
styles: {
|
|
50
|
+
packages: {},
|
|
51
|
+
blocks: {},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const pluginDefinitions = await getPluginDefinitions({ directories });
|
|
56
|
+
|
|
57
|
+
for (const plugin of pluginDefinitions) {
|
|
58
|
+
const { default: types } = await import(`${plugin.name}/types`);
|
|
59
|
+
createPluginTypesMap({
|
|
60
|
+
packageTypes: types,
|
|
61
|
+
typesMap: customTypesMap,
|
|
62
|
+
packageName: plugin.name,
|
|
63
|
+
version: plugin.version,
|
|
64
|
+
typePrefix: plugin.typePrefix,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return customTypesMap;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default createCustomPluginTypesMap;
|
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
|
+
// TODO: Trace env and args from cli that is required on the server.
|
|
5
|
+
module.exports = withLess({
|
|
6
|
+
basePath: process.env.LOWDEFY_BASE_PATH || lowdefyConfig.basePath,
|
|
7
|
+
lessLoaderOptions: {
|
|
8
|
+
lessOptions: {
|
|
9
|
+
modifyVars: lowdefyConfig.theme.lessVariables,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
reactStrictMode: true,
|
|
13
|
+
webpack: (config, { isServer }) => {
|
|
14
|
+
if (!isServer) {
|
|
15
|
+
config.resolve.fallback = {
|
|
16
|
+
assert: false,
|
|
17
|
+
buffer: false,
|
|
18
|
+
crypto: false,
|
|
19
|
+
events: false,
|
|
20
|
+
fs: false,
|
|
21
|
+
path: false,
|
|
22
|
+
process: require.resolve('process/browser'),
|
|
23
|
+
util: false,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return config;
|
|
27
|
+
},
|
|
28
|
+
poweredByHeader: false,
|
|
29
|
+
// productionBrowserSourceMaps: true
|
|
30
|
+
// experimental: {
|
|
31
|
+
// concurrentFeatures: true,
|
|
32
|
+
// },
|
|
33
|
+
eslint: {
|
|
34
|
+
ignoreDuringBuilds: true,
|
|
35
|
+
},
|
|
36
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.12",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -26,11 +26,15 @@
|
|
|
26
26
|
"url": "https://github.com/lowdefy/lowdefy.git"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
|
-
"
|
|
29
|
+
"lib/*",
|
|
30
|
+
"lowdefy/*",
|
|
31
|
+
"pages/*",
|
|
32
|
+
"public/*",
|
|
33
|
+
"next.config.js",
|
|
34
|
+
".eslintrc.yaml"
|
|
30
35
|
],
|
|
31
36
|
"scripts": {
|
|
32
|
-
"build": "
|
|
33
|
-
"build:lowdefy": "lowdefy-build",
|
|
37
|
+
"build:lowdefy": "node lowdefy/build.mjs",
|
|
34
38
|
"build:next": "next build",
|
|
35
39
|
"dev": "next dev",
|
|
36
40
|
"start": "next start",
|
|
@@ -38,29 +42,35 @@
|
|
|
38
42
|
"next": "next"
|
|
39
43
|
},
|
|
40
44
|
"dependencies": {
|
|
41
|
-
"@lowdefy/
|
|
42
|
-
"@lowdefy/
|
|
43
|
-
"@lowdefy/blocks-antd": "4.0.0-alpha.
|
|
44
|
-
"@lowdefy/blocks-basic": "4.0.0-alpha.
|
|
45
|
-
"@lowdefy/
|
|
46
|
-
"@lowdefy/
|
|
47
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
48
|
-
"@lowdefy/layout": "4.0.0-alpha.
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
45
|
+
"@lowdefy/actions-core": "4.0.0-alpha.12",
|
|
46
|
+
"@lowdefy/api": "4.0.0-alpha.12",
|
|
47
|
+
"@lowdefy/blocks-antd": "4.0.0-alpha.12",
|
|
48
|
+
"@lowdefy/blocks-basic": "4.0.0-alpha.12",
|
|
49
|
+
"@lowdefy/blocks-loaders": "4.0.0-alpha.12",
|
|
50
|
+
"@lowdefy/client": "4.0.0-alpha.12",
|
|
51
|
+
"@lowdefy/helpers": "4.0.0-alpha.12",
|
|
52
|
+
"@lowdefy/layout": "4.0.0-alpha.12",
|
|
53
|
+
"@lowdefy/node-utils": "4.0.0-alpha.12",
|
|
54
|
+
"@lowdefy/operators-js": "4.0.0-alpha.12",
|
|
55
|
+
"@lowdefy/plugin-next-auth": "4.0.0-alpha.12",
|
|
56
|
+
"next": "12.0.10",
|
|
57
|
+
"next-auth": "4.3.4",
|
|
58
|
+
"process": "0.11.10",
|
|
59
|
+
"react": "17.0.2",
|
|
60
|
+
"react-dom": "17.0.2",
|
|
53
61
|
"react-icons": "4.3.1"
|
|
54
62
|
},
|
|
55
63
|
"devDependencies": {
|
|
56
|
-
"@lowdefy/build": "4.0.0-alpha.
|
|
57
|
-
"@next/eslint-plugin-next": "12.0.
|
|
64
|
+
"@lowdefy/build": "4.0.0-alpha.12",
|
|
65
|
+
"@next/eslint-plugin-next": "12.0.10",
|
|
58
66
|
"less": "4.1.2",
|
|
59
67
|
"less-loader": "10.2.0",
|
|
60
|
-
"next-with-less": "2.0.
|
|
68
|
+
"next-with-less": "2.0.4",
|
|
69
|
+
"yaml": "1.10.2",
|
|
70
|
+
"yargs": "17.3.1"
|
|
61
71
|
},
|
|
62
72
|
"publishConfig": {
|
|
63
73
|
"access": "public"
|
|
64
74
|
},
|
|
65
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "41b6138a81bee7da362dad06345bc9f87b2c2133"
|
|
66
76
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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,24 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
18
|
+
|
|
19
|
+
import Page from '../lib/Page.js';
|
|
20
|
+
|
|
21
|
+
export async function getStaticProps() {
|
|
22
|
+
const apiContext = await createApiContext({ buildDirectory: './build' });
|
|
23
|
+
|
|
24
|
+
const [rootConfig, pageConfig] = await Promise.all([
|
|
25
|
+
getRootConfig(apiContext),
|
|
26
|
+
getPageConfig(apiContext, { pageId: '404' }),
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
props: {
|
|
31
|
+
pageConfig,
|
|
32
|
+
rootConfig,
|
|
22
33
|
},
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
if (!res.ok) {
|
|
26
|
-
// TODO: check
|
|
27
|
-
const body = await res.json();
|
|
28
|
-
console.log(res);
|
|
29
|
-
console.log(body);
|
|
30
|
-
throw new Error(body.message || 'Request error');
|
|
31
|
-
}
|
|
32
|
-
return res.json();
|
|
34
|
+
};
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
export default
|
|
37
|
+
export default Page;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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,15 +15,19 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
18
|
+
import { getSession } from 'next-auth/react';
|
|
18
19
|
|
|
19
|
-
import Page from '../
|
|
20
|
+
import Page from '../lib/Page.js';
|
|
20
21
|
|
|
21
22
|
export async function getServerSideProps(context) {
|
|
22
23
|
const { pageId } = context.params;
|
|
23
|
-
const
|
|
24
|
+
const session = await getSession(context);
|
|
25
|
+
const apiContext = await createApiContext({
|
|
26
|
+
buildDirectory: './build',
|
|
27
|
+
logger: console,
|
|
28
|
+
session,
|
|
29
|
+
});
|
|
24
30
|
|
|
25
|
-
// TODO: Maybe we can only get rootConfig once?
|
|
26
|
-
// We can't do getServerSideProps on _app :(
|
|
27
31
|
const [rootConfig, pageConfig] = await Promise.all([
|
|
28
32
|
getRootConfig(apiContext),
|
|
29
33
|
getPageConfig(apiContext, { pageId }),
|
|
@@ -42,6 +46,7 @@ export async function getServerSideProps(context) {
|
|
|
42
46
|
props: {
|
|
43
47
|
pageConfig,
|
|
44
48
|
rootConfig,
|
|
49
|
+
session,
|
|
45
50
|
},
|
|
46
51
|
};
|
|
47
52
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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,14 +15,23 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import React from 'react';
|
|
18
|
-
import
|
|
18
|
+
import dynamic from 'next/dynamic';
|
|
19
|
+
import { SessionProvider } from 'next-auth/react';
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
// Must be in _app due to next specifications.
|
|
22
|
+
import '../build/plugins/styles.less';
|
|
23
|
+
|
|
24
|
+
// TODO: SessionProvider requires basebath
|
|
25
|
+
function App({ Component, pageProps: { session, ...pageProps } }) {
|
|
21
26
|
return (
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
</
|
|
27
|
+
<SessionProvider session={session}>
|
|
28
|
+
<Component {...pageProps} />
|
|
29
|
+
</SessionProvider>
|
|
25
30
|
);
|
|
26
|
-
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const DynamicApp = dynamic(() => Promise.resolve(App), {
|
|
34
|
+
ssr: false,
|
|
35
|
+
});
|
|
27
36
|
|
|
28
|
-
export default
|
|
37
|
+
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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,14 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import NextAuth from 'next-auth';
|
|
18
|
-
import
|
|
18
|
+
import { getNextAuthConfig } from '@lowdefy/api';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}),
|
|
27
|
-
],
|
|
28
|
-
});
|
|
20
|
+
import authJson from '../../../build/auth.json';
|
|
21
|
+
import callbacks from '../../../build/plugins/auth/callbacks.js';
|
|
22
|
+
import events from '../../../build/plugins/auth/events.js';
|
|
23
|
+
import providers from '../../../build/plugins/auth/providers.js';
|
|
24
|
+
|
|
25
|
+
export default NextAuth(getNextAuthConfig({ authJson, plugins: { callbacks, events, providers } }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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,24 +15,29 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { callRequest, createApiContext } from '@lowdefy/api';
|
|
18
|
-
import
|
|
18
|
+
import { getSecretsFromEnv } from '@lowdefy/node-utils';
|
|
19
|
+
import { getSession } from 'next-auth/react';
|
|
20
|
+
import connections from '../../../../build/plugins/connections.js';
|
|
21
|
+
import operators from '../../../../build/plugins/operators/server.js';
|
|
19
22
|
|
|
20
23
|
export default async function handler(req, res) {
|
|
21
24
|
try {
|
|
22
25
|
if (req.method !== 'POST') {
|
|
23
26
|
throw new Error('Only POST requests are supported.');
|
|
24
27
|
}
|
|
28
|
+
const session = await getSession({ req });
|
|
25
29
|
const apiContext = await createApiContext({
|
|
26
|
-
buildDirectory: '
|
|
30
|
+
buildDirectory: './build',
|
|
27
31
|
connections,
|
|
28
|
-
//
|
|
29
|
-
logger:
|
|
30
|
-
|
|
31
|
-
secrets:
|
|
32
|
+
// logger: console,
|
|
33
|
+
logger: { debug: () => {} },
|
|
34
|
+
operators,
|
|
35
|
+
secrets: getSecretsFromEnv(),
|
|
36
|
+
session,
|
|
32
37
|
});
|
|
38
|
+
|
|
33
39
|
const { pageId, requestId } = req.query;
|
|
34
40
|
const { payload } = req.body;
|
|
35
|
-
|
|
36
41
|
const response = await callRequest(apiContext, { pageId, payload, requestId });
|
|
37
42
|
res.status(200).json(response);
|
|
38
43
|
} catch (error) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 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,13 +14,20 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { createApiContext,
|
|
17
|
+
import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
|
|
18
|
+
import { getSession } from 'next-auth/react';
|
|
18
19
|
|
|
19
|
-
import Page from '../
|
|
20
|
+
import Page from '../lib/Page.js';
|
|
20
21
|
|
|
21
|
-
export async function getServerSideProps() {
|
|
22
|
-
const
|
|
23
|
-
const
|
|
22
|
+
export async function getServerSideProps(context) {
|
|
23
|
+
const session = await getSession(context);
|
|
24
|
+
const apiContext = await createApiContext({
|
|
25
|
+
buildDirectory: './build',
|
|
26
|
+
logger: console,
|
|
27
|
+
session,
|
|
28
|
+
});
|
|
29
|
+
const rootConfig = await getRootConfig(apiContext);
|
|
30
|
+
const { home } = rootConfig;
|
|
24
31
|
if (home.configured === false) {
|
|
25
32
|
return {
|
|
26
33
|
redirect: {
|
|
@@ -29,12 +36,7 @@ export async function getServerSideProps() {
|
|
|
29
36
|
},
|
|
30
37
|
};
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
const [rootConfig, pageConfig] = await Promise.all([
|
|
34
|
-
getRootConfig(apiContext),
|
|
35
|
-
getPageConfig(apiContext, { pageId: home.pageId }),
|
|
36
|
-
]);
|
|
37
|
-
|
|
39
|
+
const pageConfig = await getPageConfig(apiContext, { pageId: home.pageId });
|
|
38
40
|
if (!pageConfig) {
|
|
39
41
|
return {
|
|
40
42
|
redirect: {
|
|
@@ -43,11 +45,11 @@ export async function getServerSideProps() {
|
|
|
43
45
|
},
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
|
-
|
|
47
48
|
return {
|
|
48
49
|
props: {
|
|
49
50
|
pageConfig,
|
|
50
51
|
rootConfig,
|
|
52
|
+
session,
|
|
51
53
|
},
|
|
52
54
|
};
|
|
53
55
|
}
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|