@lowdefy/server 0.0.0-alpha.5 → 0.0.0-experimental-20251203202233

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 (51) hide show
  1. package/.eslintrc.yaml +1 -0
  2. package/.npmrc +1 -0
  3. package/LICENSE +201 -0
  4. package/README.md +0 -0
  5. package/lib/client/Page.js +54 -0
  6. package/lib/client/auth/Auth.js +36 -0
  7. package/lib/client/auth/AuthConfigured.js +62 -0
  8. package/lib/client/auth/AuthNotConfigured.js +34 -0
  9. package/lib/client/createLogUsage.js +58 -0
  10. package/lib/server/apiWrapper.js +70 -0
  11. package/lib/server/auth/getAuthOptions.js +35 -0
  12. package/lib/server/auth/getServerSession.js +28 -0
  13. package/lib/server/fileCache.js +21 -0
  14. package/{dist/createGetSecretsFromEnv.js → lib/server/log/createLogger.js} +14 -19
  15. package/lib/server/log/logError.js +72 -0
  16. package/lib/server/log/logRequest.js +66 -0
  17. package/lib/server/serverSidePropsWrapper.js +60 -0
  18. package/lowdefy/build.mjs +62 -0
  19. package/lowdefy/createCustomPluginTypesMap.mjs +72 -0
  20. package/next.config.js +29 -0
  21. package/package.json +56 -44
  22. package/package.original.json +85 -0
  23. package/pages/404.js +47 -0
  24. package/pages/[pageId].js +51 -0
  25. package/pages/_app.js +54 -0
  26. package/pages/_document.js +54 -0
  27. package/pages/api/auth/[...nextauth].js +37 -0
  28. package/pages/api/endpoints/[endpointId].js +32 -0
  29. package/pages/api/request/[pageId]/[requestId].js +32 -0
  30. package/pages/api/usage.js +68 -0
  31. package/pages/index.js +57 -0
  32. package/public_default/apple-touch-icon.png +0 -0
  33. package/public_default/favicon.ico +0 -0
  34. package/public_default/icon-512.png +0 -0
  35. package/public_default/icon.svg +17 -0
  36. package/public_default/logo-dark-theme.png +0 -0
  37. package/public_default/logo-light-theme.png +0 -0
  38. package/public_default/logo-square-dark-theme.png +0 -0
  39. package/public_default/logo-square-light-theme.png +0 -0
  40. package/public_default/manifest.webmanifest +16 -0
  41. package/dist/server.js +0 -55
  42. package/dist/shell/154.js +0 -2
  43. package/dist/shell/154.js.LICENSE.txt +0 -23
  44. package/dist/shell/425.js +0 -2
  45. package/dist/shell/425.js.LICENSE.txt +0 -43
  46. package/dist/shell/693.js +0 -2
  47. package/dist/shell/693.js.LICENSE.txt +0 -14
  48. package/dist/shell/77.js +0 -1
  49. package/dist/shell/901.js +0 -1
  50. package/dist/shell/index.html +0 -1
  51. package/dist/shell/main.js +0 -1
