@lowdefy/server-dev 4.0.0-rc.9 → 4.0.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 (57) hide show
  1. package/lib/{App.js → client/App.js} +5 -5
  2. package/lib/{Page.js → client/Page.js} +1 -1
  3. package/lib/{Reload.js → client/Reload.js} +1 -1
  4. package/lib/{RestartingPage.js → client/RestartingPage.js} +1 -1
  5. package/lib/{auth → client/auth}/Auth.js +2 -2
  6. package/lib/{auth → client/auth}/AuthConfigured.js +2 -2
  7. package/lib/{auth → client/auth}/AuthNotConfigured.js +1 -1
  8. package/lib/{setPageId.js → client/setPageId.js} +1 -1
  9. package/lib/{utils → client/utils}/request.js +1 -1
  10. package/lib/{utils → client/utils}/useMutateCache.js +1 -1
  11. package/lib/{utils → client/utils}/usePageConfig.js +1 -1
  12. package/lib/{utils → client/utils}/useRootConfig.js +1 -1
  13. package/lib/{utils → client/utils}/waitForRestartedServer.js +1 -1
  14. package/lib/server/apiWrapper.js +68 -0
  15. package/lib/server/auth/getAuthOptions.js +35 -0
  16. package/lib/{auth → server/auth}/getServerSession.js +4 -4
  17. package/lib/{fileCache.js → server/fileCache.js} +1 -1
  18. package/lib/server/log/createLogger.js +29 -0
  19. package/lib/server/log/logError.js +40 -0
  20. package/lib/server/log/logRequest.js +33 -0
  21. package/lib/server/validateLicense.js +40 -0
  22. package/manager/getContext.mjs +11 -6
  23. package/manager/processes/initialBuild.mjs +1 -1
  24. package/manager/processes/installPlugins.mjs +1 -1
  25. package/manager/processes/lowdefyBuild.mjs +3 -2
  26. package/manager/processes/nextBuild.mjs +1 -1
  27. package/manager/processes/readDotEnv.mjs +1 -1
  28. package/manager/processes/reloadClients.mjs +1 -1
  29. package/manager/processes/restartServer.mjs +1 -1
  30. package/manager/processes/shutdownServer.mjs +1 -1
  31. package/manager/processes/startServer.mjs +3 -2
  32. package/manager/processes/startWatchers.mjs +1 -1
  33. package/manager/run.mjs +1 -1
  34. package/manager/utils/BatchChanges.mjs +1 -1
  35. package/manager/utils/createCustomPluginTypesMap.mjs +2 -1
  36. package/manager/utils/createLogger.mjs +1 -2
  37. package/manager/utils/createStdOutLineHandler.mjs +33 -0
  38. package/manager/utils/getLowdefyVersion.mjs +1 -1
  39. package/manager/utils/getNextBin.mjs +1 -1
  40. package/manager/utils/setupWatcher.mjs +1 -1
  41. package/manager/watchers/envWatcher.mjs +1 -1
  42. package/manager/watchers/lowdefyBuildWatcher.mjs +1 -1
  43. package/manager/watchers/nextBuildWatcher.mjs +2 -2
  44. package/package.json +50 -46
  45. package/package.original.json +43 -38
  46. package/pages/404.js +2 -2
  47. package/pages/[pageId].js +2 -2
  48. package/pages/_app.js +9 -5
  49. package/pages/_document.js +1 -1
  50. package/pages/api/auth/[...nextauth].js +7 -20
  51. package/pages/api/license.js +22 -0
  52. package/pages/api/page/[pageId].js +8 -16
  53. package/pages/api/ping.js +1 -1
  54. package/pages/api/reload.js +1 -1
  55. package/pages/api/request/[pageId]/[requestId].js +13 -31
  56. package/pages/api/root.js +7 -17
  57. package/pages/index.js +2 -2
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
@@ -26,10 +26,10 @@ import Page from './Page.js';
26
26
  import setPageId from './setPageId.js';
27
27
  import useRootConfig from './utils/useRootConfig.js';
28
28
 
29
- import actions from '../build/plugins/actions.js';
30
- import blocks from '../build/plugins/blocks.js';
31
- import icons from '../build/plugins/icons.js';
32
- import operators from '../build/plugins/operators/client.js';
29
+ import actions from '../../build/plugins/actions.js';
30
+ import blocks from '../../build/plugins/blocks.js';
31
+ import icons from '../../build/plugins/icons.js';
32
+ import operators from '../../build/plugins/operators/client.js';
33
33
 
