@platformatic/service 2.0.0-alpha.2 → 2.0.0-alpha.21
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 +11 -2
- package/eslint.config.js +14 -0
- package/index.d.ts +19 -16
- package/index.js +55 -7
- package/index.test-d.ts +34 -31
- package/lib/compile.js +4 -4
- package/lib/create.mjs +7 -7
- package/lib/gen-schema.js +1 -1
- package/lib/gen-types.mjs +2 -2
- package/lib/generator/service-generator.js +16 -16
- package/lib/openapi-schema-defs.js +363 -363
- package/lib/plugins/graphql.js +2 -2
- package/lib/plugins/health-check.js +1 -1
- package/lib/plugins/metrics.js +23 -31
- package/lib/plugins/openapi.js +10 -10
- package/lib/plugins/plugins.js +13 -6
- package/lib/plugins/sandbox-wrapper.js +2 -2
- package/lib/plugins/typescript.js +3 -3
- package/lib/root-endpoint/index.js +2 -2
- package/lib/schema.js +148 -155
- package/lib/stackable.js +271 -0
- package/lib/start.js +64 -65
- package/lib/upgrade.js +1 -4
- package/lib/utils.js +13 -11
- package/lib/versions/0.16.0.js +7 -7
- package/lib/versions/2.0.0.js +11 -0
- package/lib/versions/from-zero-twenty-eight-to-will-see.js +3 -3
- package/lib/versions/no-allow-cycles.js +2 -2
- package/package.json +37 -51
- package/schema.json +30 -6
- package/service.mjs +7 -7
package/lib/start.js
CHANGED
|
@@ -4,8 +4,8 @@ const { readFile } = require('fs/promises')
|
|
|
4
4
|
const close = require('close-with-grace')
|
|
5
5
|
const { loadConfig, ConfigManager, printConfigValidationErrors, printAndExitLoadConfigError } = require('@platformatic/config')
|
|
6
6
|
const { addLoggerToTheConfig, isDocker } = require('./utils.js')
|
|
7
|
-
const { restartable } = require('@fastify/restartable')
|
|
8
7
|
const { randomUUID } = require('crypto')
|
|
8
|
+
const { fastify } = require('fastify')
|
|
9
9
|
|
|
10
10
|
async function adjustHttpsKeyAndCert (arg) {
|
|
11
11
|
if (typeof arg === 'string') {
|
|
@@ -25,7 +25,44 @@ async function adjustHttpsKeyAndCert (arg) {
|
|
|
25
25
|
return arg
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async function
|
|
28
|
+
async function createServer (serverContext) {
|
|
29
|
+
const { app, configManager, context } = serverContext
|
|
30
|
+
const config = configManager.current
|
|
31
|
+
let fastifyOptions = {}
|
|
32
|
+
|
|
33
|
+
if (config.server) {
|
|
34
|
+
// override hostname if it's docker
|
|
35
|
+
if (await isDocker()) {
|
|
36
|
+
config.server.hostname = '0.0.0.0'
|
|
37
|
+
}
|
|
38
|
+
fastifyOptions = {
|
|
39
|
+
...config.server,
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
fastifyOptions.genReqId = function (req) { return randomUUID() }
|
|
43
|
+
const root = fastify(fastifyOptions)
|
|
44
|
+
root.decorate('platformatic', { configManager, config })
|
|
45
|
+
await root.register(app, { context })
|
|
46
|
+
if (!root.hasRoute({ url: '/', method: 'GET' })) {
|
|
47
|
+
await root.register(require('./root-endpoint'))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
root.decorate('url', {
|
|
51
|
+
getter () {
|
|
52
|
+
return serverContext.url
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
return root
|
|
57
|
+
}
|
|
58
|
+
async function buildConfigManager (options, app) {
|
|
59
|
+
const loggerInstance = options.server?.loggerInstance
|
|
60
|
+
if (loggerInstance) {
|
|
61
|
+
delete options.server.loggerInstance
|
|
62
|
+
options.server ||= {}
|
|
63
|
+
options.server.logger = { level: loggerInstance.level }
|
|
64
|
+
}
|
|
65
|
+
|
|
29
66
|
let configManager = options.configManager
|
|
30
67
|
if (!configManager) {
|
|
31
68
|
// instantiate a new config manager from current options
|
|
@@ -33,6 +70,16 @@ async function buildServer (options, app) {
|
|
|
33
70
|
await configManager.parseAndValidate()
|
|
34
71
|
}
|
|
35
72
|
|
|
73
|
+
if (loggerInstance) {
|
|
74
|
+
configManager.current.server ||= {}
|
|
75
|
+
delete configManager.current.server.logger
|
|
76
|
+
configManager.current.server.loggerInstance = loggerInstance
|
|
77
|
+
}
|
|
78
|
+
return configManager
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function buildServer (options, app, context) {
|
|
82
|
+
const configManager = await buildConfigManager(options, app)
|
|
36
83
|
const config = configManager.current
|
|
37
84
|
|
|
38
85
|
// The server now can be not present, so we might need to add logger
|
|
@@ -43,52 +90,25 @@ async function buildServer (options, app) {
|
|
|
43
90
|
options = config
|
|
44
91
|
}
|
|
45
92
|
|
|
46
|
-
let url = null
|
|
47
|
-
|
|
48
|
-
async function createRestartable (fastify) {
|
|
49
|
-
const config = configManager.current
|
|
50
|
-
let fastifyOptions = {}
|
|
51
|
-
|
|
52
|
-
if (config.server) {
|
|
53
|
-
// override hostname if it's docker
|
|
54
|
-
if (await isDocker()) {
|
|
55
|
-
config.server.hostname = '0.0.0.0'
|
|
56
|
-
}
|
|
57
|
-
fastifyOptions = {
|
|
58
|
-
...config.server
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
fastifyOptions.genReqId = function (req) { return randomUUID() }
|
|
62
|
-
const root = fastify(fastifyOptions)
|
|
63
|
-
root.decorate('platformatic', { configManager, config })
|
|
64
|
-
await root.register(app)
|
|
65
|
-
if (!root.hasRoute({ url: '/', method: 'GET' })) {
|
|
66
|
-
await root.register(require('./root-endpoint'))
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
root.decorate('url', {
|
|
70
|
-
getter () {
|
|
71
|
-
return url
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
if (root.restarted) {
|
|
76
|
-
root.log.info('restarted')
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return root
|
|
80
|
-
}
|
|
81
|
-
|
|
82
93
|
if (options.server) {
|
|
83
94
|
if (options.server.https) {
|
|
84
95
|
options.server.https.key = await adjustHttpsKeyAndCert(options.server.https.key)
|
|
85
96
|
options.server.https.cert = await adjustHttpsKeyAndCert(options.server.https.cert)
|
|
86
97
|
}
|
|
87
98
|
}
|
|
88
|
-
|
|
99
|
+
|
|
100
|
+
const serverContext = {
|
|
101
|
+
app: typeof app === 'function' ? app : app.app,
|
|
102
|
+
configManager,
|
|
103
|
+
context
|
|
104
|
+
}
|
|
105
|
+
const handler = await createServer(serverContext)
|
|
89
106
|
handler.decorate('start', async () => {
|
|
90
|
-
url = await handler.listen({
|
|
91
|
-
|
|
107
|
+
serverContext.url = await handler.listen({
|
|
108
|
+
host: options.server?.hostname || '127.0.0.1',
|
|
109
|
+
port: options.server?.port || 0,
|
|
110
|
+
})
|
|
111
|
+
return serverContext.url
|
|
92
112
|
})
|
|
93
113
|
configManager.on('error', function (err) {
|
|
94
114
|
/* c8 ignore next 1 */
|
|
@@ -98,20 +118,6 @@ async function buildServer (options, app) {
|
|
|
98
118
|
return handler
|
|
99
119
|
}
|
|
100
120
|
|
|
101
|
-
/* c8 ignore next 12 */
|
|
102
|
-
async function safeRestart (app) {
|
|
103
|
-
try {
|
|
104
|
-
await app.restart()
|
|
105
|
-
} catch (err) {
|
|
106
|
-
app.log.error({
|
|
107
|
-
err: {
|
|
108
|
-
message: err.message,
|
|
109
|
-
stack: err.stack
|
|
110
|
-
}
|
|
111
|
-
}, 'failed to reload server')
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
121
|
async function start (appType, _args) {
|
|
116
122
|
/* c8 ignore next 55 */
|
|
117
123
|
let configManager = null
|
|
@@ -145,22 +151,14 @@ async function start (appType, _args) {
|
|
|
145
151
|
printAndExitLoadConfigError(err)
|
|
146
152
|
}
|
|
147
153
|
|
|
148
|
-
// Ignore from CI because SIGUSR2 is not available
|
|
149
|
-
// on Windows
|
|
150
|
-
process.on('SIGUSR2', function () {
|
|
151
|
-
app.log.info('reloading configuration')
|
|
152
|
-
safeRestart(app)
|
|
153
|
-
return false
|
|
154
|
-
})
|
|
155
|
-
|
|
156
154
|
close(async ({ signal, err }) => {
|
|
157
155
|
// Windows does not support trapping signals
|
|
158
156
|
if (err) {
|
|
159
157
|
app.log.error({
|
|
160
158
|
err: {
|
|
161
159
|
message: err.message,
|
|
162
|
-
stack: err.stack
|
|
163
|
-
}
|
|
160
|
+
stack: err.stack,
|
|
161
|
+
},
|
|
164
162
|
}, 'exiting')
|
|
165
163
|
} else if (signal) {
|
|
166
164
|
app.log.info({ signal }, 'received signal')
|
|
@@ -172,5 +170,6 @@ async function start (appType, _args) {
|
|
|
172
170
|
})
|
|
173
171
|
}
|
|
174
172
|
|
|
173
|
+
module.exports.buildConfigManager = buildConfigManager
|
|
175
174
|
module.exports.buildServer = buildServer
|
|
176
175
|
module.exports.start = start
|
package/lib/upgrade.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { join } = require('path')
|
|
4
|
-
const pkg = require('../package.json')
|
|
5
4
|
|
|
6
5
|
module.exports = async function upgrade (config, version) {
|
|
7
6
|
const { semgrator } = await import('semgrator')
|
|
@@ -10,7 +9,7 @@ module.exports = async function upgrade (config, version) {
|
|
|
10
9
|
version,
|
|
11
10
|
path: join(__dirname, 'versions'),
|
|
12
11
|
input: config,
|
|
13
|
-
logger: this.logger.child({ name: '@platformatic/service' })
|
|
12
|
+
logger: this.logger.child({ name: '@platformatic/service' }),
|
|
14
13
|
})
|
|
15
14
|
|
|
16
15
|
let result
|
|
@@ -19,7 +18,5 @@ module.exports = async function upgrade (config, version) {
|
|
|
19
18
|
result = updated.result
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
result.$schema = `https://platformatic.dev/schemas/v${pkg.version}/service`
|
|
23
|
-
|
|
24
21
|
return result
|
|
25
22
|
}
|
package/lib/utils.js
CHANGED
|
@@ -21,17 +21,19 @@ function addLoggerToTheConfig (config) {
|
|
|
21
21
|
config.server = {}
|
|
22
22
|
}
|
|
23
23
|
// Set the logger if not present
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
if (!config.server.loggerInstance) {
|
|
25
|
+
let logger = config.server.logger
|
|
26
|
+
if (!logger) {
|
|
27
|
+
config.server.logger = { level: 'info' }
|
|
28
|
+
logger = config.server.logger
|
|
29
|
+
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
// If TTY use pino-pretty
|
|
32
|
+
if (isatty(1)) {
|
|
33
|
+
if (!logger.transport) {
|
|
34
|
+
logger.transport = {
|
|
35
|
+
target: 'pino-pretty',
|
|
36
|
+
}
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -101,5 +103,5 @@ module.exports = {
|
|
|
101
103
|
isDocker,
|
|
102
104
|
isFileAccessible,
|
|
103
105
|
getJSPluginPath,
|
|
104
|
-
addLoggerToTheConfig
|
|
106
|
+
addLoggerToTheConfig,
|
|
105
107
|
}
|
package/lib/versions/0.16.0.js
CHANGED
|
@@ -19,12 +19,12 @@ module.exports = {
|
|
|
19
19
|
} else if (p.options) {
|
|
20
20
|
return {
|
|
21
21
|
path: p.path,
|
|
22
|
-
options: p.options
|
|
22
|
+
options: p.options,
|
|
23
23
|
}
|
|
24
24
|
} else {
|
|
25
25
|
return p.path
|
|
26
26
|
}
|
|
27
|
-
})
|
|
27
|
+
}),
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
if (typeof config.plugin[0] === 'object') {
|
|
@@ -43,12 +43,12 @@ module.exports = {
|
|
|
43
43
|
config.plugins = {
|
|
44
44
|
paths: [{
|
|
45
45
|
path: config.plugin.path,
|
|
46
|
-
options: config.plugin.options
|
|
47
|
-
}]
|
|
46
|
+
options: config.plugin.options,
|
|
47
|
+
}],
|
|
48
48
|
}
|
|
49
49
|
} else {
|
|
50
50
|
config.plugins = {
|
|
51
|
-
paths: [config.plugin.path]
|
|
51
|
+
paths: [config.plugin.path],
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -66,7 +66,7 @@ module.exports = {
|
|
|
66
66
|
}
|
|
67
67
|
} else {
|
|
68
68
|
config.plugins = {
|
|
69
|
-
paths: [config.plugin]
|
|
69
|
+
paths: [config.plugin],
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -78,5 +78,5 @@ module.exports = {
|
|
|
78
78
|
config.$schema = 'https://platformatic.dev/schemas/v0.17.0/' + kind
|
|
79
79
|
|
|
80
80
|
return config
|
|
81
|
-
}
|
|
81
|
+
},
|
|
82
82
|
}
|
|
@@ -7,10 +7,10 @@ module.exports.migration = {
|
|
|
7
7
|
toVersion: version,
|
|
8
8
|
up: function (config) {
|
|
9
9
|
if (config.watch !== false) {
|
|
10
|
-
config.watch = typeof config.watch === 'object' ? config.watch :
|
|
10
|
+
config.watch = typeof config.watch === 'object' ? config.watch : true
|
|
11
11
|
}
|
|
12
|
-
delete config.plugins?.
|
|
12
|
+
delete config.plugins?.watch
|
|
13
13
|
|
|
14
14
|
return config
|
|
15
|
-
}
|
|
15
|
+
},
|
|
16
16
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { version } = require('../../package.json')
|
|
4
4
|
|
|
5
5
|
module.exports.migration = {
|
|
6
|
-
version: '
|
|
6
|
+
version: '1.99.0', // This is to account alpha versions as well
|
|
7
7
|
toVersion: version,
|
|
8
8
|
up: function (config) {
|
|
9
9
|
if (typeof config.allowCycles === 'boolean') {
|
|
@@ -11,5 +11,5 @@ module.exports.migration = {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
return config
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.21",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -17,43 +17,42 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@fastify/aws-lambda": "^
|
|
21
|
-
"@fastify/compress": "^
|
|
20
|
+
"@fastify/aws-lambda": "^5.0.0",
|
|
21
|
+
"@fastify/compress": "^8.0.0",
|
|
22
22
|
"bindings": "^1.5.0",
|
|
23
|
-
"borp": "^0.
|
|
24
|
-
"
|
|
23
|
+
"borp": "^0.17.0",
|
|
24
|
+
"eslint": "9",
|
|
25
|
+
"json-schema-to-typescript": "^15.0.0",
|
|
26
|
+
"neostandard": "^0.11.1",
|
|
25
27
|
"openapi-types": "^12.1.3",
|
|
26
|
-
"pino-abstract-transport": "^
|
|
28
|
+
"pino-abstract-transport": "^2.0.0",
|
|
27
29
|
"self-cert": "^2.0.0",
|
|
28
|
-
"snazzy": "^9.0.0",
|
|
29
30
|
"split2": "^4.2.0",
|
|
30
|
-
"standard": "^17.1.0",
|
|
31
31
|
"strip-ansi": "^7.1.0",
|
|
32
|
-
"ts-standard": "^12.0.2",
|
|
33
32
|
"tsd": "^0.31.0",
|
|
34
|
-
"typescript": "^5.4
|
|
33
|
+
"typescript": "^5.5.4",
|
|
35
34
|
"undici": "^6.0.0",
|
|
36
35
|
"vscode-json-languageservice": "^5.3.9",
|
|
37
36
|
"why-is-node-running": "^2.2.2",
|
|
38
37
|
"yaml": "^2.4.1"
|
|
39
38
|
},
|
|
40
39
|
"dependencies": {
|
|
41
|
-
"@fastify/accepts": "^
|
|
42
|
-
"@fastify/autoload": "^
|
|
43
|
-
"@fastify/basic-auth": "^
|
|
44
|
-
"@fastify/cors": "^
|
|
45
|
-
"@fastify/deepmerge": "^
|
|
46
|
-
"@fastify/error": "^
|
|
47
|
-
"@fastify/
|
|
48
|
-
"@fastify/
|
|
49
|
-
"@fastify/
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
40
|
+
"@fastify/accepts": "^5.0.0",
|
|
41
|
+
"@fastify/autoload": "^6.0.0",
|
|
42
|
+
"@fastify/basic-auth": "^6.0.0",
|
|
43
|
+
"@fastify/cors": "^10.0.0",
|
|
44
|
+
"@fastify/deepmerge": "^2.0.0",
|
|
45
|
+
"@fastify/error": "^4.0.0",
|
|
46
|
+
"@fastify/static": "^8.0.0",
|
|
47
|
+
"@fastify/swagger": "^9.0.0",
|
|
48
|
+
"@fastify/under-pressure": "^9.0.0",
|
|
49
|
+
"@mercuriusjs/federation": "^4.0.0",
|
|
50
|
+
"@platformatic/fastify-http-metrics": "^0.1.0",
|
|
52
51
|
"@scalar/fastify-api-reference": "^1.19.5",
|
|
53
52
|
"@types/ws": "^8.5.10",
|
|
54
53
|
"ajv": "^8.12.0",
|
|
55
54
|
"cli-progress": "^3.12.0",
|
|
56
|
-
"close-with-grace": "^
|
|
55
|
+
"close-with-grace": "^2.0.0",
|
|
57
56
|
"code-block-writer": "^13.0.1",
|
|
58
57
|
"colorette": "^2.0.20",
|
|
59
58
|
"commist": "^3.2.0",
|
|
@@ -62,48 +61,35 @@
|
|
|
62
61
|
"env-schema": "^5.2.1",
|
|
63
62
|
"es-main": "^1.3.0",
|
|
64
63
|
"execa": "^8.0.1",
|
|
65
|
-
"fastify": "^
|
|
66
|
-
"fastify-metrics": "^
|
|
67
|
-
"fastify-
|
|
68
|
-
"
|
|
69
|
-
"graphql": "^16.8.1",
|
|
64
|
+
"fastify": "^5.0.0",
|
|
65
|
+
"fastify-metrics": "^12.0.0",
|
|
66
|
+
"fastify-plugin": "^5.0.0",
|
|
67
|
+
"graphql": "^16.9.0",
|
|
70
68
|
"help-me": "^5.0.0",
|
|
71
|
-
"mercurius": "^
|
|
69
|
+
"mercurius": "^15.0.0",
|
|
72
70
|
"minimist": "^1.2.8",
|
|
73
71
|
"my-ua-parser": "^2.0.2",
|
|
74
72
|
"ora": "^6.3.1",
|
|
75
|
-
"pino": "^
|
|
73
|
+
"pino": "^9.0.0",
|
|
76
74
|
"pino-pretty": "^11.0.0",
|
|
77
75
|
"prom-client": "^15.1.2",
|
|
78
76
|
"rfdc": "^1.3.1",
|
|
79
77
|
"semgrator": "^0.3.0",
|
|
80
78
|
"undici": "^6.9.0",
|
|
81
|
-
"@platformatic/client": "2.0.0-alpha.
|
|
82
|
-
"@platformatic/
|
|
83
|
-
"@platformatic/
|
|
84
|
-
"@platformatic/
|
|
85
|
-
"@platformatic/
|
|
86
|
-
"@platformatic/
|
|
87
|
-
"@platformatic/
|
|
88
|
-
},
|
|
89
|
-
"standard": {
|
|
90
|
-
"ignore": [
|
|
91
|
-
"**/dist/*"
|
|
92
|
-
]
|
|
93
|
-
},
|
|
94
|
-
"ts-standard": {
|
|
95
|
-
"ignore": [
|
|
96
|
-
"**/dist/*",
|
|
97
|
-
"fixtures/**/*",
|
|
98
|
-
"test/**/*"
|
|
99
|
-
]
|
|
79
|
+
"@platformatic/client": "2.0.0-alpha.21",
|
|
80
|
+
"@platformatic/generators": "2.0.0-alpha.21",
|
|
81
|
+
"@platformatic/scalar-theme": "2.0.0-alpha.21",
|
|
82
|
+
"@platformatic/config": "2.0.0-alpha.21",
|
|
83
|
+
"@platformatic/telemetry": "2.0.0-alpha.21",
|
|
84
|
+
"@platformatic/ts-compiler": "2.0.0-alpha.21",
|
|
85
|
+
"@platformatic/utils": "2.0.0-alpha.21"
|
|
100
86
|
},
|
|
101
87
|
"scripts": {
|
|
102
|
-
"test": "pnpm run lint && borp -T --concurrency=1 --timeout
|
|
103
|
-
"unit": "borp --pattern 'test/**/*.test.{js,mjs}' --ignore 'fixtures/**/*' --concurrency=1 --timeout=
|
|
88
|
+
"test": "pnpm run lint && borp -T --concurrency=1 --timeout=180000 && tsd",
|
|
89
|
+
"unit": "borp --pattern 'test/**/*.test.{js,mjs}' --ignore 'fixtures/**/*' --concurrency=1 --timeout=180000 --no-typescript",
|
|
104
90
|
"gen-schema": "node lib/schema.js > schema.json",
|
|
105
91
|
"gen-types": "json2ts > config.d.ts < schema.json",
|
|
106
92
|
"build": "pnpm run gen-schema && pnpm run gen-types",
|
|
107
|
-
"lint": "
|
|
93
|
+
"lint": "eslint && tsd"
|
|
108
94
|
}
|
|
109
95
|
}
|
package/schema.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://platformatic.dev/
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.0.0-alpha.21.json",
|
|
3
|
+
"version": "2.0.0-alpha.21",
|
|
4
4
|
"title": "Platformatic Service",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|
|
@@ -93,7 +93,24 @@
|
|
|
93
93
|
"type": "object",
|
|
94
94
|
"properties": {
|
|
95
95
|
"level": {
|
|
96
|
-
"type": "string"
|
|
96
|
+
"type": "string",
|
|
97
|
+
"default": "info",
|
|
98
|
+
"oneOf": [
|
|
99
|
+
{
|
|
100
|
+
"enum": [
|
|
101
|
+
"fatal",
|
|
102
|
+
"error",
|
|
103
|
+
"warn",
|
|
104
|
+
"info",
|
|
105
|
+
"debug",
|
|
106
|
+
"trace",
|
|
107
|
+
"silent"
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"pattern": "^\\{.+\\}$"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
97
114
|
},
|
|
98
115
|
"transport": {
|
|
99
116
|
"anyOf": [
|
|
@@ -154,10 +171,17 @@
|
|
|
154
171
|
"additionalProperties": false
|
|
155
172
|
}
|
|
156
173
|
},
|
|
174
|
+
"required": [
|
|
175
|
+
"level"
|
|
176
|
+
],
|
|
177
|
+
"default": {},
|
|
157
178
|
"additionalProperties": true
|
|
158
179
|
}
|
|
159
180
|
]
|
|
160
181
|
},
|
|
182
|
+
"loggerInstance": {
|
|
183
|
+
"type": "object"
|
|
184
|
+
},
|
|
161
185
|
"serializerOpts": {
|
|
162
186
|
"type": "object",
|
|
163
187
|
"properties": {
|
|
@@ -635,9 +659,6 @@
|
|
|
635
659
|
],
|
|
636
660
|
"additionalProperties": false
|
|
637
661
|
},
|
|
638
|
-
"prefix": {
|
|
639
|
-
"type": "string"
|
|
640
|
-
},
|
|
641
662
|
"auth": {
|
|
642
663
|
"type": "object",
|
|
643
664
|
"properties": {
|
|
@@ -823,6 +844,9 @@
|
|
|
823
844
|
"$schema": {
|
|
824
845
|
"type": "string"
|
|
825
846
|
},
|
|
847
|
+
"module": {
|
|
848
|
+
"type": "string"
|
|
849
|
+
},
|
|
826
850
|
"service": {
|
|
827
851
|
"type": "object",
|
|
828
852
|
"properties": {
|
package/service.mjs
CHANGED
|
@@ -12,12 +12,12 @@ import { generateJsonSchemaConfig } from './lib/gen-schema.js'
|
|
|
12
12
|
import { generateTypes } from './lib/gen-types.mjs'
|
|
13
13
|
import { createService } from './lib/create.mjs'
|
|
14
14
|
|
|
15
|
-
import
|
|
15
|
+
import platformaticService from './index.js'
|
|
16
16
|
|
|
17
17
|
const help = helpMe({
|
|
18
18
|
dir: join(import.meta.url, 'help'),
|
|
19
19
|
// the default
|
|
20
|
-
ext: '.txt'
|
|
20
|
+
ext: '.txt',
|
|
21
21
|
})
|
|
22
22
|
|
|
23
23
|
function wrapCommand (fn) {
|
|
@@ -38,7 +38,7 @@ program.register('help start', help.toStdout.bind(null, ['start']))
|
|
|
38
38
|
|
|
39
39
|
program.register('start', (argv) => {
|
|
40
40
|
/* c8 ignore next 1 */
|
|
41
|
-
start(platformaticService, argv).catch(printAndExitLoadConfigError)
|
|
41
|
+
platformaticService.start(platformaticService, argv).catch(printAndExitLoadConfigError)
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
program.register('create', wrapCommand(createService))
|
|
@@ -50,19 +50,19 @@ program.register('schema', help.toStdout.bind(null, ['schema']))
|
|
|
50
50
|
export async function runService (argv) {
|
|
51
51
|
const args = parseArgs(argv, {
|
|
52
52
|
alias: {
|
|
53
|
-
v: 'version'
|
|
54
|
-
}
|
|
53
|
+
v: 'version',
|
|
54
|
+
},
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
/* c8 ignore next 4 */
|
|
58
58
|
if (args.version) {
|
|
59
|
-
console.log('v' + JSON.parse(await readFile(join(import.meta.url, 'package.json'))).version)
|
|
59
|
+
console.log('v' + JSON.parse(await readFile(join(import.meta.url, 'package.json'), 'utf-8')).version)
|
|
60
60
|
process.exit(0)
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
return {
|
|
64
64
|
output: await program.parseAsync(argv),
|
|
65
|
-
help
|
|
65
|
+
help,
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|