@platformatic/runtime 0.47.6 → 1.1.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.
File without changes
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://platformatic.dev/schemas/v0.31.0/runtime",
3
+ "entrypoint": "echo",
4
+ "allowCycles": false,
5
+ "hotReload": true,
6
+ "autoload": {
7
+ "path": "services",
8
+ "exclude": [
9
+ "docs"
10
+ ]
11
+ },
12
+ "server": {
13
+ "hostname": "127.0.0.1",
14
+ "port": "14242",
15
+ "logger": {
16
+ "level": "info"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://platformatic.dev/schemas/v0.28.1/service",
3
+ "service": {
4
+ "openapi": true
5
+ },
6
+ "plugins": {
7
+ "paths": [
8
+ "./routes"
9
+ ],
10
+ "typescript": false
11
+ },
12
+ "server": {
13
+ "hostname": "127.0.0.1",
14
+ "port": "14343",
15
+ "logger": {
16
+ "level": "info"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,8 @@
1
+ 'use strict'
2
+ module.exports = async function (fastify, opts) {
3
+ // This returns the traceId set on the span by the service
4
+ fastify.get('/', async (request, reply) => {
5
+ const traceId = request.span.spanContext().traceId
6
+ return { traceId }
7
+ })
8
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://platformatic.dev/schemas/v0.31.0/runtime",
3
+ "entrypoint": "echo",
4
+ "allowCycles": false,
5
+ "hotReload": true,
6
+ "autoload": {
7
+ "path": "services",
8
+ "exclude": [
9
+ "docs"
10
+ ]
11
+ },
12
+ "server": {
13
+ "hostname": "127.0.0.1",
14
+ "port": "14242",
15
+ "logger": {
16
+ "level": "info"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://platformatic.dev/schemas/v0.28.1/service",
3
+ "service": {
4
+ "openapi": true
5
+ },
6
+ "plugins": {
7
+ "paths": [
8
+ "./routes"
9
+ ],
10
+ "typescript": false
11
+ }
12
+ }
@@ -0,0 +1,8 @@
1
+ 'use strict'
2
+ module.exports = async function (fastify, opts) {
3
+ // This returns the traceId set on the span by the service
4
+ fastify.get('/', async (request, reply) => {
5
+ const traceId = request.span.spanContext().traceId
6
+ return { traceId }
7
+ })
8
+ }
@@ -0,0 +1,4 @@
1
+ PLT_SERVER_HOSTNAME=127.0.0.1
2
+ PORT=3000
3
+ PLT_SERVER_LOGGER_LEVEL=info
4
+ PLT_EXAMPLE_ORIGIN=
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ async function default_1(app) {
4
+ }
5
+ exports.default = default_1;
6
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../plugin.ts"],"names":[],"mappings":";;AAGe,KAAK,oBAAW,GAAoB;AACnD,CAAC;AADD,4BACC"}
@@ -0,0 +1,3 @@
1
+ PLT_SERVER_HOSTNAME=127.0.0.1
2
+ PORT=3002
3
+ PLT_SERVER_LOGGER_LEVEL=info
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ async function default_1(fastify, opts) {
4
+ fastify.decorate('example', 'foobar');
5
+ }
6
+ exports.default = default_1;
7
+ //# sourceMappingURL=example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.js","sourceRoot":"","sources":["../../plugins/example.ts"],"names":[],"mappings":";;AAGe,KAAK,oBAAW,OAAwB,EAAE,IAA0B;IACjF,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;AACvC,CAAC;AAFD,4BAEC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ async function default_1(fastify, opts) {
4
+ fastify.get('/', async (request, reply) => {
5
+ return { hello: fastify.example };
6
+ });
7
+ fastify.get('/titles', async (request, reply) => {
8
+ const movies = await fastify.client.getMovies({});
9
+ const titles = movies.map((movie) => movie.title);
10
+ return { titles };
11
+ });
12
+ }
13
+ exports.default = default_1;
14
+ //# sourceMappingURL=root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root.js","sourceRoot":"","sources":["../../routes/root.ts"],"names":[],"mappings":";;AAUe,KAAK,oBAAW,OAAwB,EAAE,IAA0B;IACjF,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACxC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAC9C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QACjD,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACjD,OAAO,EAAE,MAAM,EAAE,CAAA;IACnB,CAAC,CAAC,CAAA;AACJ,CAAC;AAVD,4BAUC"}
@@ -0,0 +1,4 @@
1
+ PLT_SERVER_HOSTNAME=127.0.0.1
2
+ PORT=3000
3
+ PLT_SERVER_LOGGER_LEVEL=info
4
+ PLT_EXAMPLE_ORIGIN=
@@ -0,0 +1,4 @@
1
+ PLT_SERVER_HOSTNAME=127.0.0.1
2
+ PORT=3001
3
+ PLT_SERVER_LOGGER_LEVEL=info
4
+ DATABASE_URL=sqlite://./db.sqlite
@@ -0,0 +1,3 @@
1
+ PLT_SERVER_HOSTNAME=127.0.0.1
2
+ PORT=3002
3
+ PLT_SERVER_LOGGER_LEVEL=info
package/lib/api.js CHANGED
@@ -16,7 +16,13 @@ class RuntimeApi {
16
16
  for (let i = 0; i < config.services.length; ++i) {
17
17
  const service = config.services[i]
18
18
  const serviceTelemetryConfig = telemetryConfig ? { ...telemetryConfig, serviceName: `${telemetryConfig.serviceName}-${service.id}` } : null
19
- const app = new PlatformaticApp(service, loaderPort, logger, serviceTelemetryConfig)
19
+
20
+ // If the service is an entrypoint and runtime server config is defined, use it.
21
+ let serverConfig = null
22
+ if (config.server && service.entrypoint) {
23
+ serverConfig = config.server
24
+ }
25
+ const app = new PlatformaticApp(service, loaderPort, logger, serviceTelemetryConfig, serverConfig)
20
26
 
21
27
  this.#services.set(service.id, app)
22
28
  }
package/lib/app.js CHANGED
@@ -17,9 +17,10 @@ class PlatformaticApp {
17
17
  #fileWatcher
18
18
  #logger
19
19
  #telemetryConfig
20
+ #serverConfig
20
21
  #debouncedRestart
21
22
 
22
- constructor (appConfig, loaderPort, logger, telemetryConfig) {
23
+ constructor (appConfig, loaderPort, logger, telemetryConfig, serverConfig) {
23
24
  this.appConfig = appConfig
24
25
  this.config = null
25
26
  this.#hotReload = false
@@ -33,6 +34,7 @@ class PlatformaticApp {
33
34
  name: this.appConfig.id
34
35
  })
35
36
  this.#telemetryConfig = telemetryConfig
37
+ this.#serverConfig = serverConfig
36
38
 
37
39
  /* c8 ignore next 4 */
38
40
  this.#debouncedRestart = debounce(() => {
@@ -93,6 +95,14 @@ class PlatformaticApp {
93
95
  ...configManager.current,
94
96
  telemetry: this.#telemetryConfig
95
97
  })
98
+
99
+ if (this.#serverConfig) {
100
+ configManager.update({
101
+ ...configManager.current,
102
+ server: this.#serverConfig
103
+ })
104
+ }
105
+
96
106
  const config = configManager.current
97
107
 
98
108
  this.#setuplogger(configManager)
package/lib/config.js CHANGED
@@ -246,6 +246,7 @@ platformaticRuntime.configManagerConfig = {
246
246
  allErrors: true,
247
247
  strict: false
248
248
  },
249
+ envWhitelist: ['DATABASE_URL', 'PORT', 'HOSTNAME'],
249
250
  async transformConfig () {
250
251
  await _transformConfig(this)
251
252
  }
package/lib/schema.js CHANGED
@@ -2,6 +2,7 @@
2
2
  'use strict'
3
3
 
4
4
  const telemetry = require('@platformatic/telemetry').schema
5
+ const { server } = require('@platformatic/service').schema
5
6
  const pkg = require('../package.json')
6
7
  const version = 'v' + pkg.version
7
8
  const platformaticRuntimeSchema = {
@@ -44,6 +45,7 @@ const platformaticRuntimeSchema = {
44
45
  }
45
46
  },
46
47
  telemetry,
48
+ server,
47
49
  services: {
48
50
  type: 'array',
49
51
  default: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "0.47.6",
3
+ "version": "1.1.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -17,38 +17,38 @@
17
17
  },
18
18
  "homepage": "https://github.com/platformatic/platformatic#readme",
19
19
  "devDependencies": {
20
- "c8": "^8.0.0",
21
- "execa": "^8.0.0",
20
+ "c8": "^8.0.1",
21
+ "execa": "^8.0.1",
22
22
  "snazzy": "^9.0.0",
23
23
  "split2": "^4.2.0",
24
24
  "standard": "^17.1.0",
25
25
  "tsd": "^0.29.0",
26
- "typescript": "^5.1.6",
27
- "@platformatic/sql-graphql": "0.47.6",
28
- "@platformatic/sql-mapper": "0.47.6"
26
+ "typescript": "^5.2.2",
27
+ "@platformatic/sql-mapper": "1.1.0",
28
+ "@platformatic/sql-graphql": "1.1.0"
29
29
  },
30
30
  "dependencies": {
31
+ "@fastify/error": "^3.3.0",
31
32
  "@hapi/topo": "^6.0.2",
32
- "@fastify/error": "^3.2.1",
33
33
  "close-with-grace": "^1.2.0",
34
34
  "commist": "^3.2.0",
35
35
  "debounce": "^1.2.1",
36
36
  "desm": "^1.3.0",
37
- "es-main": "^1.2.0",
37
+ "es-main": "^1.3.0",
38
38
  "fastest-levenshtein": "^1.0.16",
39
- "fastify": "^4.18.0",
40
- "fastify-undici-dispatcher": "^0.4.1",
39
+ "fastify": "^4.23.2",
40
+ "fastify-undici-dispatcher": "^0.4.2",
41
41
  "help-me": "^4.2.0",
42
42
  "minimist": "^1.2.8",
43
- "pino": "^8.14.1",
44
- "pino-pretty": "^10.0.0",
45
- "undici": "^5.22.1",
46
- "@platformatic/composer": "0.47.6",
47
- "@platformatic/config": "0.47.6",
48
- "@platformatic/db": "0.47.6",
49
- "@platformatic/service": "0.47.6",
50
- "@platformatic/telemetry": "0.47.6",
51
- "@platformatic/utils": "0.47.6"
43
+ "pino": "^8.15.3",
44
+ "pino-pretty": "^10.2.0",
45
+ "undici": "^5.25.3",
46
+ "@platformatic/service": "1.1.0",
47
+ "@platformatic/db": "1.1.0",
48
+ "@platformatic/telemetry": "1.1.0",
49
+ "@platformatic/utils": "1.1.0",
50
+ "@platformatic/config": "1.1.0",
51
+ "@platformatic/composer": "1.1.0"
52
52
  },
53
53
  "standard": {
54
54
  "ignore": [