@lowdefy/server 3.23.2 → 4.0.0-alpha.10

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 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,50 @@
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
+
24
+ import actions from '../build/plugins/actions.js';
25
+ import blocks from '../build/plugins/blocks.js';
26
+ import icons from '../build/plugins/icons.js';
27
+ import operators from '../build/plugins/operatorsClient.js';
28
+
29
+ const Page = ({ pageConfig, rootConfig }) => {
30
+ const router = useRouter();
31
+ return (
32
+ <Client
33
+ Components={{ Head, Link }}
34
+ config={{
35
+ pageConfig,
36
+ rootConfig,
37
+ }}
38
+ router={router}
39
+ types={{
40
+ actions,
41
+ blocks,
42
+ icons,
43
+ operators,
44
+ }}
45
+ window={window}
46
+ />
47
+ );
48
+ };
49
+
50
+ 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,66 @@
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
+ blocks: {},
37
+ connections: {},
38
+ icons: {},
39
+ operators: {
40
+ client: {},
41
+ server: {},
42
+ },
43
+ requests: {},
44
+ styles: {
45
+ packages: {},
46
+ blocks: {},
47
+ },
48
+ };
49
+
50
+ const pluginDefinitions = await getPluginDefinitions({ directories });
51
+
52
+ for (const plugin of pluginDefinitions) {
53
+ const { default: types } = await import(`${plugin.name}/types`);
54
+ createPluginTypesMap({
55
+ packageTypes: types,
56
+ typesMap: customTypesMap,
57
+ packageName: plugin.name,
58
+ version: plugin.version,
59
+ typePrefix: plugin.typePrefix,
60
+ });
61
+ }
62
+
63
+ return customTypesMap;
64
+ }
65
+
66
+ 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": "3.23.2",
3
+ "version": "4.0.0-alpha.10",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -25,39 +25,51 @@
25
25
  "type": "git",
26
26
  "url": "https://github.com/lowdefy/lowdefy.git"
27
27
  },
28
- "main": "dist/index.js",
29
28
  "files": [
30
- "dist/*"
29
+ "lib/*",
30
+ "lowdefy/*",
31
+ "pages/*",
32
+ "public/*",
33
+ "next.config.js",
34
+ ".eslintrc.yaml"
31
35
  ],
32
36
  "scripts": {
33
- "babel": "babel src --out-dir dist",
34
- "build": "rm -rf dist && babel src --out-dir dist",
35
- "clean": "rm -rf dist && rm -rf .lowdefy",
36
- "prepare": "yarn build",
37
- "start": "nodemon dist/server.js"
37
+ "build:lowdefy": "node lowdefy/build.mjs",
38
+ "build:next": "next build",
39
+ "dev": "next dev",
40
+ "start": "next start",
41
+ "lint": "next lint",
42
+ "next": "next"
38
43
  },
39
44
  "dependencies": {
40
- "@lowdefy/graphql": "3.23.2",
41
- "@lowdefy/helpers": "3.23.2",
42
- "@lowdefy/node-utils": "3.23.2",
43
- "apollo-server-express": "2.25.0",
44
- "dotenv": "10.0.0",
45
- "express": "4.17.1",
46
- "graphql": "15.5.0"
45
+ "@lowdefy/actions-core": "4.0.0-alpha.10",
46
+ "@lowdefy/api": "4.0.0-alpha.10",
47
+ "@lowdefy/blocks-antd": "4.0.0-alpha.10",
48
+ "@lowdefy/blocks-basic": "4.0.0-alpha.10",
49
+ "@lowdefy/blocks-loaders": "4.0.0-alpha.10",
50
+ "@lowdefy/client": "4.0.0-alpha.10",
51
+ "@lowdefy/helpers": "4.0.0-alpha.10",
52
+ "@lowdefy/layout": "4.0.0-alpha.10",
53
+ "@lowdefy/node-utils": "4.0.0-alpha.10",
54
+ "@lowdefy/operators-js": "4.0.0-alpha.10",
55
+ "next": "12.0.10",
56
+ "next-auth": "4.1.2",
57
+ "process": "0.11.10",
58
+ "react": "17.0.2",
59
+ "react-dom": "17.0.2",
60
+ "react-icons": "4.3.1"
47
61
  },
