@budibase/server 2.4.44-alpha.5 → 2.4.44-alpha.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.4.44-alpha.5",
4
+ "version": "2.4.44-alpha.7",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -44,12 +44,12 @@
44
44
  "license": "GPL-3.0",
45
45
  "dependencies": {
46
46
  "@apidevtools/swagger-parser": "10.0.3",
47
- "@budibase/backend-core": "2.4.44-alpha.5",
48
- "@budibase/client": "2.4.44-alpha.5",
49
- "@budibase/pro": "2.4.44-alpha.4",
50
- "@budibase/shared-core": "2.4.44-alpha.5",
51
- "@budibase/string-templates": "2.4.44-alpha.5",
52
- "@budibase/types": "2.4.44-alpha.5",
47
+ "@budibase/backend-core": "2.4.44-alpha.7",
48
+ "@budibase/client": "2.4.44-alpha.7",
49
+ "@budibase/pro": "2.4.44-alpha.6",
50
+ "@budibase/shared-core": "2.4.44-alpha.7",
51
+ "@budibase/string-templates": "2.4.44-alpha.7",
52
+ "@budibase/types": "2.4.44-alpha.7",
53
53
  "@bull-board/api": "3.7.0",
54
54
  "@bull-board/koa": "3.9.4",
55
55
  "@elastic/elasticsearch": "7.10.0",
@@ -85,7 +85,6 @@
85
85
  "koa-body": "4.2.0",
86
86
  "koa-compress": "4.0.1",
87
87
  "koa-connect": "2.1.0",
88
- "koa-pino-logger": "3.0.0",
89
88
  "koa-send": "5.0.0",
90
89
  "koa-session": "5.12.0",
91
90
  "koa-static": "5.0.0",
@@ -99,7 +98,6 @@
99
98
  "node-fetch": "2.6.7",
100
99
  "open": "8.4.0",
101
100
  "pg": "8.5.1",
102
- "pino-pretty": "5.1.3",
103
101
  "posthog-node": "1.3.0",
104
102
  "pouchdb": "7.3.0",
105
103
  "pouchdb-adapter-memory": "7.2.2",
@@ -176,5 +174,5 @@
176
174
  "optionalDependencies": {
177
175
  "oracledb": "5.3.0"
178
176
  },
179
- "gitHead": "68a3f6f075c9fbea115278fdae880ce095deee71"
177
+ "gitHead": "a43e7fab7056a6be54f056b0c7aca083ce490b52"
180
178
  }
@@ -45,6 +45,7 @@ async function init() {
45
45
  BB_ADMIN_USER_PASSWORD: "",
46
46
  PLUGINS_DIR: "",
47
47
  TENANT_FEATURE_FLAGS: "*:LICENSING,*:USER_GROUPS,*:ONBOARDING_TOUR",
48
+ HTTP_LOGGING: 0,
48
49
  }
49
50
  let envFile = ""
