@platformatic/service 0.47.2 → 0.47.3

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/index.js CHANGED
@@ -67,7 +67,7 @@ async function platformaticService (app, opts, toLoad = []) {
67
67
  await app.register(loadPlugins)
68
68
  }
69
69
 
70
- if (config.server.cors) {
70
+ if (isKeyEnabled('cors', config.server)) {
71
71
  app.register(setupCors, config.server.cors)
72
72
  }
73
73
 
package/lib/schema.js CHANGED
@@ -635,7 +635,6 @@ const platformaticServiceSchema = {
635
635
  clients
636
636
  },
637
637
  additionalProperties: false,
638
- required: ['server'],
639
638
  $defs: openApiDefs
640
639
  }
641
640
 
package/lib/start.js CHANGED
@@ -41,11 +41,15 @@ async function buildServer (options, app) {
41
41
 
42
42
  async function createRestartable (fastify) {
43
43
  const config = configManager.current
44
- const root = fastify({
45
- ...config.server,
46
- genReqId: function (req) { return randomUUID() }
47
- })
44
+ let fastifyOptions = {}
45
+ if (config.server) {
46
+ fastifyOptions = {
47
+ ...config.server
48
+ }
49
+ }
50
+ fastifyOptions.genReqId = function (req) { return randomUUID() }
48
51
 
52
+ const root = fastify(fastifyOptions)
49
53
  root.decorate('platformatic', { configManager, config })
50
54
  root.register(app)
51
55
 
@@ -62,25 +66,24 @@ async function buildServer (options, app) {
62
66
  return root
63
67
  }
64
68
 
65
- const { port, hostname, ...serverOptions } = options.server
66
-
67
- if (serverOptions.https) {
68
- serverOptions.https.key = await adjustHttpsKeyAndCert(serverOptions.https.key)
69
- serverOptions.https.cert = await adjustHttpsKeyAndCert(serverOptions.https.cert)
69
+ if (options.server) {
70
+ if (options.server.https) {
71
+ options.server.https.key = await adjustHttpsKeyAndCert(options.server.https.key)
72
+ options.server.https.cert = await adjustHttpsKeyAndCert(options.server.https.cert)
73
+ }
70
74
  }
71
-
72
75
  const handler = await restartable(createRestartable)
73
-
76
+ if (options.server) {
77
+ handler.decorate('start', async () => {
78
+ url = await handler.listen({ host: options.server.hostname, port: options.server.port })
79
+ return url
80
+ })
81
+ }
74
82
  configManager.on('error', function (err) {
75
83
  /* c8 ignore next 1 */
76
84
  handler.log.error({ err }, 'error reloading the configuration')
77
85
  })
78
86
 
79
- handler.decorate('start', async () => {
80
- url = await handler.listen({ host: hostname, port })
81
- return url
82
- })
83
-
84
87
  return handler
85
88
  }
86
89
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/service",
3
- "version": "0.47.2",
3
+ "version": "0.47.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -67,11 +67,11 @@
67
67
  "pino-pretty": "^10.0.0",
68
68
  "rfdc": "^1.3.0",
69
69
  "ua-parser-js": "^1.0.35",
70
- "@platformatic/client": "0.47.2",
71
- "@platformatic/config": "0.47.2",
72
- "@platformatic/swagger-ui-theme": "0.47.2",
73
- "@platformatic/telemetry": "0.47.2",
74
- "@platformatic/utils": "0.47.2"
70
+ "@platformatic/client": "0.47.3",
71
+ "@platformatic/config": "0.47.3",
72
+ "@platformatic/swagger-ui-theme": "0.47.3",
73
+ "@platformatic/telemetry": "0.47.3",
74
+ "@platformatic/utils": "0.47.3"
75
75
  },
76
76
  "standard": {
77
77
  "ignore": [