@@ -0,0 +1,72 @@
1
+ /*
2
+ Copyright 2020-2024 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
+ function logError({ context, error }) {
18
+ try {
19
+ const { headers = {}, user = {} } = context;
20
+
21
+ context.logger.error({
22
+ // TODO:
23
+ // app_name
24
+ // app_version
25
+ // lowdefy_version
26
+ // build_hash
27
+ // config_hash
28
+ err: error,
29
+ user: {
30
+ id: user.id,
31
+ roles: user.roles,
32
+ sub: user.sub,
33
+ session_id: user.session_id,
34
+ },
35
+ url: context.req.url,
36
+ method: context.req.method,
37
+ resolvedUrl: context.nextContext?.resolvedUrl,
38
+ hostname: context.req.hostname,
39
+ headers: {
40
+ 'accept-language': headers['accept-language'],
41
+ 'sec-ch-ua-mobile': headers['sec-ch-ua-mobile'],
42
+ 'sec-ch-ua-platform': headers['sec-ch-ua-platform'],
43
+ 'sec-ch-ua': headers['sec-ch-ua'],
44
+ 'user-agent': headers['user-agent'],
45
+ host: headers.host,
46
+ referer: headers.referer,
47
+ // Non localhost headers
48
+ 'x-forward-for': headers['x-forward-for'],
49
+ // Vercel headers
50
+ 'x-vercel-id': headers['x-vercel-id'],
51
+ 'x-real-ip': headers['x-real-ip'],
52
+ 'x-vercel-ip-country': headers['x-vercel-ip-country'],
53
+ 'x-vercel-ip-country-region': headers['x-vercel-ip-country-region'],
54
+ 'x-vercel-ip-city': headers['x-vercel-ip-city'],
55
+ 'x-vercel-ip-latitude': headers['x-vercel-ip-latitude'],
56
+ 'x-vercel-ip-longitude': headers['x-vercel-ip-longitude'],
57
+ 'x-vercel-ip-timezone': headers['x-vercel-ip-timezone'],
58
+ // Cloudflare headers
59
+ 'cf-connecting-ip': headers['cf-connecting-ip'],
60
+ 'cf-ray': headers['cf-ray'],
61
+ 'cf-ipcountry': headers['cf-ipcountry'],
62
+ 'cf-visitor': headers['cf-visitor'],
63
+ },
64
+ });
65
+ } catch (e) {
66
+ console.error(error);
67
+ console.error('An error occurred while logging the error.');
68
+ console.error(e);
69
+ }
70
+ }
71
+
72
+ export default logError;
@@ -0,0 +1,66 @@
1
+ /*
2
+ Copyright 2020-2024 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
+ // TODO: Better name needed here maybe?
18
+ function logRequest({ context }) {
19
+ const { headers = {}, user = {} } = context;
20
+ context.logger.info({
21
+ // TODO:
22
+ // app_name
23
+ // app_version
24
+ // lowdefy_version
25
+ // build_hash
26
+ // config_hash
27
+ user: {
28
+ id: user.id,
29
+ roles: user.roles,
30
+ sub: user.sub,
31
+ session_id: user.session_id, // TODO: Implement session id
32
+ },
33
+ url: context.req.url,
34
+ method: context.req.method,
35
+ resolvedUrl: context.nextContext?.resolvedUrl,
36
+ hostname: context.req.hostname,
37
+ headers: {
38
+ 'accept-language': headers['accept-language'],
39
+ 'sec-ch-ua-mobile': headers['sec-ch-ua-mobile'],
40
+ 'sec-ch-ua-platform': headers['sec-ch-ua-platform'],
41
+ 'sec-ch-ua': headers['sec-ch-ua'],
42
+ 'user-agent': headers['user-agent'],
43
+ host: headers.host,
44
+ referer: headers.referer,
45
+ 'x-forward-for': headers['x-forward-for'],
46
+ // Vercel headers
47
+ 'x-vercel-id': headers['x-vercel-id'],
48
+ 'x-real-ip': headers['x-real-ip'],
49
+ 'x-vercel-ip-country': headers['x-vercel-ip-country'],
50
+ 'x-vercel-ip-country-region': headers['x-vercel-ip-country-region'],
51
+ 'x-vercel-ip-city': headers['x-vercel-ip-city'],
52
+ 'x-vercel-ip-latitude': headers['x-vercel-ip-latitude'],
53
+ 'x-vercel-ip-longitude': headers['x-vercel-ip-longitude'],
54
+ 'x-vercel-ip-timezone': headers['x-vercel-ip-timezone'],
55
+ // Cloudflare headers
56
+ 'cf-connecting-ip': headers['cf-connecting-ip'],
57
+ 'cf-ray': headers['cf-ray'],
58
+ 'cf-ipcountry': headers['cf-ipcountry'],
59
+ 'cf-visitor': headers['cf-visitor'],
60
+ },
61
+ });
62
+ // TODO:
63
+ // Next local? nextContext.locale, nextContext.locales, nextContext.defaultLocale
64
+ }
65
+
66
+ export default logRequest;
@@ -0,0 +1,60 @@
1
+ /*
2
+ Copyright 2020-2024 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 crypto from 'crypto';
19
+ import { createApiContext } from '@lowdefy/api';
20
+
21
+ import config from '../../build/config.json';
22
+ import createLogger from './log/createLogger.js';
23
+ import fileCache from './fileCache.js';
24
+ import getServerSession from './auth/getServerSession.js';
25
+ import logError from './log/logError.js';
26
+ import logRequest from './log/logRequest.js';
27
+ import getAuthOptions from './auth/getAuthOptions.js';
28
+
29
+ // TODO: Merge serverSidePropsWrapper and apiWrapper?
30
+ function serverSidePropsWrapper(handler) {
31
+ return async function wrappedHandler(nextContext) {
32
+ const context = {
33
+ // Important to give absolute path so Next can trace build files
34
+ rid: crypto.randomUUID(),
35
+ buildDirectory: path.join(process.cwd(), 'build'),
36
+ config,
37
+ fileCache,
38
+ headers: nextContext?.req?.headers,
39
+ logger: console,
40
+ nextContext,
41
+ req: nextContext?.req,
42
+ res: nextContext?.res,
43
+ };
44
+ try {
45
+ context.logger = createLogger({ rid: context.rid });
46
+ context.authOptions = getAuthOptions(context);
47
+ context.session = await getServerSession(context);
48
+ createApiContext(context);
49
+ logRequest({ context });
50
+ // Await here so that if handler throws it is caught.
51
+ const response = await handler({ context, nextContext });
52
+ return response;
53
+ } catch (error) {
54
+ logError({ error, context });
55
+ throw error;
56
+ }
57
+ };
58
+ }
59
+
60
+ export default serverSidePropsWrapper;
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ Copyright 2020-2024 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 pino from 'pino';
20
+ import yargs from 'yargs';
21
+ import { hideBin } from 'yargs/helpers';
22
+
23
+ import build from '@lowdefy/build';
24
+ import createCustomPluginTypesMap from './createCustomPluginTypesMap.mjs';
25
+
26
+ const argv = yargs(hideBin(process.argv)).argv;
27
+
28
+ async function run() {
29
+ const serverDirectory = path.resolve(
30
+ argv.serverDirectory || process.env.LOWDEFY_DIRECTORY_SERVER || process.cwd()
31
+ );
32
+ const directories = {
33
+ build: path.join(serverDirectory, 'build'),
34
+ config: path.resolve(
35
+ argv.configDirectory || process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()
36
+ ),
37
+ server: serverDirectory,
38
+ };
39
+
40
+ const customTypesMap = await createCustomPluginTypesMap({ directories });
41
+
42
+ const logger = pino({
43
+ name: 'lowdefy_build',
44
+ level: process.env.LOWDEFY_LOG_LEVEL ?? 'info',
45
+ base: { pid: undefined, hostname: undefined },
46
+ mixin: (context, level) => {
47
+ return {
48
+ ...context,
49
+ print: context.print ?? logger.levels.labels[level],
50
+ };
51
+ },
52
+ });
53
+
54
+ await build({
55
+ customTypesMap,
56
+ directories,
57
+ logger,
58
+ refResolver: argv.refResolver || process.env.LOWDEFY_BUILD_REF_RESOLVER,
59
+ });
60
+ }
61
+
62
+ run();
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ Copyright 2020-2024 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
+ adapters: {},
38
+ callbacks: {},
39
+ events: {},
40
+ providers: {},
41
+ },
42
+ blocks: {},
43
+ connections: {},
44
+ icons: {},
45
+ operators: {
46
+ client: {},
47
+ server: {},
48
+ },
49
+ requests: {},
50
+ styles: {
51
+ packages: {},
52
+ blocks: {},
53
+ },
54
+ };
55
+
56
+ const pluginDefinitions = await getPluginDefinitions({ directories });
57
+
58
+ for (const plugin of pluginDefinitions) {
59
+ const { default: types } = await import(`${plugin.name}/types`);
60
+ createPluginTypesMap({
61
+ packageTypes: types,
62
+ typesMap: customTypesMap,
63
+ packageName: plugin.name,
64
+ version: plugin.version,
65
+ typePrefix: plugin.typePrefix,
66
+ });
67
+ }
68
+
69
+ return customTypesMap;
70
+ }
71
+
72
+ export default createCustomPluginTypesMap;
package/next.config.js ADDED
@@ -0,0 +1,29 @@
1
+ const withLess = require('next-with-less');
2
+ const lowdefyConfig = require('./build/config.json');
3
+
4
+ module.exports = withLess({
5
+ basePath: lowdefyConfig.basePath,
6
+ reactStrictMode: true,
7
+ webpack: (config, { isServer }) => {
8
+ if (!isServer) {
9
+ config.resolve.fallback = {
10
+ assert: false,
11
+ buffer: false,
12
+ crypto: false,
13
+ events: false,
14
+ fs: false,
15
+ path: false,
16
+ process: require.resolve('process/browser'),
17
+ util: false,
18
+ };
19
+ }
20
+ return config;
21
+ },
22
+ poweredByHeader: false,
23
+ // productionBrowserSourceMaps: true
24
+ output: process.env.LOWDEFY_BUILD_OUTPUT_STANDALONE === '1' ? 'standalone' : undefined,
25
+ outputFileTracing: true,
26
+ eslint: {
27
+ ignoreDuringBuilds: true,
28
+ },
29
+ });
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@lowdefy/server",
3
- "version": "0.0.0-alpha.5",
3
+ "version": "0.0.0-experimental-20251203202233",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
7
+ "keywords": [
8
+ "lowdefy",
9
+ "server"
10
+ ],
7
11
  "bugs": {
8
12
  "url": "https://github.com/lowdefy/lowdefy/issues"
9
13
  },
@@ -22,51 +26,59 @@
22
26
  "url": "https://github.com/lowdefy/lowdefy.git"
23
27
  },
24
28
  "files": [
25
- "dist/*"
29
+ "lib/*",
30
+ "lowdefy/*",
31
+ "pages/*",
32
+ "public_default/*",
33
+ "next.config.js",
34
+ "package.original.json",
35
+ ".eslintrc.yaml",
36
+ ".npmrc"
26
37
  ],
27
- "scripts": {
28
- "babel": "babel src --out-dir dist",
29
- "babel:dev": "babel src --out-dir dev",
30
- "build": "yarn webpack && yarn babel",
31
- "build:dev": "yarn webpack:dev && yarn babel:dev",
32
- "build:docker": "docker build --tag lowdefy/lowdefy .",
33
- "clean": "rm -rf dist && rm -rf dev",
34
- "npm-publish": "npm publish --access public",
35
- "prepublishOnly": "yarn build",
36
- "start": "nodemon dev/server.js",
37
- "test": "jest --coverage",
38
- "version:prerelease": "yarn version prerelease",
39
- "version:patch": "yarn version patch -d",
40
- "version:minor": "yarn version minor -d",
41
- "version:major": "yarn version major -d",
42
- "webpack": "webpack --config webpack.prod.js",
43
- "webpack:dev": "webpack --config webpack.dev.js"
44
- },
45
38
  "dependencies": {
46
- "@lowdefy/block-tools": "1.0.3",
47
- "@lowdefy/graphql": "0.0.0-alpha.5",
48
- "apollo-server-express": "2.19.0",
49
- "express": "4.17.1",
50
- "graphql": "15.4.0",
51
- "react": "17.0.1",
52
- "react-dom": "17.0.1"
39
+ "@lowdefy/actions-core": "0.0.0-experimental-20251203202233",
40
+ "@lowdefy/api": "0.0.0-experimental-20251203202233",
41
+ "@lowdefy/block-utils": "0.0.0-experimental-20251203202233",
42
+ "@lowdefy/blocks-antd": "0.0.0-experimental-20251203202233",
43
+ "@lowdefy/blocks-basic": "0.0.0-experimental-20251203202233",
44
+ "@lowdefy/blocks-loaders": "0.0.0-experimental-20251203202233",
45
+ "@lowdefy/client": "0.0.0-experimental-20251203202233",
46
+ "@lowdefy/helpers": "0.0.0-experimental-20251203202233",
47
+ "@lowdefy/layout": "0.0.0-experimental-20251203202233",
48
+ "@lowdefy/node-utils": "0.0.0-experimental-20251203202233",
49
+ "@lowdefy/operators-js": "0.0.0-experimental-20251203202233",
50
+ "@lowdefy/plugin-next-auth": "0.0.0-experimental-20251203202233",
51
+ "next": "13.5.4",
52
+ "next-auth": "4.24.5",
53
+ "pino": "8.16.2",
54
+ "process": "0.11.10",
55
+ "react": "18.2.0",
56
+ "react-dom": "18.2.0",
57
+ "react-icons": "4.12.0"
53
58
  },
54
59
  "devDependencies": {
55
- "@babel/cli": "7.12.1",
56
- "@babel/core": "7.12.3",
57
- "@babel/preset-env": "7.12.1",
58
- "@babel/preset-react": "7.12.5",
59
- "babel-jest": "26.6.3",
60
- "babel-loader": "8.2.1",
61
- "clean-webpack-plugin": "3.0.0",
62
- "css-loader": "5.0.1",
63
- "html-webpack-plugin": "4.5.0",
64
- "jest": "26.6.3",
65
- "nodemon": "2.0.6",
66
- "style-loader": "2.0.0",
67
- "webpack": "5.4.0",
68
- "webpack-cli": "4.2.0",
69
- "webpack-dev-server": "3.11.0",
70
- "webpack-merge": "5.3.0"
60
+ "@lowdefy/build": "0.0.0-experimental-20251203202233",
61
+ "@next/eslint-plugin-next": "13.5.4",
62
+ "less": "4.2.0",
63
+ "less-loader": "11.1.3",
64
+ "next-with-less": "3.0.1",
65
+ "webpack": "5.94.0",
66
+ "yaml": "2.3.4",
67
+ "yargs": "17.7.2"
68
+ },
69
+ "engines": {
70
+ "node": ">=18"
71
+ },
72
+ "publishConfig": {
73
+ "access": "public"
74
+ },
75
+ "scripts": {
76
+ "build": "cp package.json package.original.json || copy package.json package.original.json",
77
+ "build:lowdefy": "node lowdefy/build.mjs",
78
+ "build:next": "next build",
79
+ "dev": "next dev",
80
+ "start": "next start",
81
+ "lint": "next lint",
82
+ "next": "next"
71
83
  }
72
- }
84
+ }
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@lowdefy/server",
3
+ "version": "0.0.0-experimental-20251203202233",
4
+ "license": "Apache-2.0",
5
+ "description": "",
6
+ "homepage": "https://lowdefy.com",
7
+ "keywords": [
8
+ "lowdefy",
9
+ "server"
10
+ ],
11
+ "bugs": {
12
+ "url": "https://github.com/lowdefy/lowdefy/issues"
13
+ },
14
+ "contributors": [
15
+ {
16
+ "name": "Sam Tolmay",
17
+ "url": "https://github.com/SamTolmay"
18
+ },
19
+ {
20
+ "name": "Gerrie van Wyk",
21
+ "url": "https://github.com/Gervwyk"
22
+ }
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/lowdefy/lowdefy.git"
27
+ },
28
+ "files": [
29
+ "lib/*",
30
+ "lowdefy/*",
31
+ "pages/*",
32
+ "public_default/*",
33
+ "next.config.js",
34
+ "package.original.json",
35
+ ".eslintrc.yaml",
36
+ ".npmrc"
37
+ ],
38
+ "scripts": {
39
+ "build": "cp package.json package.original.json || copy package.json package.original.json",
40
+ "build:lowdefy": "node lowdefy/build.mjs",
41
+ "build:next": "next build",
42
+ "dev": "next dev",
43
+ "start": "next start",
44
+ "lint": "next lint",
45
+ "next": "next",
46
+ "prepublishOnly": "pnpm build"
47
+ },
48
+ "dependencies": {
49
+ "@lowdefy/actions-core": "0.0.0-experimental-20251203202233",
50
+ "@lowdefy/api": "0.0.0-experimental-20251203202233",
51
+ "@lowdefy/block-utils": "0.0.0-experimental-20251203202233",
52
+ "@lowdefy/blocks-antd": "0.0.0-experimental-20251203202233",
53
+ "@lowdefy/blocks-basic": "0.0.0-experimental-20251203202233",
54
+ "@lowdefy/blocks-loaders": "0.0.0-experimental-20251203202233",
55
+ "@lowdefy/client": "0.0.0-experimental-20251203202233",
56
+ "@lowdefy/helpers": "0.0.0-experimental-20251203202233",
57
+ "@lowdefy/layout": "0.0.0-experimental-20251203202233",
58
+ "@lowdefy/node-utils": "0.0.0-experimental-20251203202233",
59
+ "@lowdefy/operators-js": "0.0.0-experimental-20251203202233",
60
+ "@lowdefy/plugin-next-auth": "0.0.0-experimental-20251203202233",
61
+ "next": "13.5.4",
62
+ "next-auth": "4.24.5",
63
+ "pino": "8.16.2",
64
+ "process": "0.11.10",
65
+ "react": "18.2.0",
66
+ "react-dom": "18.2.0",
67
+ "react-icons": "4.12.0"
68
+ },
69
+ "devDependencies": {
70
+ "@lowdefy/build": "0.0.0-experimental-20251203202233",
71
+ "@next/eslint-plugin-next": "13.5.4",
72
+ "less": "4.2.0",
73
+ "less-loader": "11.1.3",
74
+ "next-with-less": "3.0.1",
75
+ "webpack": "5.94.0",
76
+ "yaml": "2.3.4",
77
+ "yargs": "17.7.2"
78
+ },
79
+ "engines": {
80
+ "node": ">=18"
81
+ },
82
+ "publishConfig": {
83
+ "access": "public"
84
+ }
85
+ }
package/pages/404.js ADDED
@@ -0,0 +1,47 @@
1
+ /*
2
+ Copyright 2020-2024 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 { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
19
+
20
+ import config from '../build/config.json';
21
+ import fileCache from '../lib/server/fileCache.js';
22
+ import Page from '../lib/client/Page.js';
23
+
24
+ export async function getStaticProps() {
25
+ // Important to give absolute path so Next can trace build files
26
+ const context = {
27
+ buildDirectory: path.join(process.cwd(), 'build'),
28
+ config,
29
+ fileCache,
30
+ logger: console, // TODO: pino or console or 🤷‍♂️?
31
+ };
32
+ createApiContext(context);
33
+
34
+ const [rootConfig, pageConfig] = await Promise.all([
35
+ getRootConfig(context),
36
+ getPageConfig(context, { pageId: '404' }),
37
+ ]);
38
+
39
+ return {
40
+ props: {
41
+ pageConfig,
42
+ rootConfig,
43
+ },
44
+ };
45
+ }
46
+
47
+ export default Page;
@@ -0,0 +1,51 @@
1
+ /*
2
+ Copyright 2020-2024 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 { getPageConfig, getRootConfig } from '@lowdefy/api';
18
+
19
+ import serverSidePropsWrapper from '../lib/server/serverSidePropsWrapper.js';
20
+ import Page from '../lib/client/Page.js';
21
+
22
+ async function getServerSidePropsHandler({ context, nextContext }) {
23
+ const { pageId } = nextContext.params;
24
+ const { logger, session } = context;
25
+ const [rootConfig, pageConfig] = await Promise.all([
26
+ getRootConfig(context),
27
+ getPageConfig(context, { pageId }),
28
+ ]);
29
+
30
+ if (!pageConfig) {
31
+ logger.info({ event: 'redirect_page_not_found', pageId });
32
+ return {
33
+ redirect: {
34
+ destination: '/404',
35
+ permanent: false,
36
+ },
37
+ };
38
+ }
39
+ logger.info({ event: 'page_view', pageId });
40
+ return {
41
+ props: {
42
+ pageConfig,
43
+ rootConfig,
44
+ session,
45
+ },
46
+ };
47
+ }
48
+
49
+ export const getServerSideProps = serverSidePropsWrapper(getServerSidePropsHandler);
50
+
51
+ export default Page;