@lowdefy/server 4.5.1 → 4.6.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 (39) hide show
  1. package/lib/build/app.js +19 -0
  2. package/lib/build/auth.js +19 -0
  3. package/lib/build/config.js +19 -0
  4. package/lib/build/logger.js +19 -0
  5. package/lib/client/Page.js +1 -1
  6. package/lib/client/auth/Auth.js +2 -2
  7. package/lib/client/auth/AuthConfigured.js +2 -2
  8. package/lib/client/auth/AuthNotConfigured.js +1 -1
  9. package/lib/client/createLogUsage.js +1 -1
  10. package/lib/client/sentry/captureSentryError.js +43 -0
  11. package/lib/client/sentry/initSentryClient.js +55 -0
  12. package/lib/client/sentry/setSentryUser.js +41 -0
  13. package/lib/server/apiWrapper.js +23 -5
  14. package/lib/server/auth/getAuthOptions.js +2 -2
  15. package/lib/server/auth/getServerSession.js +2 -2
  16. package/lib/server/fileCache.js +1 -1
  17. package/lib/server/log/createHandleError.js +151 -0
  18. package/lib/server/log/createLogger.js +3 -5
  19. package/lib/server/log/logRequest.js +1 -1
  20. package/lib/server/sentry/captureSentryError.js +57 -0
  21. package/lib/server/sentry/initSentry.js +44 -0
  22. package/lib/server/sentry/setSentryUser.js +46 -0
  23. package/lib/server/serverSidePropsWrapper.js +8 -4
  24. package/lowdefy/build.mjs +17 -10
  25. package/lowdefy/createCustomPluginTypesMap.mjs +1 -1
  26. package/next.config.js +12 -1
  27. package/package.json +24 -20
  28. package/package.original.json +24 -20
  29. package/pages/404.js +2 -2
  30. package/pages/[pageId].js +1 -1
  31. package/pages/_app.js +26 -3
  32. package/pages/_document.js +3 -3
  33. package/pages/api/auth/[...nextauth].js +2 -2
  34. package/pages/api/client-error.js +58 -0
  35. package/pages/api/endpoints/[endpointId].js +1 -1
  36. package/pages/api/request/[pageId]/[requestId].js +3 -3
  37. package/pages/api/usage.js +2 -2
  38. package/pages/index.js +1 -1
  39. package/lib/server/log/logError.js +0 -72
@@ -0,0 +1,46 @@
1
+ /*
2
+ Copyright 2020-2026 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 * as Sentry from '@sentry/nextjs';
18
+
19
+ function setSentryUser({ user, sentryConfig }) {
20
+ // No-op if Sentry not initialized (DSN not set)
21
+ if (!process.env.SENTRY_DSN) {
22
+ return;
23
+ }
24
+
25
+ // No-op if no user
26
+ if (!user) {
27
+ Sentry.setUser(null);
28
+ return;
29
+ }
30
+
31
+ const userFields = sentryConfig?.userFields || ['id', '_id'];
32
+ const sentryUser = {};
33
+
34
+ userFields.forEach((field) => {
35
+ if (user[field] !== undefined) {
36
+ sentryUser[field] = user[field];
37
+ }
38
+ });
39
+
40
+ // Only set user if we have at least one field
41
+ if (Object.keys(sentryUser).length > 0) {
42
+ Sentry.setUser(sentryUser);
43
+ }
44
+ }
45
+
46
+ export default setSentryUser;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 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.
@@ -18,11 +18,11 @@ import path from 'path';
18
18
  import { createApiContext } from '@lowdefy/api';
19
19
  import { v4 as uuid } from 'uuid';
20
20
 
21
- import config from '../../build/config.json';
21
+ import config from '../build/config.js';
22
22
  import createLogger from './log/createLogger.js';
23
23
  import fileCache from './fileCache.js';
24
24
  import getServerSession from './auth/getServerSession.js';
25
- import logError from './log/logError.js';
25
+ import createHandleError from './log/createHandleError.js';
26
26
  import logRequest from './log/logRequest.js';
27
27
  import getAuthOptions from './auth/getAuthOptions.js';
28
28
 
@@ -35,6 +35,9 @@ function serverSidePropsWrapper(handler) {
35
35
  buildDirectory: path.join(process.cwd(), 'build'),
36
36
  config,
37
37
  fileCache,
38
+ handleError: async (err) => {
39
+ console.error(err);
40
+ },
38
41
  headers: nextContext?.req?.headers,
39
42
  logger: console,
40
43
  nextContext,
@@ -43,6 +46,7 @@ function serverSidePropsWrapper(handler) {
43
46
  };
44
47
  try {
45
48
  context.logger = createLogger({ rid: context.rid });
49
+ context.handleError = createHandleError({ context });
46
50
  context.authOptions = getAuthOptions(context);
47
51
  context.session = await getServerSession(context);
48
52
  createApiContext(context);
@@ -51,7 +55,7 @@ function serverSidePropsWrapper(handler) {
51
55
  const response = await handler({ context, nextContext });
52
56
  return response;
53
57
  } catch (error) {
54
- logError({ error, context });
58
+ await context.handleError(error);
55
59
  throw error;
56
60
  }
57
61
  };
package/lowdefy/build.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /*
3
- Copyright 2020-2024 Lowdefy, Inc
3
+ Copyright 2020-2026 Lowdefy, Inc
4
4
 
5
5
  Licensed under the Apache License, Version 2.0 (the "License");
6
6
  you may not use this file except in compliance with the License.
@@ -16,11 +16,12 @@
16
16
  */
