diff --git a/packages/cli/src/cmd/editor/build.js b/packages/cli/src/cmd/editor/build.js index 1b540ec..f2bde6a 100644 --- a/packages/cli/src/cmd/editor/build.js +++ b/packages/cli/src/cmd/editor/build.js @@ -27,4 +27,7 @@ require('esbuild') }), ], }) + .then(() => { + console.log('imove editor builded'); + }) .catch(() => process.exit(1)); diff --git a/packages/cli/src/cmd/editor/index.js b/packages/cli/src/cmd/editor/index.js index e356e34..7275fc4 100644 --- a/packages/cli/src/cmd/editor/index.js +++ b/packages/cli/src/cmd/editor/index.js @@ -69,7 +69,7 @@ class Editor extends Base { } run() { - const server = createServer(8000); + const server = createServer(); server.use(express.static(path.join(__dirname, './template'))); server.post('/api/queryGraph', this.queryGraph.bind(this)); server.post('/api/modifyGraph', this.modifyGraph.bind(this)); diff --git a/packages/cli/src/utils/server/index.js b/packages/cli/src/utils/server/index.js index 3dec508..3cd7a1e 100644 --- a/packages/cli/src/utils/server/index.js +++ b/packages/cli/src/utils/server/index.js @@ -1,8 +1,15 @@ const express = require('express'); const bodyParser = require('body-parser'); +const cachedServer = {}; + const createServer = (port = 3500) => { + if (cachedServer[port]) { + return cachedServer[port]; + } const app = express(); + cachedServer[port] = app; + app.use(bodyParser.json({ limit: '50mb' })); app.use(bodyParser.urlencoded({ extended: false })); app.use((req, res, next) => {