50
51
  Object.keys(envFileJson).forEach(key => {
@@ -0,0 +1,32 @@
1
+ import { Ctx } from "@budibase/types"
2
+ import { logging } from "@budibase/backend-core"
3
+
4
+ interface LogRequest {
5
+ message: string
6
+ data?: any
7
+ }
8
+
9
+ interface ErrorRequest {
10
+ message: string
11
+ }
12
+
13
+ export async function log(ctx: Ctx<LogRequest>) {
14
+ const body = ctx.request.body
15
+ console.trace(body.message, body.data)
16
+ console.debug(body.message, body.data)
17
+ console.info(body.message, body.data)
18
+ console.warn(body.message, body.data)
19
+ console.error(body.message, body.data)
20
+ ctx.status = 204
21
+ }
22
+
23
+ export async function alert(ctx: Ctx<ErrorRequest>) {
24
+ const body = ctx.request.body
25
+ logging.logAlert(body.message, new Error(body.message))
26
+ ctx.status = 204
27
+ }
28
+
29
+ export async function error(ctx: Ctx<ErrorRequest>) {
30
+ const body = ctx.request.body
31
+ throw new Error(body.message)
32
+ }
@@ -25,6 +25,7 @@ import devRoutes from "./dev"
25
25
  import cloudRoutes from "./cloud"
26
26
  import migrationRoutes from "./migrations"
27
27
  import pluginRoutes from "./plugin"
28
+ import opsRoutes from "./ops"
28
29
  import Router from "@koa/router"
29
30
  import { api as pro } from "@budibase/pro"
30
31
 
@@ -63,6 +64,7 @@ export const mainRoutes: Router[] = [
63
64
  rowRoutes,
64
65
  migrationRoutes,
65
66
  pluginRoutes,
67
+ opsRoutes,
66
68
  scheduleRoutes,
67
69
  environmentVariableRoutes,
68
70
  // these need to be handled last as they still use /api/:tableId
@@ -0,0 +1,30 @@
1
+ import Router from "@koa/router"
2
+ import * as controller from "../controllers/ops"
3
+ import { middleware } from "@budibase/backend-core"
4
+ import Joi from "joi"
5
+
6
+ export function logsValidator() {
7
+ return middleware.joiValidator.body(
8
+ Joi.object({
9
+ message: Joi.string().required(),
10
+ data: Joi.object(),
11
+ })
12
+ )
13
+ }
14
+
15
+ export function errorValidator() {
16
+ return middleware.joiValidator.body(
17
+ Joi.object({
18
+ message: Joi.string().required(),
19
+ })
20
+ )
21
+ }
22
+
23
+ const router: Router = new Router()
24
+
25
+ router
26
+ .post("/api/ops/log", logsValidator(), controller.log)
27
+ .post("/api/ops/error", errorValidator(), controller.error)
28
+ .post("/api/ops/alert", errorValidator(), controller.alert)
29
+
30
+ export default router
package/src/app.ts CHANGED
@@ -2,21 +2,9 @@ if (process.env.DD_APM_ENABLED) {
2
2
  require("./ddApm")
3
3
  }
4
4
 
5
- if (process.env.ELASTIC_APM_ENABLED) {
6
- require("./elasticApm")
7
- }
8
-
9
5
  // need to load environment first
10
6
  import env from "./environment"
11
7
 
12
- // enable APM if configured
13
- if (process.env.ELASTIC_APM_ENABLED) {
14
- const apm = require("elastic-apm-node").start({
15
- serviceName: process.env.SERVICE,
16
- environment: process.env.BUDIBASE_ENVIRONMENT,
17
- })
18
- }
19
-
20
8
  import { ExtendableContext } from "koa"
21
9
  import * as db from "./db"
22
10
  db.init()
@@ -53,7 +41,8 @@ app.use(
53
41
  })
54
42
  )
55
43
 
56
- app.use(middleware.logging)
44
+ app.use(middleware.correlation)
45
+ app.use(middleware.pino)
57
46
  app.use(userAgent)
58
47
 
59
48
  if (env.isProd()) {
@@ -62,7 +62,6 @@ const environment = {
62
62
  // minor
63
63
  SALT_ROUNDS: process.env.SALT_ROUNDS,
64
64
  LOGGER: process.env.LOGGER,
65
- LOG_LEVEL: process.env.LOG_LEVEL,
66
65
  ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL,
67
66
  AUTOMATION_MAX_ITERATIONS:
68
67
  parseIntSafe(process.env.AUTOMATION_MAX_ITERATIONS) || 200,
@@ -9,6 +9,6 @@ export const run = async () => {
9
9
 
10
10
  // sync app count
11
11
  const tenantId = tenancy.getTenantId()
12
- console.log(`[Tenant: ${tenantId}] Syncing app count: ${appCount}`)
12
+ console.log(`Syncing app count: ${appCount}`)
13
13
  await quotas.setUsage(appCount, StaticQuotaName.APPS, QuotaUsageType.STATIC)
14
14
  }
@@ -1,4 +1,4 @@
1
- import { tenancy, db as dbCore } from "@budibase/backend-core"
1
+ import { db as dbCore } from "@budibase/backend-core"
2
2
  import { getUniqueRows } from "../../../utilities/usageQuota/rows"
3
3
  import { quotas } from "@budibase/pro"
4
4
  import { StaticQuotaName, QuotaUsageType, App } from "@budibase/types"
@@ -18,8 +18,7 @@ export const run = async () => {
18
18
  })
19
19
 
20
20
  // sync row count
21
- const tenantId = tenancy.getTenantId()
22
- console.log(`[Tenant: ${tenantId}] Syncing row count: ${rowCount}`)
21
+ console.log(`Syncing row count: ${rowCount}`)
23
22
  await quotas.setUsagePerApp(
24
23
  counts,
25
24
  StaticQuotaName.ROWS,
package/src/startup.ts CHANGED
@@ -16,13 +16,10 @@ import * as bullboard from "./automations/bullboard"
16
16
  import * as pro from "@budibase/pro"
17
17
  import * as api from "./api"
18
18
  import sdk from "./sdk"
19
- const pino = require("koa-pino-logger")
20
19
 
21
20
  let STARTUP_RAN = false
22
21
 
23
22
  async function initRoutes(app: any) {
24
- app.use(pino(logging.pinoSettings()))
25
-
26
23
  if (!env.isTest()) {
27
24
  const plugin = await bullboard.init()
28
25
  app.use(plugin)
@@ -6,7 +6,6 @@ process.env.MULTI_TENANCY = "1"
6
6
  // @ts-ignore
7
7
  process.env.BUDIBASE_DIR = tmpdir("budibase-unittests")
8
8
  process.env.LOG_LEVEL = process.env.LOG_LEVEL || "error"
9
- process.env.ENABLE_4XX_HTTP_LOGGING = "0"
10
9
  process.env.MOCK_REDIS = "1"
11
10
  process.env.PLATFORM_URL = "http://localhost:10000"
12
11
  process.env.REDIS_PASSWORD = "budibase"
@@ -1,4 +1,3 @@
1
- import "./logging"
2
1
  import env from "../environment"
3
2
  import { env as coreEnv, timers } from "@budibase/backend-core"
4
3
  import { testContainerUtils } from "@budibase/backend-core/tests"
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const elastic_apm_node_1 = __importDefault(require("elastic-apm-node"));
7
- // enable APM if configured
8
- if (process.env.ELASTIC_APM_ENABLED) {
9
- console.log("Starting elastic-apm-node");
10
- elastic_apm_node_1.default.start({
11
- serviceName: process.env.SERVICE,
12
- environment: process.env.BUDIBASE_ENVIRONMENT,
13
- });
14
- }
package/src/elasticApm.ts DELETED
@@ -1,10 +0,0 @@
1
- import apm from "elastic-apm-node"
2
-
3
- // enable APM if configured
4
- if (process.env.ELASTIC_APM_ENABLED) {
5
- console.log("Starting elastic-apm-node")
6
- apm.start({
7
- serviceName: process.env.SERVICE,
8
- environment: process.env.BUDIBASE_ENVIRONMENT,
9
- })
10
- }
@@ -1,34 +0,0 @@
1
- export enum LogLevel {
2
- TRACE = "trace",
3
- DEBUG = "debug",
4
- INFO = "info",
5
- WARN = "warn",
6
- ERROR = "error",
7
- }
8
-
9
- const LOG_INDEX: { [key in LogLevel]: number } = {
10
- [LogLevel.TRACE]: 1,
11
- [LogLevel.DEBUG]: 2,
12
- [LogLevel.INFO]: 3,
13
- [LogLevel.WARN]: 4,
14
- [LogLevel.ERROR]: 5,
15
- }
16
-
17
- const setIndex = LOG_INDEX[process.env.LOG_LEVEL as LogLevel]
18
-
19
- if (setIndex > LOG_INDEX.trace) {
20
- global.console.trace = jest.fn()
21
- }
22
-
23
- if (setIndex > LOG_INDEX.debug) {
24
- global.console.debug = jest.fn()
25
- }
26
-
27
- if (setIndex > LOG_INDEX.info) {
28
- global.console.info = jest.fn()
29
- global.console.log = jest.fn()
30
- }
31
-
32
- if (setIndex > LOG_INDEX.warn) {
33
- global.console.warn = jest.fn()
34
- }