@lowdefy/server 4.0.0-alpha.34 → 4.0.0-alpha.36

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.
@@ -0,0 +1,21 @@
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 { LRUCache } from '@lowdefy/helpers';
18
+
19
+ const fileCache = new LRUCache({ maxSize: 100 });
20
+
21
+ export default fileCache;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server",
3
- "version": "4.0.0-alpha.34",
3
+ "version": "4.0.0-alpha.36",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -43,17 +43,17 @@
43
43
  "next": "next"
44
44
  },
45
45
  "dependencies": {
46
- "@lowdefy/actions-core": "4.0.0-alpha.34",
47
- "@lowdefy/api": "4.0.0-alpha.34",
48
- "@lowdefy/blocks-antd": "4.0.0-alpha.34",
49
- "@lowdefy/blocks-basic": "4.0.0-alpha.34",
50
- "@lowdefy/blocks-loaders": "4.0.0-alpha.34",
51
- "@lowdefy/client": "4.0.0-alpha.34",
52
- "@lowdefy/helpers": "4.0.0-alpha.34",
53
- "@lowdefy/layout": "4.0.0-alpha.34",
54
- "@lowdefy/node-utils": "4.0.0-alpha.34",
55
- "@lowdefy/operators-js": "4.0.0-alpha.34",
56
- "@lowdefy/plugin-next-auth": "4.0.0-alpha.34",
46
+ "@lowdefy/actions-core": "4.0.0-alpha.36",
47
+ "@lowdefy/api": "4.0.0-alpha.36",
48
+ "@lowdefy/blocks-antd": "4.0.0-alpha.36",
49
+ "@lowdefy/blocks-basic": "4.0.0-alpha.36",
50
+ "@lowdefy/blocks-loaders": "4.0.0-alpha.36",
51
+ "@lowdefy/client": "4.0.0-alpha.36",
52
+ "@lowdefy/helpers": "4.0.0-alpha.36",
53
+ "@lowdefy/layout": "4.0.0-alpha.36",
54
+ "@lowdefy/node-utils": "4.0.0-alpha.36",
55
+ "@lowdefy/operators-js": "4.0.0-alpha.36",
56
+ "@lowdefy/plugin-next-auth": "4.0.0-alpha.36",
57
57
  "next": "12.3.1",
58
58
  "next-auth": "4.10.3",
59
59
  "process": "0.11.10",
@@ -62,7 +62,7 @@
62
62
  "react-icons": "4.3.1"
63
63
  },
64
64
  "devDependencies": {
65
- "@lowdefy/build": "4.0.0-alpha.34",
65
+ "@lowdefy/build": "4.0.0-alpha.36",
66
66
  "@next/eslint-plugin-next": "12.1.6",
67
67
  "less": "4.1.2",
68
68
  "less-loader": "11.0.0",
@@ -75,5 +75,5 @@
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  },
78
- "gitHead": "5e801532cef950b947c0069a5ba1a8f5ed6bb66f"
78
+ "gitHead": "d4b0fa0998d56ee812cb08d9676515cbac84a9cf"
79
79
  }
package/pages/404.js CHANGED
@@ -16,11 +16,18 @@
16
16
  import path from 'path';
17
17
  import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
18
18
 
19
+ import config from '../build/config.json';
20
+ import fileCache from '../lib/fileCache.js';
19
21
  import Page from '../lib/Page.js';
20
22
 