17
17
 
18
18
  import path from 'path';
19
- import pino from 'pino';
20
19
  import yargs from 'yargs';
21
20
  import { hideBin } from 'yargs/helpers';
22
21
 
23
22
  import build from '@lowdefy/build';
23
+ import { BuildError } from '@lowdefy/errors';
24
+ import { createNodeLogger } from '@lowdefy/logger/node';
24
25
  import createCustomPluginTypesMap from './createCustomPluginTypesMap.mjs';
25
26
 
26
27
  const argv = yargs(hideBin(process.argv)).argv;
@@ -39,16 +40,15 @@ async function run() {
39
40
 
40
41
  const customTypesMap = await createCustomPluginTypesMap({ directories });
41
42
 
42
- const logger = pino({
43
+ let logger;
44
+ logger = createNodeLogger({
43
45
  name: 'lowdefy_build',
44
46
  level: process.env.LOWDEFY_LOG_LEVEL ?? 'info',
45
47
  base: { pid: undefined, hostname: undefined },
46
- mixin: (context, level) => {
47
- return {
48
- ...context,
49
- print: context.print ?? logger.levels.labels[level],
50
- };
51
- },
48
+ mixin: (context, level) => ({
49
+ ...context,
50
+ print: context.print ?? logger.levels.labels[level],
51
+ }),
52
52
  });
53
53
 
54
54
  await build({
@@ -59,4 +59,11 @@ async function run() {
59
59
  });
60
60
  }
61
61
 
62
- run();
62
+ run().catch((error) => {
63
+ if (error instanceof BuildError) {
64
+ console.error(error.message);
65
+ process.exit(1);
66
+ }
67
+ // Otherwise, show full error with stack trace
68
+ throw error;
69
+ });
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /*
3
- Copyright 2020-2024 Lowdefy, Inc
3
+ Copyright 2020-2026 Lowdefy, Inc
4
4
 
5
5
  Licensed under the Apache License, Version 2.0 (the "License");
6
6
  you may not use this file except in compliance with the License.
package/next.config.js CHANGED
@@ -1,7 +1,8 @@
1
+ const { withSentryConfig } = require('@sentry/nextjs');
1
2
  const withLess = require('next-with-less');
2
3
  const lowdefyConfig = require('./build/config.json');
3
4
 
4
- module.exports = withLess({
5
+ const nextConfig = withLess({
5
6
  basePath: lowdefyConfig.basePath,
6
7
  reactStrictMode: true,
7
8
  webpack: (config, { isServer }) => {
@@ -27,3 +28,13 @@ module.exports = withLess({
27
28
  ignoreDuringBuilds: true,
28
29
  },
29
30
  });
31
+
32
+ // Only wrap with Sentry if SENTRY_DSN is configured
33
+ // This enables source map uploads when SENTRY_AUTH_TOKEN is present
34
+ module.exports = process.env.SENTRY_DSN
35
+ ? withSentryConfig(nextConfig, {
36
+ // Sentry options
37
+ silent: true,
38
+ hideSourceMaps: true,
39
+ })
40
+ : nextConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server",
3
- "version": "4.5.1",
3
+ "version": "4.6.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -36,33 +36,37 @@
36
36
  ".npmrc"
37
37
  ],
38
38
  "dependencies": {
39
- "@lowdefy/actions-core": "4.5.1",
40
- "@lowdefy/api": "4.5.1",
41
- "@lowdefy/block-utils": "4.5.1",
42
- "@lowdefy/blocks-antd": "4.5.1",
43
- "@lowdefy/blocks-basic": "4.5.1",
44
- "@lowdefy/blocks-loaders": "4.5.1",
45
- "@lowdefy/blocks-markdown": "4.5.1",
46
- "@lowdefy/client": "4.5.1",
47
- "@lowdefy/connection-axios-http": "4.5.1",
48
- "@lowdefy/connection-mongodb": "4.5.1",
49
- "@lowdefy/helpers": "4.5.1",
50
- "@lowdefy/layout": "4.5.1",
51
- "@lowdefy/node-utils": "4.5.1",
52
- "@lowdefy/operators-js": "4.5.1",
53
- "@lowdefy/operators-nunjucks": "4.5.1",
54
- "@lowdefy/operators-uuid": "4.5.1",
55
- "@lowdefy/plugin-next-auth": "4.5.1",
39
+ "@lowdefy/actions-core": "4.6.0",
40
+ "@lowdefy/api": "4.6.0",
41
+ "@lowdefy/block-utils": "4.6.0",
42
+ "@lowdefy/blocks-antd": "4.6.0",
43
+ "@lowdefy/blocks-basic": "4.6.0",
44
+ "@lowdefy/blocks-loaders": "4.6.0",
45
+ "@lowdefy/blocks-markdown": "4.6.0",
46
+ "@lowdefy/client": "4.6.0",
47
+ "@lowdefy/connection-axios-http": "4.6.0",
48
+ "@lowdefy/connection-mongodb": "4.6.0",
49
+ "@lowdefy/errors": "4.6.0",
50
+ "@lowdefy/helpers": "4.6.0",
51
+ "@lowdefy/layout": "4.6.0",
52
+ "@lowdefy/logger": "4.6.0",
53
+ "@lowdefy/node-utils": "4.6.0",
54
+ "@lowdefy/operators-js": "4.6.0",
55
+ "@lowdefy/operators-nunjucks": "4.6.0",
56
+ "@lowdefy/operators-uuid": "4.6.0",
57
+ "@lowdefy/plugin-next-auth": "4.6.0",
58
+ "@sentry/nextjs": "8.53.0",
56
59
  "next": "13.5.4",
57
60
  "next-auth": "4.24.5",
58
61
  "pino": "8.16.2",
59
62
  "process": "0.11.10",
60
63
  "react": "18.2.0",
61
64
  "react-dom": "18.2.0",
62
- "react-icons": "4.12.0"
65
+ "react-icons": "4.12.0",
66
+ "uuid": "13.0.0"
63
67
  },
64
68
  "devDependencies": {
65
- "@lowdefy/build": "4.5.1",
69
+ "@lowdefy/build": "4.6.0",
66
70
  "@next/eslint-plugin-next": "13.5.4",
67
71
  "less": "4.2.0",
68
72
  "less-loader": "11.1.3",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server",
3
- "version": "4.5.1",
3
+ "version": "4.6.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -46,33 +46,37 @@
46
46
  "prepublishOnly": "pnpm build"
47
47
  },
48
48
  "dependencies": {
49
- "@lowdefy/actions-core": "4.5.1",
50
- "@lowdefy/api": "4.5.1",
51
- "@lowdefy/block-utils": "4.5.1",
52
- "@lowdefy/blocks-antd": "4.5.1",
53
- "@lowdefy/blocks-basic": "4.5.1",
54
- "@lowdefy/blocks-loaders": "4.5.1",
55
- "@lowdefy/blocks-markdown": "4.5.1",
56
- "@lowdefy/client": "4.5.1",
57
- "@lowdefy/connection-axios-http": "4.5.1",
58
- "@lowdefy/connection-mongodb": "4.5.1",
59
- "@lowdefy/helpers": "4.5.1",
60
- "@lowdefy/layout": "4.5.1",
61
- "@lowdefy/node-utils": "4.5.1",
62
- "@lowdefy/operators-js": "4.5.1",
63
- "@lowdefy/operators-nunjucks": "4.5.1",
64
- "@lowdefy/operators-uuid": "4.5.1",
65
- "@lowdefy/plugin-next-auth": "4.5.1",
49
+ "@lowdefy/actions-core": "4.6.0",
50
+ "@lowdefy/api": "4.6.0",
51
+ "@lowdefy/block-utils": "4.6.0",
52
+ "@lowdefy/blocks-antd": "4.6.0",
53
+ "@lowdefy/blocks-basic": "4.6.0",
54
+ "@lowdefy/blocks-loaders": "4.6.0",
55
+ "@lowdefy/blocks-markdown": "4.6.0",
56
+ "@lowdefy/client": "4.6.0",
57
+ "@lowdefy/connection-axios-http": "4.6.0",
58
+ "@lowdefy/connection-mongodb": "4.6.0",
59
+ "@lowdefy/errors": "4.6.0",
60
+ "@lowdefy/helpers": "4.6.0",
61
+ "@lowdefy/layout": "4.6.0",
62
+ "@lowdefy/logger": "4.6.0",
63
+ "@lowdefy/node-utils": "4.6.0",
64
+ "@lowdefy/operators-js": "4.6.0",
65
+ "@lowdefy/operators-nunjucks": "4.6.0",
66
+ "@lowdefy/operators-uuid": "4.6.0",
67
+ "@lowdefy/plugin-next-auth": "4.6.0",
68
+ "@sentry/nextjs": "8.53.0",
66
69
  "next": "13.5.4",
67
70
  "next-auth": "4.24.5",
68
71
  "pino": "8.16.2",
69
72
  "process": "0.11.10",
70
73
  "react": "18.2.0",
71
74
  "react-dom": "18.2.0",
72
- "react-icons": "4.12.0"
75
+ "react-icons": "4.12.0",
76
+ "uuid": "13.0.0"
73
77
  },
74
78
  "devDependencies": {
75
- "@lowdefy/build": "4.5.1",
79
+ "@lowdefy/build": "4.6.0",
76
80
  "@next/eslint-plugin-next": "13.5.4",
77
81
  "less": "4.2.0",
78
82
  "less-loader": "11.1.3",
package/pages/404.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
17
17
  import path from 'path';
18
18
  import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
19
19
 
20
- import config from '../build/config.json';
20
+ import config from '../lib/build/config.js';
21
21
  import fileCache from '../lib/server/fileCache.js';
22
22
  import Page from '../lib/client/Page.js';
23
23
 
package/pages/[pageId].js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 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.
package/pages/_app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 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,25 +14,48 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
- import React, { useRef } from 'react';
17
+ import React, { useCallback, useRef } from 'react';
18
18
  import dynamic from 'next/dynamic';
19
19
 
20
20
  import { ErrorBoundary } from '@lowdefy/block-utils';
21
21
 
22
22
  import Auth from '../lib/client/auth/Auth.js';
23
23
  import createLogUsage from '../lib/client/createLogUsage.js';
24
+ import initSentryClient from '../lib/client/sentry/initSentryClient.js';
25
+ import loggerConfig from '../lib/build/logger.js';
26
+ import setSentryUser from '../lib/client/sentry/setSentryUser.js';
24
27
 
25
28
  // Must be in _app due to next specifications.
26
29
  import '../build/plugins/styles.less';
27
30
 
31
+ // Initialize Sentry client once on module load
32
+ initSentryClient({
33
+ sentryDsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
34
+ sentryConfig: loggerConfig.sentry,
35
+ });
36
+
28
37
  function App({ Component, pageProps: { session, rootConfig, pageConfig } }) {
29
38
  const usageDataRef = useRef({});
30
39
  const lowdefyRef = useRef({ eventCallback: createLogUsage({ usageDataRef }) });
40
+
41
+ const handleError = useCallback((error) => {
42
+ if (lowdefyRef.current?._internal?.handleError) {
43
+ lowdefyRef.current._internal.handleError(error);
44
+ } else {
45
+ console.error(error);
46
+ }
47
+ }, []);
48
+
31
49
  return (
32
- <ErrorBoundary fullPage>
50
+ <ErrorBoundary fullPage onError={handleError}>
33
51
  <Auth session={session}>
34
52
  {(auth) => {
35
53
  usageDataRef.current.user = auth.session?.hashed_id;
54
+ // Set Sentry user context when auth changes
55
+ setSentryUser({
56
+ user: auth.session,
57
+ sentryConfig: loggerConfig.sentry,
58
+ });
36
59
  return (
37
60
  <Component
38
61
  auth={auth}
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -17,8 +17,8 @@
17
17
  import React from 'react';
18
18
  import Document, { Html, Head, Main, NextScript } from 'next/document';
19
19
 
20
- import appJson from '../build/app.json';
21
- import lowdefyConfig from '../build/config.json';
20
+ import appJson from '../lib/build/app.js';
21
+ import lowdefyConfig from '../lib/build/config.js';
22
22
 
23
23
  const basePath = lowdefyConfig.basePath ?? '';
24
24
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
17
17
  import NextAuth from 'next-auth';
18
18
 
19
19
  import apiWrapper from '../../../lib/server/apiWrapper.js';
20
- import authJson from '../../../build/auth.json';
20
+ import authJson from '../../../lib/build/auth.js';
21
21
 
22
22
  async function handler({ context, req, res }) {
23
23
  if (authJson.configured !== true) {
@@ -0,0 +1,58 @@
1
+ /*
2
+ Copyright 2020-2026 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 { logClientError } from '@lowdefy/api';
18
+
19
+ import apiWrapper from '../../lib/server/apiWrapper.js';
20
+ import captureSentryError from '../../lib/server/sentry/captureSentryError.js';
21
+
22
+ async function handler({ context, req, res }) {
23
+ if (req.method !== 'POST') {
24
+ throw new Error('Only POST requests are supported.');
25
+ }
26
+
27
+ const origin = req.headers.origin;
28
+ if (!origin) {
29
+ res.status(403).json({ error: 'Forbidden' });
30
+ return;
31
+ }
32
+ try {
33
+ if (new URL(origin).host !== req.headers.host) {
34
+ res.status(403).json({ error: 'Forbidden' });
35
+ return;
36
+ }
37
+ } catch {
38
+ res.status(403).json({ error: 'Forbidden' });
39
+ return;
40
+ }
41
+
42
+ // Strip received from payload — prod doesn't need it for schema validation
43
+ if (req.body?.['~e']) {
44
+ delete req.body['~e'].received;
45
+ }
46
+ const { error, ...response } = await logClientError(context, req.body);
47
+
48
+ // Capture client error to Sentry (no-op if Sentry not configured)
49
+ captureSentryError({
50
+ error,
51
+ context,
52
+ configLocation: response.source ? { source: response.source, config: response.config } : null,
53
+ });
54
+
55
+ res.status(200).json({ success: true });
56
+ }
57
+
58
+ export default apiWrapper(handler);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 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.
@@ -23,8 +23,8 @@ async function handler({ context, req, res }) {
23
23
  throw new Error('Only POST requests are supported.');
24
24
  }
25
25
  const { pageId, requestId } = req.query;
26
- const { blockId, payload } = req.body;
27
- context.logger.info({ event: 'call_request', pageId, requestId, blockId });
26
+ const { actionId, blockId, payload } = req.body;
27
+ context.logger.info({ event: 'call_request', pageId, requestId, blockId, actionId });
28
28
  const response = await callRequest(context, { blockId, pageId, payload, requestId });
29
29
  res.status(200).json(response);
30
30
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
17
17
  // TODO
18
18
  // import crypto from 'crypto';
19
19
 
20
- import appJson from '../../build/app.json';
20
+ import appJson from '../../lib/build/app.js';
21
21
  import packageJson from '../../package.json';
22
22
  import apiWrapper from '../../lib/server/apiWrapper.js';
23
23
  // import validateLicense from '../../lib/server/validateLicense.js';
package/pages/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2024 Lowdefy, Inc
2
+ Copyright 2020-2026 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,72 +0,0 @@
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;