@platformatic/runtime 2.21.1 → 2.22.0

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/config.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * and run json-schema-to-typescript to regenerate this file.
6
6
  */
7
7
 
8
- export type HttpsSchemasPlatformaticDevPlatformaticRuntime2211Json = {
8
+ export type HttpsSchemasPlatformaticDevPlatformaticRuntime2220Json = {
9
9
  [k: string]: unknown;
10
10
  } & {
11
11
  $schema?: string;
@@ -177,6 +177,9 @@ export type HttpsSchemasPlatformaticDevPlatformaticRuntime2211Json = {
177
177
  };
178
178
  serviceTimeout?: number | string;
179
179
  resolvedServicesBasePath?: string;
180
+ env?: {
181
+ [k: string]: string;
182
+ };
180
183
  };
181
184
 
182
185
  export interface UndiciInterceptor {
package/lib/schema.js CHANGED
@@ -6,6 +6,13 @@ const {
6
6
  schemaComponents: { server, logger, health }
7
7
  } = require('@platformatic/utils')
8
8
 
9
+ const env = {
10
+ type: 'object',
11
+ additionalProperties: {
12
+ type: 'string'
13
+ }
14
+ }
15
+
9
16
  const workers = {
10
17
  anyOf: [
11
18
  {
@@ -41,7 +48,11 @@ const services = {
41
48
  type: 'boolean'
42
49
  },
43
50
  workers,
44
- health: { ...health, default: undefined }
51
+ health: { ...health, default: undefined },
52
+ env,
53
+ envfile: {
54
+ type: 'string'
55
+ }
45
56
  }
46
57
  }
47
58
  }
@@ -316,7 +327,8 @@ const platformaticRuntimeSchema = {
316
327
  resolvedServicesBasePath: {
317
328
  type: 'string',
318
329
  default: 'external'
319
- }
330
+ },
331
+ env
320
332
  },
321
333
  anyOf: [{ required: ['autoload'] }, { required: ['services'] }, { required: ['web'] }],
322
334
  additionalProperties: false,
@@ -3,13 +3,14 @@
3
3
  const { EventEmitter } = require('node:events')
4
4
  const { createRequire } = require('node:module')
5
5
  const { hostname } = require('node:os')
6
- const { join } = require('node:path')
6
+ const { join, resolve } = require('node:path')
7
7
  const { parentPort, workerData, threadId } = require('node:worker_threads')
8
8
  const { pathToFileURL } = require('node:url')
9
9
  const inspector = require('node:inspector')
10
10
  const diagnosticChannel = require('node:diagnostics_channel')
11
11
  const { ServerResponse } = require('node:http')
12
12
 
13
+ const dotenv = require('dotenv')
13
14
  const pino = require('pino')
14
15
  const { fetch, setGlobalDispatcher, getGlobalDispatcher, Agent } = require('undici')
15
16
  const { wire } = require('undici-thread-interceptor')
@@ -81,6 +82,22 @@ async function main () {
81
82
 
82
83
  const service = workerData.serviceConfig
83
84
 
85
+ // Load env file and mixin env vars from service config
86
+ if (service.envfile) {
87
+ const envfile = resolve(workerData.dirname, service.envfile)
88
+ globalThis.platformatic.logger.info({ envfile }, 'Loading envfile...')
89
+
90
+ dotenv.config({
91
+ path: envfile
92
+ })
93
+ }
94
+ if (config.env) {
95
+ Object.assign(process.env, config.env)
96
+ }
97
+ if (service.env) {
98
+ Object.assign(process.env, service.env)
99
+ }
100
+
84
101
  // Setup undici
85
102
  const interceptors = {}
86
103
  const composedInterceptors = []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "2.21.1",
3
+ "version": "2.22.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -35,12 +35,12 @@
35
35
  "typescript": "^5.5.4",
36
36
  "undici-oidc-interceptor": "^0.5.0",
37
37
  "why-is-node-running": "^2.2.2",
38
- "@platformatic/composer": "2.21.1",
39
- "@platformatic/db": "2.21.1",
40
- "@platformatic/node": "2.21.1",
41
- "@platformatic/sql-graphql": "2.21.1",
42
- "@platformatic/service": "2.21.1",
43
- "@platformatic/sql-mapper": "2.21.1"
38
+ "@platformatic/composer": "2.22.0",
39
+ "@platformatic/db": "2.22.0",
40
+ "@platformatic/node": "2.22.0",
41
+ "@platformatic/service": "2.22.0",
42
+ "@platformatic/sql-mapper": "2.22.0",
43
+ "@platformatic/sql-graphql": "2.22.0"
44
44
  },
45
45
  "dependencies": {
46
46
  "@fastify/error": "^4.0.0",
@@ -55,6 +55,7 @@
55
55
  "commist": "^3.2.0",
56
56
  "debounce": "^2.0.0",
57
57
  "desm": "^1.3.1",
58
+ "dotenv": "^16.4.5",
58
59
  "dotenv-tool": "^0.1.1",
59
60
  "es-main": "^1.3.0",
60
61
  "fastest-levenshtein": "^1.0.16",
@@ -72,13 +73,13 @@
72
73
  "undici": "^7.0.0",
73
74
  "undici-thread-interceptor": "^0.10.0",
74
75
  "ws": "^8.16.0",
75
- "@platformatic/basic": "2.21.1",
76
- "@platformatic/itc": "2.21.1",
77
- "@platformatic/config": "2.21.1",
78
- "@platformatic/telemetry": "2.21.1",
79
- "@platformatic/utils": "2.21.1",
80
- "@platformatic/generators": "2.21.1",
81
- "@platformatic/ts-compiler": "2.21.1"
76
+ "@platformatic/basic": "2.22.0",
77
+ "@platformatic/config": "2.22.0",
78
+ "@platformatic/itc": "2.22.0",
79
+ "@platformatic/generators": "2.22.0",
80
+ "@platformatic/ts-compiler": "2.22.0",
81
+ "@platformatic/telemetry": "2.22.0",
82
+ "@platformatic/utils": "2.22.0"
82
83
  },
83
84
  "scripts": {
84
85
  "test": "npm run lint && borp --concurrency=1 --timeout=300000 && tsd",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.21.1.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.22.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "type": "object",
5
5
  "properties": {
@@ -296,6 +296,15 @@
296
296
  }
297
297
  },
298
298
  "additionalProperties": false
299
+ },
300
+ "env": {
301
+ "type": "object",
302
+ "additionalProperties": {
303
+ "type": "string"
304
+ }
305
+ },
306
+ "envfile": {
307
+ "type": "string"
299
308
  }
300
309
  }
301
310
  }
@@ -449,6 +458,15 @@
449
458
  }
450
459
  },
451
460
  "additionalProperties": false
461
+ },
462
+ "env": {
463
+ "type": "object",
464
+ "additionalProperties": {
465
+ "type": "string"
466
+ }
467
+ },
468
+ "envfile": {
469
+ "type": "string"
452
470
  }
453
471
  }
454
472
  }
@@ -1113,6 +1131,12 @@
1113
1131
  "resolvedServicesBasePath": {
1114
1132
  "type": "string",
1115
1133
  "default": "external"
1134
+ },
1135
+ "env": {
1136
+ "type": "object",
1137
+ "additionalProperties": {
1138
+ "type": "string"
1139
+ }
1116
1140
  }
1117
1141
  },
1118
1142
  "anyOf": [