@budibase/worker 3.10.5 → 3.10.7

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/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM node:20-alpine
1
+ FROM node:22-alpine
2
2
 
3
3
  LABEL com.centurylinklabs.watchtower.lifecycle.pre-check="scripts/watchtower-hooks/pre-check.sh"
4
4
  LABEL com.centurylinklabs.watchtower.lifecycle.pre-update="scripts/watchtower-hooks/pre-update.sh"
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.5",
4
+ "version": "3.10.7",
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": "1f720b605f4e22676836dbec26918f7e94ce2434"
124
+ "gitHead": "777805a3ff93c87bad59cb8605e5430e67c91d90"
125
125
  }
@@ -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 new redis.Client(
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.getClient() }),
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
+ }