@budibase/worker 3.10.4 → 3.10.6
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/package.json +2 -2
- package/src/environment.ts +1 -0
- package/src/index.ts +2 -4
- package/src/utilities/apps.ts +31 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "3.10.
|
|
4
|
+
"version": "3.10.6",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -121,5 +121,5 @@
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
|
-
"gitHead": "
|
|
124
|
+
"gitHead": "f1e8fdc36892d9bfedeea3c5148433c4bfcc6bdf"
|
|
125
125
|
}
|
package/src/environment.ts
CHANGED
|
@@ -28,6 +28,7 @@ const environment = {
|
|
|
28
28
|
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
|
|
29
29
|
COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
|
|
30
30
|
PASSWORD_MIN_LENGTH: process.env.PASSWORD_MIN_LENGTH,
|
|
31
|
+
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
|
|
31
32
|
// urls
|
|
32
33
|
MINIO_URL: process.env.MINIO_URL,
|
|
33
34
|
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
package/src/index.ts
CHANGED
|
@@ -54,13 +54,11 @@ app.use(handleScimBody)
|
|
|
54
54
|
app.use(koaBody({ multipart: true }))
|
|
55
55
|
|
|
56
56
|
const sessionMiddleware: Middleware = async (ctx: any, next: any) => {
|
|
57
|
-
const redisClient = await
|
|
58
|
-
redis.utils.Databases.SESSIONS
|
|
59
|
-
).init()
|
|
57
|
+
const redisClient = await redis.clients.getSessionClient()
|
|
60
58
|
return koaSession(
|
|
61
59
|
{
|
|
62
60
|
// @ts-ignore
|
|
63
|
-
store: new RedisStore({ client: redisClient.
|
|
61
|
+
store: new RedisStore({ client: redisClient.client }),
|
|
64
62
|
key: "koa:sess",
|
|
65
63
|
maxAge: 86400000, // one day
|
|
66
64
|
},
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import fetch from "node-fetch"
|
|
2
|
+
import { constants } from "@budibase/backend-core"
|
|
3
|
+
import env from "../environment"
|
|
4
|
+
import { checkSlashesInUrl } from "./"
|
|
5
|
+
|
|
6
|
+
export async function triggerAutomation(
|
|
7
|
+
appId: string,
|
|
8
|
+
automationId: string,
|
|
9
|
+
parameters: Record<string, any>
|
|
10
|
+
) {
|
|
11
|
+
if (!env.INTERNAL_API_KEY) {
|
|
12
|
+
throw new Error("No API key, cannot trigger automation")
|
|
13
|
+
}
|
|
14
|
+
const url = checkSlashesInUrl(
|
|
15
|
+
`${env.APPS_URL}/api/automations/${automationId}/trigger`
|
|
16
|
+
)
|
|
17
|
+
const res = await fetch(url, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
body: JSON.stringify(parameters),
|
|
20
|
+
headers: {
|
|
21
|
+
[constants.Header.APP_ID]: appId,
|
|
22
|
+
[constants.Header.API_KEY]: env.INTERNAL_API_KEY,
|
|
23
|
+
["Content-Type"]: "application/json",
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
if (res.status >= 300) {
|
|
27
|
+
throw new Error(await res.text())
|
|
28
|
+
} else {
|
|
29
|
+
return res.json()
|
|
30
|
+
}
|
|
31
|
+
}
|