34
34
  const App = ({ auth, lowdefy }) => {
35
35
  const router = useRouter();
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
@@ -19,7 +19,7 @@ import React from 'react';
19
19
  import AuthConfigured from './AuthConfigured.js';
20
20
  import AuthNotConfigured from './AuthNotConfigured.js';
21
21
 
22
- import authConfig from '../../build/auth.json';
22
+ import authConfig from '../../../build/auth.json';
23
23
 
24
24
  function Auth({ children, session }) {
25
25
  if (authConfig.configured === true) {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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,7 +18,7 @@
18
18
  import React, { useEffect, useRef } from 'react';
19
19
  import { getSession, SessionProvider, signIn, signOut, useSession } from 'next-auth/react';
20
20
 
21
- import lowdefyConfig from '../../build/config.json';
21
+ import lowdefyConfig from '../../../build/config.json';
22
22
 
23
23
  function Session({ children }) {
24
24
  const wasAuthenticated = useRef(false);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
5
5
  You may obtain a copy of the License at
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
5
5
  You may obtain a copy of the License at
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
@@ -0,0 +1,68 @@
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
+ import path from 'path';
17
+ import crypto from 'crypto';
18
+ import { createApiContext } from '@lowdefy/api';
19
+ import { getSecretsFromEnv } from '@lowdefy/node-utils';
20
+
21
+ import config from '../../build/config.json';
22
+ import connections from '../../build/plugins/connections.js';
23
+ import createLogger from './log/createLogger.js';
24
+ import fileCache from './fileCache.js';
25
+ import getServerSession from './auth/getServerSession.js';
26
+ import logError from './log/logError.js';
27
+ import logRequest from './log/logRequest.js';
28
+ import operators from '../../build/plugins/operators/server.js';
29
+ import getAuthOptions from './auth/getAuthOptions.js';
30
+
31
+ const secrets = getSecretsFromEnv();
32
+
33
+ function apiWrapper(handler) {
34
+ return async function wrappedHandler(req, res) {
35
+ const context = {
36
+ // Important to give absolute path so Next can trace build files
37
+ rid: crypto.randomUUID(),
38
+ buildDirectory: path.join(process.cwd(), 'build'),
39
+ config,
40
+ connections,
41
+ fileCache,
42
+ headers: req?.headers,
43
+ logger: console,
44
+ operators,
45
+ req,
46
+ res,
47
+ secrets,
48
+ };
49
+ try {
50
+ context.logger = createLogger({ rid: context.rid });
51
+ context.authOptions = getAuthOptions(context);
52
+ if (!req.url.startsWith('/api/auth')) {
53
+ context.session = await getServerSession(context);
54
+ }
55
+ createApiContext(context);
56
+ logRequest({ context });
57
+ // Await here so that if handler throws it is caught.
58
+ const response = await handler({ context, req, res });
59
+ // TODO: Log response time?
60
+ return response;
61
+ } catch (error) {
62
+ logError({ error, context });
63
+ res.status(500).json({ name: error.name, message: error.message });
64
+ }
65
+ };
66
+ }
67
+
68
+ export default apiWrapper;
@@ -0,0 +1,35 @@
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 { getNextAuthConfig } from '@lowdefy/api';
18
+ import { getSecretsFromEnv } from '@lowdefy/node-utils';
19
+
20
+ import adapters from '../../../build/plugins/auth/adapters.js';
21
+ import authJson from '../../../build/auth.json';
22
+ import callbacks from '../../../build/plugins/auth/callbacks.js';
23
+ import events from '../../../build/plugins/auth/events.js';
24
+ import providers from '../../../build/plugins/auth/providers.js';
25
+
26
+ function getAuthOptions({ logger }) {
27
+ return getNextAuthConfig({
28
+ authJson,
29
+ logger,
30
+ plugins: { adapters, callbacks, events, providers },
31
+ secrets: getSecretsFromEnv(),
32
+ });
33
+ }
34
+
35
+ export default getAuthOptions;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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,10 +15,10 @@
15
15
  */
16
16
 
17
17
  import { getServerSession as getNextAuthServerSession } from 'next-auth/next';
18
- import { authOptions } from '../../pages/api/auth/[...nextauth].js';
19
- import authJson from '../../build/auth.json';
20
18
 
21
- function getServerSession({ req, res }) {
19
+ import authJson from '../../../build/auth.json';
20
+
21
+ function getServerSession({ authOptions, req, res }) {
22
22
  if (authJson.configured === true) {
23
23
  return getNextAuthServerSession(req, res, authOptions);
24
24
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
@@ -0,0 +1,29 @@
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 pino from 'pino';
18
+
19
+ const logger = pino({
20
+ name: 'lowdefy_server',
21
+ level: process.env.LOWDEFY_LOG_LEVEL ?? 'info',
22
+ base: { pid: undefined, hostname: undefined },
23
+ });
24
+
25
+ function createLogger(metadata = {}) {
26
+ return logger.child(metadata);
27
+ }
28
+
29
+ export default createLogger;
@@ -0,0 +1,40 @@
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 { user = {} } = context;
20
+
21
+ context.logger.error({
22
+ err: error,
23
+ user: {
24
+ id: user.id,
25
+ roles: user.roles,
26
+ sub: user.sub,
27
+ session_id: user.session_id,
28
+ },
29
+ url: context.req.url,
30
+ method: context.req.method,
31
+ resolvedUrl: context.nextContext?.resolvedUrl,
32
+ });
33
+ } catch (e) {
34
+ console.error(error);
35
+ console.error('An error occurred while logging the error.');
36
+ console.error(e);
37
+ }
38
+ }
39
+
40
+ export default logError;
@@ -0,0 +1,33 @@
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 { user = {} } = context;
20
+ context.logger.debug({
21
+ user: {
22
+ id: user.id,
23
+ roles: user.roles,
24
+ sub: user.sub,
25
+ session_id: user.session_id,
26
+ },
27
+ url: context.req.url,
28
+ method: context.req.method,
29
+ resolvedUrl: context.nextContext?.resolvedUrl,
30
+ });
31
+ }
32
+
33
+ export default logRequest;
@@ -0,0 +1,40 @@
1
+ /*
2
+ Copyright (C) 2023 Lowdefy, Inc
3
+ Use of this software is governed by the Business Source License included in the LICENSE file and at www.mariadb.com/bsl11.
4
+
5
+ Change Date: 2027-10-09
6
+
7
+ On the date above, in accordance with the Business Source License, use
8
+ of this software will be governed by the Apache License, Version 2.0.
9
+ */
10
+ import { keygenValidateLicense } from '@lowdefy/node-utils';
11
+
12
+ const config = {
13
+ dev: {
14
+ accountId: 'bf35f4ae-53a8-45c6-9eed-2d1fc9f53bd6',
15
+ productId: '4254760d-e760-4932-bb96-ba767e6ae780',
16
+ publicKey: 'MCowBQYDK2VwAyEAN27y1DiHiEDYFbNGjgfFdWygxrVSetq6rApWq3psJZI=',
17
+ },
18
+ prod: {
19
+ accountId: '63b3d4e4-39e1-4ccc-8c58-6b8f97ddf4fa',
20
+ productId: 'd19a5af0-4147-4a65-8b6d-0706d7804bc1',
21
+ publicKey: 'MCowBQYDK2VwAyEAFPoseE3gi+YsJziigc1kFKOkdUIBiUMd9RZujTh23Fc=',
22
+ },
23
+ };
24
+
25
+ let license;
26
+
27
+ async function validateLicense() {
28
+ if (license) {
29
+ // Check cached license every 24 hours
30
+ if (license?.timestamp?.valueOf?.() > Date.now() - 1000 * 60 * 60 * 24) {
31
+ return license;
32
+ }
33
+ }
34
+ license = await keygenValidateLicense({
35
+ config: config[process.env.LOWDEFY_LICENSE_ENV ?? 'prod'],
36
+ });
37
+ return license;
38
+ }
39
+
40
+ export default validateLicense;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
@@ -43,20 +43,25 @@ async function getContext() {
43
43
  },
44
44
  directories: {
45
45
  build: path.resolve(process.cwd(), './build'),
46
- config: path.resolve(argv.configDirectory || env.LOWDEFY_DIRECTORY_CONFIG || process.cwd()),
46
+ config: path.resolve(argv.configDirectory ?? env.LOWDEFY_DIRECTORY_CONFIG ?? process.cwd()),
47
47
  server: process.cwd(),
48
48
  },
49
49
  logger: createLogger({ level: env.LOWDEFY_LOG_LEVEL }),
50
50
  options: {
51
- port: argv.port || env.PORT || 3000,
52
- refResolver: argv.refResolver || env.LOWDEFY_BUILD_REF_RESOLVER,
51
+ port: argv.port ?? env.PORT ?? 3000,
52
+ refResolver: argv.refResolver ?? env.LOWDEFY_BUILD_REF_RESOLVER,
53
53
  watch:
54
- argv.watch || env.LOWDEFY_SERVER_DEV_WATCH ? JSON.parse(env.LOWDEFY_SERVER_DEV_WATCH) : [],
54
+ argv.watch ?? env.LOWDEFY_SERVER_DEV_WATCH ? JSON.parse(env.LOWDEFY_SERVER_DEV_WATCH) : [],
55
55
  watchIgnore:
56
- argv.watchIgnore || env.LOWDEFY_SERVER_DEV_WATCH_IGNORE
56
+ argv.watchIgnore ?? env.LOWDEFY_SERVER_DEV_WATCH_IGNORE
57
57
  ? JSON.parse(env.LOWDEFY_SERVER_DEV_WATCH_IGNORE)
58
58
  : [],
59
59
  },
60
+ license: {
61
+ entitlements: env.LOWDEFY_LICENSE_ENTITLEMENTS
62
+ ? JSON.parse(env.LOWDEFY_LICENSE_ENTITLEMENTS)
63
+ : [],
64
+ },
60
65
  version: env.npm_package_version,
61
66
  };
62
67
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /*
3
- Copyright 2020-2023 Lowdefy, Inc
3
+ Copyright 2020-2024 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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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,13 +17,14 @@
17
17
  import build from '@lowdefy/build';
18
18
  import createCustomPluginTypesMap from '../utils/createCustomPluginTypesMap.mjs';
19
19
 
20
- function lowdefyBuild({ directories, logger, options }) {
20
+ function lowdefyBuild({ directories, logger, options, license }) {
21
21
  return async () => {
22
22
  logger.info({ print: 'spin' }, 'Building config...');
23
23
  const customTypesMap = await createCustomPluginTypesMap({ directories, logger });
24
24
  await build({
25
25
  customTypesMap,
26
26
  directories,
27
+ entitlements: license.entitlements,
27
28
  logger,
28
29
  refResolver: options.refResolver,
29
30
  stage: 'dev',
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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,12 +15,13 @@
15
15
  */
16
16
 
17
17
  import { spawnProcess } from '@lowdefy/node-utils';
18
+ import createStdOutLineHandler from '../utils/createStdOutLineHandler.mjs';
18
19
 
19
20
  function startServer(context) {
20
21
  context.shutdownServer();
21
22
 
22
23
  const nextServer = spawnProcess({
23
- stdOutLineHandler: (line) => context.logger.info({ print: 'log' }, line),
24
+ stdOutLineHandler: createStdOutLineHandler({ context }),
24
25
  stdErrLineHandler: (line) => context.logger.error(line),
25
26
  command: 'node',
26
27
  args: [context.bin.next, 'start'],
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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/manager/run.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /*
3
- Copyright 2020-2023 Lowdefy, Inc
3
+ Copyright 2020-2024 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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /*
3
- Copyright 2020-2023 Lowdefy, Inc
3
+ Copyright 2020-2024 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.
@@ -61,6 +61,7 @@ async function createCustomPluginTypesMap({ directories, logger }) {
61
61
  types = (await import(`${plugin.name}/types`)).default;
62
62
  } catch (e) {
63
63
  logger.error(`Failed to import plugin "${plugin.name}".`);
64
+ logger.debug(e);
64
65
  logger.info('If the plugin was added while the server was running, restart the server.');
65
66
  throw new Error(`Failed to import plugin "${plugin.name}".`);
66
67
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
@@ -20,7 +20,6 @@ function createLogger({ level = 'info' }) {
20
20
  name: 'lowdefy build',
21
21
  level,
22
22
  base: { pid: undefined, hostname: undefined },
23
- // TODO: Add log as custom level
24
23
  mixin: (context, level) => {
25
24
  return {
26
25
  ...context,
@@ -0,0 +1,33 @@
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 createStdOutLineHandler({ context }) {
18
+ const { logger } = context;
19
+ function stdOutLineHandler(line) {
20
+ try {
21
+ const { level, name, time, rid, ...msgObj } = JSON.parse(line);
22
+ if (level) {
23
+ const print = level === 30 ? 'log' : logger.levels.labels[level];
24
+ logger[logger.levels.labels[level]]({ print }, JSON.stringify(msgObj));
25
+ }
26
+ } catch (error) {
27
+ logger.info({ print: 'log' }, line);
28
+ }
29
+ }
30
+ return stdOutLineHandler;
31
+ }
32
+
33
+ export default createStdOutLineHandler;