From 397ff9735c78083bbfb230466f3fb43ea8c7c087 Mon Sep 17 00:00:00 2001 From: Joel Chen Date: Tue, 21 Jul 2020 12:36:51 -0700 Subject: [PATCH] update create app template deps --- packages/xarc-create-app/template/_package.js | 12 +++--- .../template/src/server/config.js | 39 +++++++++++++++++++ .../template/src/server/index.js | 21 +--------- 3 files changed, 46 insertions(+), 26 deletions(-) create mode 100644 packages/xarc-create-app/template/src/server/config.js diff --git a/packages/xarc-create-app/template/_package.js b/packages/xarc-create-app/template/_package.js index 94963d8cd..f88ff9eef 100644 --- a/packages/xarc-create-app/template/_package.js +++ b/packages/xarc-create-app/template/_package.js @@ -30,18 +30,18 @@ module.exports = (base, merge) => { npm: ">= 6" }, dependencies: { - "@xarc/app": "^8.1.6", - "@xarc/fastify-server": "^1.1.0", + "@xarc/app": "^8.1.7", + "@xarc/fastify-server": "^2.0.0", + react: "^16.13.1", "react-dom": "^16.13.1", + redux: "^4.0.5", "react-redux": "^7.2.0", "subapp-react": "^0.0.21", "subapp-redux": "^1.0.30", - "subapp-server": "^1.2.4", - react: "^16.13.1", - redux: "^4.0.5" + "subapp-server": "^1.2.4" }, devDependencies: { - "@xarc/app-dev": "^8.1.6" + "@xarc/app-dev": "^8.1.7" } }; diff --git a/packages/xarc-create-app/template/src/server/config.js b/packages/xarc-create-app/template/src/server/config.js new file mode 100644 index 000000000..65f3b8f9d --- /dev/null +++ b/packages/xarc-create-app/template/src/server/config.js @@ -0,0 +1,39 @@ +"use strict"; + +/** + * A simple configuration to setup fastify to serve routes for the + * Electrode X webapp. + * + * To support config composition base on environment, checkout these: + * + * 1. https://www.npmjs.com/package/electrode-confippet + * 2. https://www.npmjs.com/package/config + * + */ +exports.config = { + connection: { + host: process.env.HOST || "localhost", + // Allow Electrode X to control app's listening port during dev + // to serve both static assets and app under a unified proxy port + port: parseInt(process.env.APP_SERVER_PORT || process.env.PORT || "3000") + }, + plugins: { + /** + * Register the dev support plugin + */ + "@xarc/app-dev": { + priority: -1, + enable: process.env.WEBPACK_DEV === "true" + }, + /** + * Register the server routes plugin for the app + */ + "subapp-server": { + options: { + cdn: { + enable: process.env.NODE_ENV === "production" + } + } + } + } +}; diff --git a/packages/xarc-create-app/template/src/server/index.js b/packages/xarc-create-app/template/src/server/index.js index f51bf60e3..a597e6de8 100644 --- a/packages/xarc-create-app/template/src/server/index.js +++ b/packages/xarc-create-app/template/src/server/index.js @@ -2,26 +2,7 @@ const support = require("@xarc/app/support"); const electrodeServer = require("@xarc/fastify-server"); - -const config = { - connection: { - host: process.env.HOST || "localhost", - port: parseInt(process.env.APP_SERVER_PORT || process.env.PORT || "3000") - }, - plugins: { - "@xarc/app-dev": { - priority: -1, - enable: process.env.WEBPACK_DEV === "true" - }, - "subapp-server": { - options: { - cdn: { - enable: process.env.NODE_ENV === "production" - } - } - } - } -}; +const { config } = require("./config"); async function start() { await support.load();