Browse Source

tidy up

pull/1429/head
Martin McKeaveney 5 years ago
parent
commit
da25d8b6e5
  1. 3
      package.json
  2. 1
      packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte
  3. 2
      packages/server/scripts/dev/manage.js
  4. 5
      packages/server/src/api/controllers/script.js
  5. 4
      packages/server/src/api/routes/admin.js
  6. 6
      packages/server/src/api/routes/script.js
  7. 1
      packages/server/src/automations/steps/executeQuery.js
  8. 8
      packages/server/src/automations/steps/executeScript.js
  9. 1
      packages/server/src/automations/triggers.js

3
package.json

@ -38,6 +38,5 @@
"test:e2e:ci": "lerna run cy:ci",
"build:docker": "cd hosting/scripts/linux/ && ./release-to-docker-hub.sh && cd -",
"build:docker:staging": "cd hosting/scripts/linux/ && ./release-to-docker-hub.sh staging && cd -"
},
"dependencies": {}
}
}

1
packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte

@ -91,6 +91,7 @@
{:else if value.customType === 'code'}
<CodeEditorModal>
<pre>{JSON.stringify(bindings, null, 2)}</pre>
<Label small grey>Note: The result of the very last statement of this script will be returned and available as the "value" property in following automation blocks.</Label>
<Editor
mode="javascript"
on:change={e => {

2
packages/server/scripts/dev/manage.js

@ -37,7 +37,7 @@ async function init() {
PORT: 4001,
MINIO_URL: "http://localhost:10000/",
COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/",
// REDIS_URL: "http://localhost:10000/cache/",
REDIS_URL: "http://localhost:10000/cache/",
WORKER_URL: "http://localhost:4002",
JWT_SECRET: "testsecret",
MINIO_ACCESS_KEY: "budibase",

5
packages/server/src/api/controllers/script.js

@ -9,8 +9,8 @@ class ScriptExecutor {
}
execute() {
this.script.runInContext(this.context)
return this.context
const returnValue = this.script.runInContext(this.context)
return returnValue
}
}
@ -18,6 +18,5 @@ exports.execute = async function(ctx) {
const executor = new ScriptExecutor(ctx.request.body)
const result = executor.execute()
ctx.body = result
}

4
packages/server/src/api/routes/admin.js

@ -1,4 +0,0 @@
const app = require("express")()
const { router } = require("bull-board")
app.use("/admin/queues", router)

6
packages/server/src/api/routes/script.js

@ -1,14 +1,10 @@
const Router = require("@koa/router")
const controller = require("../controllers/hosting")
const authorized = require("../../middleware/authorized")
const selfhost = require("../../middleware/selfhost")
const { BUILDER } = require("../../utilities/security/permissions")
const router = Router()
router
.post("/api/script", authorized(BUILDER), controller.save)
// this isn't risky, doesn't return anything about apps other than names and URLs
.get("/api/hosting/apps", selfhost, controller.getDeployedApps)
router.post("/api/script", authorized(BUILDER), controller.save)
module.exports = router

1
packages/server/src/automations/steps/executeQuery.js

@ -53,7 +53,6 @@ module.exports.run = async function({ inputs, appId, emitter }) {
}
const { queryId, ...rest } = inputs.query
console.log(JSON.stringify(inputs.query))
const ctx = {
params: {

8
packages/server/src/automations/steps/executeScript.js

@ -2,7 +2,7 @@ const scriptController = require("../../api/controllers/script")
module.exports.definition = {
name: "Scripting",
tagline: "Execute code",
tagline: "Execute JavaScript Code",
icon: "ri-terminal-box-line",
description: "Run a piece of JavaScript code in your automation",
type: "ACTION",
@ -21,6 +21,11 @@ module.exports.definition = {
},
outputs: {
properties: {
value: {
type: "string",
description:
"The result of the last statement of the executed script.",
},
success: {
type: "boolean",
description: "Whether the action was successful",
@ -56,6 +61,7 @@ module.exports.run = async function({ inputs, appId, context, emitter }) {
await scriptController.execute(ctx)
return {
success: ctx.status === 200,
value: ctx.body,
}
} catch (err) {
console.error(err)

1
packages/server/src/automations/triggers.js

@ -1,6 +1,5 @@
const CouchDB = require("../db")
const emitter = require("../events/index")
// const InMemoryQueue = require("../utilities/queue/inMemoryQueue")
const Queue = require("bull")
const { setQueues, BullAdapter } = require("bull-board")
const { getAutomationParams } = require("../db/utils")

Loading…
Cancel
Save