21
23
  export async function getStaticProps() {
22
24
  // Important to give absolute path so Next can trace build files
23
- const apiContext = await createApiContext({ buildDirectory: path.join(process.cwd(), 'build') });
25
+ const apiContext = createApiContext({
26
+ buildDirectory: path.join(process.cwd(), 'build'),
27
+ config,
28
+ fileCache,
29
+ logger: console,
30
+ });
24
31
 
25
32
  const [rootConfig, pageConfig] = await Promise.all([
26
33
  getRootConfig(apiContext),
package/pages/[pageId].js CHANGED
@@ -17,6 +17,8 @@
17
17
  import path from 'path';
18
18
  import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
19
19
 
20
+ import config from '../build/config.json';
21
+ import fileCache from '../lib/fileCache.js';
20
22
  import getServerSession from '../lib/auth/getServerSession.js';
21
23
  import Page from '../lib/Page.js';
22
24
 
@@ -24,8 +26,10 @@ export async function getServerSideProps(context) {
24
26
  const { pageId } = context.params;
25
27
  const session = await getServerSession(context);
26
28
  // Important to give absolute path so Next can trace build files
27
- const apiContext = await createApiContext({
29
+ const apiContext = createApiContext({
28
30
  buildDirectory: path.join(process.cwd(), 'build'),
31
+ config,
32
+ fileCache,
29
33
  logger: console,
30
34
  session,
31
35
  });
@@ -15,16 +15,22 @@
15
15
  */
16
16
 
17
17
  import NextAuth from 'next-auth';
18
- import { getNextAuthConfig } from '@lowdefy/api';
18
+ import { createApiContext, getNextAuthConfig } from '@lowdefy/api';
19
19
 
20
- import authJson from '../../../build/auth.json';
21
20
  import adapters from '../../../build/plugins/auth/adapters.js';
21
+ import authJson from '../../../build/auth.json';
22
22
  import callbacks from '../../../build/plugins/auth/callbacks.js';
23
+ import config from '../../../build/config.json';
23
24
  import events from '../../../build/plugins/auth/events.js';
25
+ import fileCache from '../../../lib/fileCache.js';
24
26
  import providers from '../../../build/plugins/auth/providers.js';
25
27
 
26
28
  export const authOptions = getNextAuthConfig(
27
- { logger: console }, // TODO: make createApiContext synchronous
29
+ createApiContext({
30
+ config,
31
+ fileCache,
32
+ logger: console,
33
+ }),
28
34
  { authJson, plugins: { adapters, callbacks, events, providers } }
29
35
  );
30
36
 
@@ -18,10 +18,11 @@ import path from 'path';
18
18
  import { callRequest, createApiContext } from '@lowdefy/api';
19
19
  import { getSecretsFromEnv } from '@lowdefy/node-utils';
20
20
 
21
- import getServerSession from '../../../../lib/auth/getServerSession.js';
22
-
21
+ import config from '../../../../build/config.json';
23
22
  import connections from '../../../../build/plugins/connections.js';
23
+ import getServerSession from '../../../../lib/auth/getServerSession.js';
24
24
  import operators from '../../../../build/plugins/operators/server.js';
25
+ import fileCache from '../../../../lib/fileCache.js';
25
26
 
26
27
  export default async function handler(req, res) {
27
28
  try {
@@ -30,9 +31,11 @@ export default async function handler(req, res) {
30
31
  }
31
32
  const session = await getServerSession({ req, res });
32
33
  // Important to give absolute path so Next can trace build files
33
- const apiContext = await createApiContext({
34
+ const apiContext = createApiContext({
34
35
  buildDirectory: path.join(process.cwd(), 'build'),
36
+ config,
35
37
  connections,
38
+ fileCache,
36
39
  // logger: console,
37
40
  logger: { debug: () => {} },
38
41
  operators,
package/pages/index.js CHANGED
@@ -17,6 +17,8 @@
17
17
  import path from 'path';
18
18
  import { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
19
19
 
20
+ import config from '../build/config.json';
21
+ import fileCache from '../lib/fileCache.js';
20
22
  import getServerSession from '../lib/auth/getServerSession.js';
21
23
  import Page from '../lib/Page.js';
22
24
 
@@ -24,8 +26,10 @@ export async function getServerSideProps(context) {
24
26
  const session = await getServerSession(context);
25
27
 
26
28
  // Important to give absolute path so Next can trace build files
27
- const apiContext = await createApiContext({
29
+ const apiContext = createApiContext({
28
30
  buildDirectory: path.join(process.cwd(), 'build'),
31
+ config,
32
+ fileCache,
29
33
  logger: console,
30
34
  session,
31
35
  });