48
62
  "devDependencies": {
49
- "@babel/cli": "7.14.3",
50
- "@babel/core": "7.14.3",
51
- "@babel/preset-env": "7.14.4",
52
- "@babel/preset-react": "7.13.13",
53
- "@lowdefy/block-tools": "3.23.2",
54
- "babel-jest": "26.6.3",
55
- "babel-loader": "8.2.2",
56
- "jest": "26.6.3",
57
- "nodemon": "2.0.7"
63
+ "@lowdefy/build": "4.0.0-alpha.10",
64
+ "@next/eslint-plugin-next": "12.0.10",
65
+ "less": "4.1.2",
66
+ "less-loader": "10.2.0",
67
+ "next-with-less": "2.0.4",
68
+ "yaml": "1.10.2",
69
+ "yargs": "17.3.1"
58
70
  },
59
71
  "publishConfig": {
60
72
  "access": "public"
61
73
  },
62
- "gitHead": "4c30d3cdfa99ae4e90fc891825938c28bad45760"
74
+ "gitHead": "d697b4b5f354697d9481a371b90a00ca0944f486"
63
75
  }
package/pages/404.js ADDED
@@ -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 { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
18
+
19
+ import Page from '../lib/Page.js';
20
+
21
+ export async function getStaticProps() {
22
+ // TODO: get the right api context options
23
+ const apiContext = await createApiContext({ buildDirectory: './build' });
24
+
25
+ const [rootConfig, pageConfig] = await Promise.all([
26
+ getRootConfig(apiContext),
27
+ getPageConfig(apiContext, { pageId: '404' }),
28
+ ]);
29
+
30
+ return {
31
+ props: {
32
+ pageConfig,
33
+ rootConfig,
34
+ },
35
+ };
36
+ }
37
+
38
+ export default Page;
@@ -0,0 +1,48 @@
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 { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
18
+
19
+ import Page from '../lib/Page.js';
20
+
21
+ export async function getServerSideProps(context) {
22
+ const { pageId } = context.params;
23
+ // TODO: get the right api context options
24
+ const apiContext = await createApiContext({ buildDirectory: './build' });
25
+
26
+ const [rootConfig, pageConfig] = await Promise.all([
27
+ getRootConfig(apiContext),
28
+ getPageConfig(apiContext, { pageId }),
29
+ ]);
30
+
31
+ if (!pageConfig) {
32
+ return {
33
+ redirect: {
34
+ destination: '/404',
35
+ permanent: false,
36
+ },
37
+ };
38
+ }
39
+
40
+ return {
41
+ props: {
42
+ pageConfig,
43
+ rootConfig,
44
+ },
45
+ };
46
+ }
47
+
48
+ export default Page;
package/pages/_app.js ADDED
@@ -0,0 +1,31 @@
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 dynamic from 'next/dynamic';
19
+
20
+ // Must be in _app due to next specifications.
21
+ import '../build/plugins/styles.less';
22
+
23
+ function App({ Component, pageProps }) {
24
+ return <Component {...pageProps} />;
25
+ }
26
+
27
+ const DynamicApp = dynamic(() => Promise.resolve(App), {
28
+ ssr: false,
29
+ });
30
+
31
+ 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;
@@ -0,0 +1,28 @@
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 NextAuth from 'next-auth';
18
+ import Auth0Provider from 'next-auth/providers/auth0';
19
+
20
+ export default NextAuth({
21
+ providers: [
22
+ Auth0Provider({
23
+ clientId: process.env.AUTH0_CLIENT_ID,
24
+ clientSecret: process.env.AUTH0_CLIENT_SECRET,
25
+ issuer: process.env.AUTH0_ISSUER,
26
+ }),
27
+ ],
28
+ });
@@ -0,0 +1,44 @@
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 { callRequest, createApiContext } from '@lowdefy/api';
18
+ import { getSecretsFromEnv } from '@lowdefy/node-utils';
19
+ import connections from '../../../../build/plugins/connections.js';
20
+ import operators from '../../../../build/plugins/operatorsServer.js';
21
+
22
+ export default async function handler(req, res) {
23
+ try {
24
+ if (req.method !== 'POST') {
25
+ throw new Error('Only POST requests are supported.');
26
+ }
27
+ // TODO: configure API context
28
+ const apiContext = await createApiContext({
29
+ buildDirectory: './build',
30
+ connections,
31
+ // TODO: use a logger like pino
32
+ logger: console,
33
+ operators,
34
+ secrets: getSecretsFromEnv(),
35
+ });
36
+ const { pageId, requestId } = req.query;
37
+ const { payload } = req.body;
38
+
39
+ const response = await callRequest(apiContext, { pageId, payload, requestId });
40
+ res.status(200).json(response);
41
+ } catch (error) {
42
+ res.status(500).json({ name: error.name, message: error.message });
43
+ }
44
+ }
package/pages/index.js ADDED
@@ -0,0 +1,51 @@
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 { createApiContext, getPageConfig, getRootConfig } from '@lowdefy/api';
18
+
19
+ import Page from '../lib/Page.js';
20
+
21
+ export async function getServerSideProps() {
22
+ // TODO: is this build directory configurable from the cli?
23
+ const apiContext = await createApiContext({ buildDirectory: './build' });
24
+ const rootConfig = await getRootConfig(apiContext);
25
+ const { home } = rootConfig;
26
+ if (home.configured === false) {
27
+ return {
28
+ redirect: {
29
+ destination: `/${home.pageId}`,
30
+ permanent: false,
31
+ },
32
+ };
33
+ }
34
+ const pageConfig = await getPageConfig(apiContext, { pageId: home.pageId });
35
+ if (!pageConfig) {
36
+ return {
37
+ redirect: {
38
+ destination: '/404',
39
+ permanent: false,
40
+ },
41
+ };
42
+ }
43
+ return {
44
+ props: {
45
+ pageConfig,
46
+ rootConfig,
47
+ },
48
+ };
49
+ }
50
+
51
+ export default Page;
Binary file
Binary file
Binary file
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg width="100%" height="100%" viewBox="0 0 94 94" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
4
+ <g transform="matrix(1,0,0,1,-979.672,-59.6924)">
5
+ <g transform="matrix(1,0,0,1.03297,-38.3284,-294.615)">
6
+ <g transform="matrix(1,0,0,1,952,232)">
7
+ <path d="M160,129.634C160,119.35 151.375,111 140.751,111L85.249,111C74.625,111 66,119.35 66,129.634L66,183.366C66,193.65 74.625,202 85.249,202L140.751,202C151.375,202 160,193.65 160,183.366L160,129.634Z"/>
8
+ </g>
9
+ <g transform="matrix(0.872141,0,0,1,1002.6,346)">
10
+ <rect x="36" y="12" width="36" height="59" style="fill:white;"/>
11
+ </g>
12
+ <g transform="matrix(0.78125,0,0,0.862069,1010.84,356.663)">
13
+ <rect x="77" y="41" width="32" height="29" style="fill:rgb(24,144,255);"/>
14
+ </g>
15
+ </g>
16
+ </g>
17
+ </svg>
Binary file
Binary file
@@ -0,0 +1,16 @@
1
+ {
2
+ "short_name": "Lowdefy App",
3
+ "name": "Lowdefy App",
4
+ "description": "Lowdefy App",
5
+ "icons": [
6
+ {
7
+ "src": "/public/icon-512.png",
8
+ "type": "image/png",
9
+ "sizes": "512x512"
10
+ }
11
+ ],
12
+ "start_url": "/",
13
+ "background_color": "#FFFFFF",
14
+ "display": "browser",
15
+ "scope": "/"
16
+ }
package/dist/index.js DELETED
@@ -1,106 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _path = _interopRequireDefault(require("path"));
9
-
10
- var _express = _interopRequireDefault(require("express"));
11
-
12
- var _apolloServerExpress = require("apollo-server-express");
13
-
14
- var _graphql = require("@lowdefy/graphql");
15
-
16
- var _helpers = require("@lowdefy/helpers");
17
-
18
- var _nodeUtils = require("@lowdefy/node-utils");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
23
-
24
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
25
-
26
- function getServer(_ref) {
27
- var {
28
- buildDirectory,
29
- development = false,
30
- getSecrets,
31
- gqlExpressPath,
32
- gqlUri,
33
- logger,
34
- publicDirectory,
35
- serverBasePath = '',
36
- serveStaticFiles = true,
37
- shellDirectory
38
- } = _ref;
39
- var context = (0, _graphql.createContext)({
40
- CONFIGURATION_BASE_PATH: buildDirectory,
41
- development,
42
- getSecrets,
43
- gqlUri,
44
- logger
45
- });
46
- var gqlServer = new _apolloServerExpress.ApolloServer({
47
- typeDefs: _graphql.typeDefs,
48
- resolvers: _graphql.resolvers,
49
- context
50
- });
51
- var indexHtml = null;
52
-
53
- if (serverBasePath !== '') {
54
- serverBasePath = "/".concat(serverBasePath);
55
- }
56
-
57
- var serveIndex = /*#__PURE__*/function () {
58
- var _ref2 = _asyncToGenerator(function* (req, res) {
59
- // TODO: can do better here?
60
- if (!indexHtml || development) {
61
- indexHtml = yield (0, _nodeUtils.readFile)(_path.default.resolve(shellDirectory, 'index.html'));
62
- var appConfig = yield (0, _nodeUtils.readFile)(_path.default.resolve(buildDirectory, 'app.json'));
63
- appConfig = JSON.parse(appConfig);
64
- indexHtml = indexHtml.replace('<!-- __LOWDEFY_APP_HEAD_HTML__ -->', (0, _helpers.get)(appConfig, 'html.appendHead', {
65
- default: ''
66
- }));
67
- indexHtml = indexHtml.replace('<!-- __LOWDEFY_APP_BODY_HTML__ -->', (0, _helpers.get)(appConfig, 'html.appendBody', {
68
- default: ''
69
- }));
70
- indexHtml = indexHtml.replace(/__LOWDEFY_SERVER_BASE_PATH__/g, serverBasePath);
71
- }
72
-
73
- res.send(indexHtml);
74
- });
75
-
76
- return function serveIndex(_x, _x2) {
77
- return _ref2.apply(this, arguments);
78
- };
79
- }();
80
-
81
- var server = (0, _express.default)();
82
- gqlServer.applyMiddleware({
83
- app: server,
84
- path: gqlExpressPath || "".concat(serverBasePath, "/api/graphql"),
85
- bodyParserConfig: {
86
- limit: '5mb'
87
- }
88
- });
89
-
90
- if (serveStaticFiles) {
91
- // serve index.html with appended html
92
- // else static server serves without appended html
93
- server.get("".concat(serverBasePath, "/"), serveIndex);
94
- server.use("".concat(serverBasePath, "/shell"), _express.default.static(_path.default.resolve(shellDirectory))); // serve public files
95
-
96
- server.use("".concat(serverBasePath, "/public"), _express.default.static(_path.default.resolve(publicDirectory))); // Redirect all 404 to index.html with status 200
97
- // This should always be the last route
98
-
99
- server.use("".concat(serverBasePath, "/*"), serveIndex);
100
- }
101
-
102
- return server;
103
- }
104
-
105
- var _default = getServer;
106
- exports.default = _default;