@platformatic/runtime 2.0.1 → 2.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.
Files changed (256) hide show
  1. package/config.d.ts +1 -1
  2. package/index.d.ts +1 -0
  3. package/lib/config.js +37 -1
  4. package/lib/errors.js +1 -0
  5. package/lib/schema.js +1 -5
  6. package/lib/versions/v2.0.0.js +2 -0
  7. package/lib/worker/app.js +1 -2
  8. package/package.json +13 -13
  9. package/schema.json +4 -7
  10. package/fixtures/botched-start/platformatic.runtime.json +0 -14
  11. package/fixtures/botched-start/services/a/platformatic.service.json +0 -14
  12. package/fixtures/botched-start/services/a/plugin.js +0 -11
  13. package/fixtures/composerApp/api1.json +0 -65
  14. package/fixtures/composerApp/platformatic.composer.json +0 -23
  15. package/fixtures/configs/invalid-entrypoint.json +0 -14
  16. package/fixtures/configs/invalid-schema-type.config.json +0 -19
  17. package/fixtures/configs/invalid-web-with-services.json +0 -36
  18. package/fixtures/configs/missing-property.config.json +0 -13
  19. package/fixtures/configs/missing-service-config.json +0 -7
  20. package/fixtures/configs/monorepo-composer-no-autoload.json +0 -32
  21. package/fixtures/configs/monorepo-composer.json +0 -19
  22. package/fixtures/configs/monorepo-create-cycle.json +0 -20
  23. package/fixtures/configs/monorepo-missing-dependencies.json +0 -9
  24. package/fixtures/configs/monorepo-no-cycles.json +0 -19
  25. package/fixtures/configs/monorepo-openapi.json +0 -12
  26. package/fixtures/configs/monorepo-watch-env.json +0 -19
  27. package/fixtures/configs/monorepo-watch-single.json +0 -12
  28. package/fixtures/configs/monorepo-watch.json +0 -27
  29. package/fixtures/configs/monorepo-with-dependencies.json +0 -8
  30. package/fixtures/configs/monorepo-with-management-api-without-metrics.json +0 -21
  31. package/fixtures/configs/monorepo-with-management-api.json +0 -20
  32. package/fixtures/configs/monorepo-with-metrics.json +0 -32
  33. package/fixtures/configs/monorepo.json +0 -27
  34. package/fixtures/configs/no-schema.config.json +0 -18
  35. package/fixtures/configs/no-services.config.json +0 -5
  36. package/fixtures/configs/no-sources.config.json +0 -4
  37. package/fixtures/configs/service-throws-on-start.json +0 -11
  38. package/fixtures/configs/service-with-env-port.json +0 -32
  39. package/fixtures/configs/service-with-stdio.json +0 -12
  40. package/fixtures/configs/watch.json +0 -19
  41. package/fixtures/crash-on-bootstrap/platformatic.runtime.json +0 -15
  42. package/fixtures/crash-on-bootstrap/services/service-1/platformatic.service.json +0 -14
  43. package/fixtures/crash-on-bootstrap/services/service-1/plugin.js +0 -5
  44. package/fixtures/crash-on-bootstrap/services/service-2/platformatic.service.json +0 -14
  45. package/fixtures/crash-on-bootstrap/services/service-2/plugin.js +0 -5
  46. package/fixtures/dbApp/package.json +0 -5
  47. package/fixtures/dbApp/platformatic.db.json +0 -28
  48. package/fixtures/dbApp/plugin.js +0 -12
  49. package/fixtures/dbAppNoName/package.json +0 -4
  50. package/fixtures/dbAppNoName/platformatic.db.json +0 -27
  51. package/fixtures/dbAppNoName/plugin.js +0 -12
  52. package/fixtures/dbAppNoPackageJson/platformatic.db.json +0 -27
  53. package/fixtures/dbAppNoPackageJson/plugin.js +0 -12
  54. package/fixtures/dbAppWithMigrationError/migrations/001.do.sql +0 -4
  55. package/fixtures/dbAppWithMigrationError/migrations/001.undo.sql +0 -1
  56. package/fixtures/dbAppWithMigrationError/package.json +0 -5
  57. package/fixtures/dbAppWithMigrationError/platformatic.db.json +0 -28
  58. package/fixtures/dbAppWithMigrationError/plugin.js +0 -5
  59. package/fixtures/do-not-reload-dependencies/node_modules/foo/foo.js +0 -2
  60. package/fixtures/do-not-reload-dependencies/node_modules/foo/package.json +0 -3
  61. package/fixtures/do-not-reload-dependencies/node_modules/foom/foom.js +0 -1
  62. package/fixtures/do-not-reload-dependencies/node_modules/foom/package.json +0 -4
  63. package/fixtures/do-not-reload-dependencies/platformatic.service.json +0 -18
  64. package/fixtures/do-not-reload-dependencies/plugin.js +0 -14
  65. package/fixtures/do-not-restart-on-crash/platformatic.runtime.json +0 -15
  66. package/fixtures/do-not-restart-on-crash/services/a/platformatic.service.json +0 -16
  67. package/fixtures/do-not-restart-on-crash/services/a/plugin.js +0 -9
  68. package/fixtures/empty/hello.js +0 -7
  69. package/fixtures/express/platformatic.runtime.json +0 -21
  70. package/fixtures/express/services/a/platformatic.service.json +0 -14
  71. package/fixtures/express/services/a/plugin.js +0 -26
  72. package/fixtures/express/services/b/platformatic.service.json +0 -14
  73. package/fixtures/express/services/b/plugin.js +0 -19
  74. package/fixtures/external-client/openmeter.json +0 -420
  75. package/fixtures/external-client/platformatic.service.json +0 -13
  76. package/fixtures/interceptors/external.js +0 -27
  77. package/fixtures/interceptors/idp.js +0 -48
  78. package/fixtures/interceptors/platformatic.runtime.json +0 -27
  79. package/fixtures/interceptors/services/a/platformatic.service.json +0 -17
  80. package/fixtures/interceptors/services/a/plugin.js +0 -15
  81. package/fixtures/interceptors-2/platformatic.runtime.json +0 -25
  82. package/fixtures/interceptors-2/services/a/platformatic.service.json +0 -17
  83. package/fixtures/interceptors-2/services/a/plugin.js +0 -15
  84. package/fixtures/leven/.env.sample +0 -4
  85. package/fixtures/leven/platformatic.runtime.json +0 -11
  86. package/fixtures/leven/services/deeply-spittle/platformatic.service.json +0 -25
  87. package/fixtures/leven/services/deeply-spittle/plugins/example.js +0 -6
  88. package/fixtures/leven/services/deeply-spittle/routes/root.js +0 -8
  89. package/fixtures/leven/services/rainy-empire/platformatic.composer.json +0 -21
  90. package/fixtures/management-api/package.json +0 -4
  91. package/fixtures/management-api/platformatic.json +0 -22
  92. package/fixtures/management-api/services/service-1/platformatic.json +0 -15
  93. package/fixtures/management-api/services/service-1/plugin.js +0 -16
  94. package/fixtures/management-api/services/service-2/platformatic.json +0 -9
  95. package/fixtures/management-api/services/service-2/plugin.js +0 -8
  96. package/fixtures/management-api/services/service-db/migrations/001.do.sql +0 -4
  97. package/fixtures/management-api/services/service-db/migrations/001.undo.sql +0 -1
  98. package/fixtures/management-api/services/service-db/package.json +0 -5
  99. package/fixtures/management-api/services/service-db/platformatic.db.json +0 -29
  100. package/fixtures/management-api/services/service-db/plugin.js +0 -12
  101. package/fixtures/management-api-custom-labels/package.json +0 -4
  102. package/fixtures/management-api-custom-labels/platformatic.json +0 -22
  103. package/fixtures/management-api-custom-labels/services/service-1/platformatic.json +0 -12
  104. package/fixtures/management-api-custom-labels/services/service-1/plugin.js +0 -16
  105. package/fixtures/management-api-custom-labels/services/service-2/platformatic.json +0 -9
  106. package/fixtures/management-api-custom-labels/services/service-2/plugin.js +0 -8
  107. package/fixtures/management-api-custom-labels/services/service-db/migrations/001.do.sql +0 -4
  108. package/fixtures/management-api-custom-labels/services/service-db/migrations/001.undo.sql +0 -1
  109. package/fixtures/management-api-custom-labels/services/service-db/package.json +0 -5
  110. package/fixtures/management-api-custom-labels/services/service-db/platformatic.db.json +0 -29
  111. package/fixtures/management-api-custom-labels/services/service-db/plugin.js +0 -12
  112. package/fixtures/management-api-without-metrics/package.json +0 -4
  113. package/fixtures/management-api-without-metrics/platformatic.json +0 -14
  114. package/fixtures/management-api-without-metrics/services/service-1/platformatic.json +0 -8
  115. package/fixtures/monorepo/composerApp/external-service.json +0 -204
  116. package/fixtures/monorepo/composerApp/platformatic.composer.json +0 -46
  117. package/fixtures/monorepo/dbApp/platformatic.db.json +0 -16
  118. package/fixtures/monorepo/docs/README.md +0 -1
  119. package/fixtures/monorepo/serviceApp/deps/dep1.js +0 -7
  120. package/fixtures/monorepo/serviceApp/deps/dep2.mjs +0 -2
  121. package/fixtures/monorepo/serviceApp/deps/dep3.mjs +0 -2
  122. package/fixtures/monorepo/serviceApp/deps/dep4.js +0 -1
  123. package/fixtures/monorepo/serviceApp/platformatic.service.json +0 -23
  124. package/fixtures/monorepo/serviceApp/plugin.js +0 -29
  125. package/fixtures/monorepo/serviceApp/with-logger/package.json +0 -5
  126. package/fixtures/monorepo/serviceApp/with-logger/with-logger.cjs +0 -25
  127. package/fixtures/monorepo/serviceApp/with-logger/with-logger.d.ts +0 -38
  128. package/fixtures/monorepo/serviceApp/with-logger/with-logger.openapi.json +0 -22
  129. package/fixtures/monorepo/serviceAppWithLogger/platformatic.service.json +0 -20
  130. package/fixtures/monorepo/serviceAppWithLogger/plugin.js +0 -20
  131. package/fixtures/monorepo/serviceAppWithMultiplePlugins/platformatic.service.json +0 -28
  132. package/fixtures/monorepo/serviceAppWithMultiplePlugins/plugin.js +0 -8
  133. package/fixtures/monorepo/serviceAppWithMultiplePlugins/plugin2.mjs +0 -5
  134. package/fixtures/monorepo-missing-dependencies/composer/platformatic.json +0 -24
  135. package/fixtures/monorepo-openapi/serviceAppWithoutOpenapi/platformatic.service.json +0 -13
  136. package/fixtures/monorepo-openapi/serviceAppWithoutOpenapi/plugin.js +0 -8
  137. package/fixtures/monorepo-watch/service1/platformatic.service.json +0 -13
  138. package/fixtures/monorepo-watch/service1/plugin.js +0 -8
  139. package/fixtures/monorepo-with-dependencies/main/clients/service-1/package.json +0 -3
  140. package/fixtures/monorepo-with-dependencies/main/clients/service-1/schema.json +0 -204
  141. package/fixtures/monorepo-with-dependencies/main/clients/service-2/package.json +0 -3
  142. package/fixtures/monorepo-with-dependencies/main/clients/service-2/schema.json +0 -204
  143. package/fixtures/monorepo-with-dependencies/main/external-service.schema.json +0 -204
  144. package/fixtures/monorepo-with-dependencies/main/platformatic.json +0 -46
  145. package/fixtures/monorepo-with-dependencies/service-1/clients/service-2/package.json +0 -3
  146. package/fixtures/monorepo-with-dependencies/service-1/clients/service-2/schema.json +0 -204
  147. package/fixtures/monorepo-with-dependencies/service-1/external-service.schema.json +0 -204
  148. package/fixtures/monorepo-with-dependencies/service-1/platformatic.json +0 -29
  149. package/fixtures/monorepo-with-dependencies/service-2/platformatic.json +0 -15
  150. package/fixtures/no-env.service.json +0 -25
  151. package/fixtures/preload/platformatic.runtime.json +0 -15
  152. package/fixtures/preload/preload.js +0 -1
  153. package/fixtures/preload/services/a/platformatic.service.json +0 -14
  154. package/fixtures/preload/services/a/plugin.js +0 -7
  155. package/fixtures/prom-server/platformatic.json +0 -16
  156. package/fixtures/prom-server/services/service-1/platformatic.json +0 -13
  157. package/fixtures/prom-server/services/service-1/plugin.js +0 -8
  158. package/fixtures/prom-server/services/service-2/platformatic.json +0 -12
  159. package/fixtures/prom-server/services/service-2/plugin.js +0 -8
  160. package/fixtures/restart-on-crash/platformatic.runtime.json +0 -14
  161. package/fixtures/restart-on-crash/services/a/platformatic.service.json +0 -16
  162. package/fixtures/restart-on-crash/services/a/plugin.js +0 -9
  163. package/fixtures/sample-runtime/.env +0 -9
  164. package/fixtures/sample-runtime/package.json +0 -16
  165. package/fixtures/sample-runtime/platformatic.json +0 -18
  166. package/fixtures/sample-runtime/services/rival/package.json +0 -16
  167. package/fixtures/sample-runtime/services/rival/platformatic.json +0 -33
  168. package/fixtures/sample-runtime/services/rival/routes/root.js +0 -7
  169. package/fixtures/sample-runtime-with-2-services/.env +0 -10
  170. package/fixtures/sample-runtime-with-2-services/package.json +0 -16
  171. package/fixtures/sample-runtime-with-2-services/platformatic.json +0 -18
  172. package/fixtures/sample-runtime-with-2-services/services/foobar/package.json +0 -16
  173. package/fixtures/sample-runtime-with-2-services/services/foobar/platformatic.json +0 -18
  174. package/fixtures/sample-runtime-with-2-services/services/foobar/routes/root.js +0 -7
  175. package/fixtures/sample-runtime-with-2-services/services/rival/package.json +0 -16
  176. package/fixtures/sample-runtime-with-2-services/services/rival/platformatic.json +0 -33
  177. package/fixtures/sample-runtime-with-2-services/services/rival/routes/root.js +0 -7
  178. package/fixtures/server/logger-transport/custom-transport.js +0 -15
  179. package/fixtures/server/logger-transport/platformatic.runtime.json +0 -21
  180. package/fixtures/server/logger-transport/services/echo/platformatic.service.json +0 -12
  181. package/fixtures/server/logger-transport/services/echo/routes/hello.js +0 -6
  182. package/fixtures/server/overrides-service/platformatic.runtime.json +0 -18
  183. package/fixtures/server/overrides-service/services/echo/platformatic.service.json +0 -19
  184. package/fixtures/server/overrides-service/services/echo/routes/span.js +0 -8
  185. package/fixtures/server/runtime-server/platformatic.runtime.json +0 -18
  186. package/fixtures/server/runtime-server/services/echo/platformatic.service.json +0 -12
  187. package/fixtures/server/runtime-server/services/echo/routes/hello.js +0 -6
  188. package/fixtures/serviceAppThrowsOnStart/platformatic.service.json +0 -12
  189. package/fixtures/serviceAppThrowsOnStart/plugin.js +0 -6
  190. package/fixtures/stackables/node_modules/foo/foo.js +0 -62
  191. package/fixtures/stackables/node_modules/foo/package.json +0 -4
  192. package/fixtures/stackables/platformatic.json +0 -11
  193. package/fixtures/start-command-in-runtime.js +0 -24
  194. package/fixtures/start-command.js +0 -9
  195. package/fixtures/starter.js +0 -9
  196. package/fixtures/stdio/platformatic.service.json +0 -6
  197. package/fixtures/stdio/plugin.js +0 -24
  198. package/fixtures/telemetry/platformatic.runtime.json +0 -18
  199. package/fixtures/telemetry/services/echo/platformatic.service.json +0 -19
  200. package/fixtures/telemetry/services/echo/routes/span.js +0 -22
  201. package/fixtures/telemetry/services/service-1/platformatic.service.json +0 -19
  202. package/fixtures/telemetry/services/service-1/routes/echo.js +0 -7
  203. package/fixtures/typescript/.env +0 -4
  204. package/fixtures/typescript/platformatic.runtime.json +0 -11
  205. package/fixtures/typescript/services/composer/platformatic.composer.json +0 -28
  206. package/fixtures/typescript/services/movies/.env +0 -4
  207. package/fixtures/typescript/services/movies/global.d.ts +0 -23
  208. package/fixtures/typescript/services/movies/migrations/001.do.sql +0 -6
  209. package/fixtures/typescript/services/movies/migrations/001.undo.sql +0 -3
  210. package/fixtures/typescript/services/movies/platformatic.db.json +0 -33
  211. package/fixtures/typescript/services/movies/plugin.ts +0 -5
  212. package/fixtures/typescript/services/movies/tsconfig.json +0 -21
  213. package/fixtures/typescript/services/movies/types/Movie.d.ts +0 -9
  214. package/fixtures/typescript/services/movies/types/index.d.ts +0 -7
  215. package/fixtures/typescript/services/titles/client/client.d.ts +0 -141
  216. package/fixtures/typescript/services/titles/client/client.openapi.json +0 -630
  217. package/fixtures/typescript/services/titles/client/package.json +0 -4
  218. package/fixtures/typescript/services/titles/platformatic.service.json +0 -31
  219. package/fixtures/typescript/services/titles/plugins/example.ts +0 -6
  220. package/fixtures/typescript/services/titles/routes/root.ts +0 -21
  221. package/fixtures/typescript/services/titles/tsconfig.json +0 -21
  222. package/fixtures/typescript-custom-flags/.env +0 -4
  223. package/fixtures/typescript-custom-flags/platformatic.runtime.json +0 -11
  224. package/fixtures/typescript-custom-flags/services/composer/platformatic.composer.json +0 -28
  225. package/fixtures/typescript-custom-flags/services/movies/global.d.ts +0 -23
  226. package/fixtures/typescript-custom-flags/services/movies/migrations/001.do.sql +0 -6
  227. package/fixtures/typescript-custom-flags/services/movies/migrations/001.undo.sql +0 -3
  228. package/fixtures/typescript-custom-flags/services/movies/platformatic.db.json +0 -35
  229. package/fixtures/typescript-custom-flags/services/movies/plugin.ts +0 -5
  230. package/fixtures/typescript-custom-flags/services/movies/tsconfig.json +0 -20
  231. package/fixtures/typescript-custom-flags/services/movies/types/Movie.d.ts +0 -9
  232. package/fixtures/typescript-custom-flags/services/movies/types/index.d.ts +0 -7
  233. package/fixtures/typescript-custom-flags/services/titles/client/client.d.ts +0 -141
  234. package/fixtures/typescript-custom-flags/services/titles/client/client.openapi.json +0 -630
  235. package/fixtures/typescript-custom-flags/services/titles/client/package.json +0 -4
  236. package/fixtures/typescript-custom-flags/services/titles/platformatic.service.json +0 -33
  237. package/fixtures/typescript-custom-flags/services/titles/plugins/example.ts +0 -6
  238. package/fixtures/typescript-custom-flags/services/titles/routes/root.ts +0 -21
  239. package/fixtures/typescript-custom-flags/services/titles/tsconfig.json +0 -21
  240. package/fixtures/typescript-no-env/platformatic.runtime.json +0 -11
  241. package/fixtures/typescript-no-env/services/composer/platformatic.composer.json +0 -28
  242. package/fixtures/typescript-no-env/services/movies/global.d.ts +0 -23
  243. package/fixtures/typescript-no-env/services/movies/migrations/001.do.sql +0 -6
  244. package/fixtures/typescript-no-env/services/movies/migrations/001.undo.sql +0 -3
  245. package/fixtures/typescript-no-env/services/movies/platformatic.db.json +0 -33
  246. package/fixtures/typescript-no-env/services/movies/plugin.ts +0 -5
  247. package/fixtures/typescript-no-env/services/movies/tsconfig.json +0 -21
  248. package/fixtures/typescript-no-env/services/movies/types/Movie.d.ts +0 -9
  249. package/fixtures/typescript-no-env/services/movies/types/index.d.ts +0 -7
  250. package/fixtures/typescript-no-env/services/titles/client/client.d.ts +0 -141
  251. package/fixtures/typescript-no-env/services/titles/client/client.openapi.json +0 -630
  252. package/fixtures/typescript-no-env/services/titles/client/package.json +0 -4
  253. package/fixtures/typescript-no-env/services/titles/platformatic.service.json +0 -31
  254. package/fixtures/typescript-no-env/services/titles/plugins/example.ts +0 -6
  255. package/fixtures/typescript-no-env/services/titles/routes/root.ts +0 -21
  256. package/fixtures/typescript-no-env/services/titles/tsconfig.json +0 -21
@@ -1,33 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/service/1.52.0.json",
3
- "service": {
4
- "openapi": true
5
- },
6
- "watch": true,
7
- "plugins": {
8
- "paths": [
9
- {
10
- "path": "./plugins",
11
- "encapsulate": false
12
- },
13
- "./routes"
14
- ],
15
- "typescript": "{PLT_RIVAL_TYPESCRIPT}",
16
- "packages": [
17
- {
18
- "name": "@fastify/oauth2",
19
- "options": {
20
- "name": "{PLT_RIVAL_FST_PLUGIN_OAUTH2_NAME}",
21
- "credentials": {
22
- "client": {
23
- "id": "{PLT_RIVAL_FST_PLUGIN_OAUTH2_CREDENTIALS_CLIENT_ID}",
24
- "secret": "{PLT_RIVAL_FST_PLUGIN_OAUTH2_CREDENTIALS_CLIENT_SECRET}"
25
- }
26
- },
27
- "startRedirectPath": "{PLT_RIVAL_FST_PLUGIN_OAUTH2_REDIRECT_PATH}",
28
- "callbackUri": "{PLT_RIVAL_FST_PLUGIN_OAUTH2_CALLBACK_URI}"
29
- }
30
- }
31
- ]
32
- }
33
- }
@@ -1,7 +0,0 @@
1
- 'use strict'
2
-
3
- module.exports = async function (fastify, opts) {
4
- fastify.get('/', async function (request, reply) {
5
- return { hello: 'from root' }
6
- })
7
- }
@@ -1,15 +0,0 @@
1
- 'use strict'
2
-
3
- const build = require('pino-abstract-transport')
4
- const fs = require('fs')
5
- const path = require('path')
6
-
7
- module.exports = function (opts) {
8
- const dest = opts.path || path.join(process.cwd(), 'transport.log')
9
- return build(function (source) {
10
- source.on('data', function (obj) {
11
- obj.fromTransport = true
12
- fs.appendFileSync(dest, JSON.stringify(obj) + '\n')
13
- })
14
- })
15
- }
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
3
- "entrypoint": "echo",
4
- "watch": true,
5
- "autoload": {
6
- "path": "services",
7
- "exclude": [
8
- "docs"
9
- ]
10
- },
11
- "server": {
12
- "hostname": "127.0.0.1",
13
- "port": "14242",
14
- "logger": {
15
- "level": "info",
16
- "transport": {
17
- "target": "./custom-transport.js"
18
- }
19
- }
20
- }
21
- }
@@ -1,12 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/service/1.52.0.json",
3
- "service": {
4
- "openapi": true
5
- },
6
- "plugins": {
7
- "paths": [
8
- "./routes"
9
- ],
10
- "typescript": false
11
- }
12
- }
@@ -1,6 +0,0 @@
1
- 'use strict'
2
- module.exports = async function (fastify, opts) {
3
- fastify.get('/', async (request, reply) => {
4
- return { hello: 'world' }
5
- })
6
- }
@@ -1,18 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
3
- "entrypoint": "echo",
4
- "watch": true,
5
- "autoload": {
6
- "path": "services",
7
- "exclude": [
8
- "docs"
9
- ]
10
- },
11
- "server": {
12
- "hostname": "127.0.0.1",
13
- "port": "14242",
14
- "logger": {
15
- "level": "info"
16
- }
17
- }
18
- }
@@ -1,19 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/service/1.52.0.json",
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
- }
@@ -1,8 +0,0 @@
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
- }
@@ -1,18 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
3
- "entrypoint": "echo",
4
- "watch": true,
5
- "autoload": {
6
- "path": "services",
7
- "exclude": [
8
- "docs"
9
- ]
10
- },
11
- "server": {
12
- "hostname": "127.0.0.1",
13
- "port": "14242",
14
- "logger": {
15
- "level": "info"
16
- }
17
- }
18
- }
@@ -1,12 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/service/1.52.0.json",
3
- "service": {
4
- "openapi": true
5
- },
6
- "plugins": {
7
- "paths": [
8
- "./routes"
9
- ],
10
- "typescript": false
11
- }
12
- }
@@ -1,6 +0,0 @@
1
- 'use strict'
2
- module.exports = async function (fastify, opts) {
3
- fastify.get('/', async (request, reply) => {
4
- return { hello: 'world' }
5
- })
6
- }
@@ -1,12 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/service/1.52.0.json",
3
- "server": {
4
- "hostname": "127.0.0.1",
5
- "port": 0
6
- },
7
- "plugins": {
8
- "paths": [
9
- "plugin.js"
10
- ]
11
- }
12
- }
@@ -1,6 +0,0 @@
1
- 'use strict'
2
-
3
- /** @param {import('fastify').FastifyInstance} app */
4
- module.exports = async function (app) {
5
- throw new Error('boom')
6
- }
@@ -1,62 +0,0 @@
1
- 'use strict'
2
-
3
- const { schema, buildStackable } = require('@platformatic/service')
4
-
5
- /** @type {import('fastify').FastifyPluginAsync<{}>} */
6
- async function foo (app) {
7
- const text = app.platformatic.config.foo.text
8
- app.get('/foo', async (request, reply) => {
9
- return text
10
- })
11
- }
12
-
13
- foo.configType = 'foo'
14
- foo.schema = {
15
- $id: 'https://example.com/schemas/foo.json',
16
- title: 'Platformatic Service',
17
- type: 'object',
18
- properties: {
19
- server: schema.server,
20
- plugins: schema.plugins,
21
- metrics: schema.metrics,
22
- watch: {
23
- anyOf: [schema.watch, {
24
- type: 'boolean'
25
- }, {
26
- type: 'string'
27
- }]
28
- },
29
- $schema: {
30
- type: 'string'
31
- },
32
- module: {
33
- type: 'string'
34
- },
35
- foo: {
36
- type: 'object',
37
- properties: {
38
- text: {
39
- type: 'string'
40
- }
41
- },
42
- required: ['text']
43
- }
44
- },
45
- additionalProperties: false,
46
- required: ['server']
47
- }
48
-
49
- foo.configManagerConfig = {
50
- schema: foo.schema,
51
- envWhitelist: ['PORT', 'HOSTNAME'],
52
- allowToWatch: ['.env'],
53
- schemaOptions: {
54
- useDefaults: true,
55
- coerceTypes: true,
56
- allErrors: true,
57
- strict: false
58
- }
59
- }
60
- foo.buildStackable = (options) => buildStackable(options, foo)
61
-
62
- module.exports = foo
@@ -1,4 +0,0 @@
1
- {
2
- "name": "foo",
3
- "main": "foo.js"
4
- }
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://example.com/schemas/foo.json",
3
- "module": "foo",
4
- "server": {
5
- "port": 0,
6
- "hostname": "127.0.0.1"
7
- },
8
- "foo": {
9
- "text": "Hello World"
10
- }
11
- }
@@ -1,24 +0,0 @@
1
- 'use strict'
2
-
3
- const assert = require('node:assert')
4
- const { request, setGlobalDispatcher, Agent } = require('undici')
5
- const { startCommand } = require('..')
6
-
7
- setGlobalDispatcher(new Agent({
8
- keepAliveTimeout: 1,
9
- keepAliveMaxTimeout: 1,
10
- }))
11
-
12
- async function main () {
13
- const entrypoint = await startCommand(['-c', process.argv[2]])
14
- const endpoint = process.argv[3] ?? '/'
15
- const res = await request(entrypoint + endpoint)
16
-
17
- assert.strictEqual(res.statusCode, 200)
18
-
19
- // Consume the body so the service can end
20
- await res.body.text()
21
- process.exit(42)
22
- }
23
-
24
- main()
@@ -1,9 +0,0 @@
1
- 'use strict'
2
- const { startCommand } = require('..')
3
-
4
- async function main () {
5
- await startCommand(['-c', process.argv[2]])
6
- process.exit(42)
7
- }
8
-
9
- main()
@@ -1,9 +0,0 @@
1
- 'use strict'
2
- const { start } = require('..')
3
-
4
- async function main () {
5
- await start(['-c', process.argv[2]])
6
- process.exit(42)
7
- }
8
-
9
- main()
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/service/1.52.0.json",
3
- "plugins": {
4
- "paths": ["plugin.js"]
5
- }
6
- }
@@ -1,24 +0,0 @@
1
- 'use strict'
2
-
3
- const pino = require('pino')
4
-
5
- module.exports = async function foo (app) {
6
- app.log.info('This is an info')
7
- app.log.warn('This is a warn')
8
- app.log.warn('This is an error')
9
-
10
- app.get('/', async () => {
11
- console.log('This is a\n console.log')
12
- console.error('This is a\n console.error')
13
-
14
- console.log(JSON.stringify({ ts: '123', foo: 'bar' }))
15
- console.log('#'.repeat(1e4))
16
- console.log(Buffer.from(Array.from(Array(1e2)).map((_, i) => i)))
17
-
18
- const logger = pino({ level: 'trace' })
19
- logger.trace('This is a trace')
20
- logger.fatal({ payload: { ts: '123', foo: 'bar' } }, 'This is a fatal with object')
21
-
22
- return { ok: true }
23
- })
24
- }
@@ -1,18 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
3
- "entrypoint": "echo",
4
- "watch": true,
5
- "autoload": {
6
- "path": "services",
7
- "exclude": [
8
- "docs"
9
- ]
10
- },
11
- "telemetry": {
12
- "serviceName": "test-runtime",
13
- "version": "1.0.0",
14
- "exporter": {
15
- "type": "memory"
16
- }
17
- }
18
- }
@@ -1,19 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/service/1.52.0.json",
3
- "server": {
4
- "hostname": "127.0.0.1",
5
- "port": "0",
6
- "logger": {
7
- "level": "info"
8
- }
9
- },
10
- "service": {
11
- "openapi": true
12
- },
13
- "plugins": {
14
- "paths": [
15
- "./routes"
16
- ],
17
- "typescript": false
18
- }
19
- }
@@ -1,22 +0,0 @@
1
- 'use strict'
2
-
3
- const { request } = require('undici')
4
-
5
- module.exports = async function (fastify, opts) {
6
- // This returns the traceId set on the span by the service
7
- fastify.get('/', async (req, reply) => {
8
- const traceId = req.span.spanContext().traceId
9
- return { traceId }
10
- })
11
-
12
- fastify.get('/service-1/echo-headers', async (req, reply) => {
13
- const res = await request('http://service-1.plt.local/echo-headers', {
14
- method: 'GET',
15
- headers: {
16
- 'content-type': 'application/json',
17
- },
18
- })
19
- const body = await res.body.json()
20
- return body
21
- })
22
- }
@@ -1,19 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/service/1.52.0.json",
3
- "server": {
4
- "hostname": "127.0.0.1",
5
- "port": "0",
6
- "logger": {
7
- "level": "info"
8
- }
9
- },
10
- "service": {
11
- "openapi": true
12
- },
13
- "plugins": {
14
- "paths": [
15
- "./routes"
16
- ],
17
- "typescript": false
18
- }
19
- }
@@ -1,7 +0,0 @@
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('/echo-headers', async (request, reply) => {
5
- return { headers: request.headers }
6
- })
7
- }
@@ -1,4 +0,0 @@
1
- PLT_SERVER_HOSTNAME=127.0.0.1
2
- PORT=3001
3
- PLT_SERVER_LOGGER_LEVEL=info
4
- DATABASE_URL=sqlite://./db.sqlite
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/1.52.0.json",
3
- "entrypoint": "composer",
4
- "watch": true,
5
- "autoload": {
6
- "path": "services",
7
- "exclude": [
8
- "docs"
9
- ]
10
- }
11
- }
@@ -1,28 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/composer/1.52.0.json",
3
- "server": {
4
- "hostname": "{PLT_SERVER_HOSTNAME}",
5
- "port": "{PORT}",
6
- "logger": {
7
- "level": "{PLT_SERVER_LOGGER_LEVEL}"
8
- }
9
- },
10
- "composer": {
11
- "services": [
12
- {
13
- "id": "movies",
14
- "openapi": {
15
- "url": "/documentation/json"
16
- }
17
- },
18
- {
19
- "id": "titles",
20
- "openapi": {
21
- "url": "/documentation/json"
22
- }
23
- }
24
- ],
25
- "refreshTimeout": 1000
26
- },
27
- "watch": true
28
- }
@@ -1,4 +0,0 @@
1
- PLT_SERVER_HOSTNAME=127.0.0.1
2
- PORT=3001
3
- PLT_SERVER_LOGGER_LEVEL=info
4
- DATABASE_URL=sqlite://./db.sqlite
@@ -1,23 +0,0 @@
1
- import { Entity } from '@platformatic/sql-mapper'
2
- import { EntityTypes, Movie } from './types'
3
-
4
- declare module 'fastify' {
5
- interface FastifyInstance {
6
- getSchema<T extends 'Movie'>(schemaId: T): {
7
- $id: string,
8
- title: string,
9
- description: string,
10
- type: string,
11
- properties: {
12
- [x in keyof EntityTypes[T]]: { type: string, nullable?: boolean }
13
- },
14
- required: string[]
15
- };
16
- }
17
- }
18
-
19
- declare module '@platformatic/sql-mapper' {
20
- interface Entities {
21
- movie: Entity<Movie>,
22
- }
23
- }
@@ -1,6 +0,0 @@
1
-
2
- -- Add SQL in this file to create the database tables for your API
3
- CREATE TABLE IF NOT EXISTS movies (
4
- id INTEGER PRIMARY KEY,
5
- title TEXT NOT NULL
6
- );
@@ -1,3 +0,0 @@
1
-
2
- -- Add SQL in this file to drop the database tables
3
- DROP TABLE movies;
@@ -1,33 +0,0 @@
1
- {
2
- "$schema": "https://schemas.platformatic.dev/@platformatic/db/1.52.0.json",
3
- "server": {
4
- "hostname": "{PLT_SERVER_HOSTNAME}",
5
- "port": "{PORT}",
6
- "logger": {
7
- "level": "{PLT_SERVER_LOGGER_LEVEL}"
8
- }
9
- },
10
- "db": {
11
- "connectionString": "{DATABASE_URL}",
12
- "graphql": true,
13
- "openapi": true
14
- },
15
- "watch": {
16
- "ignore": [
17
- "*.sqlite",
18
- "*.sqlite-journal"
19
- ]
20
- },
21
- "migrations": {
22
- "dir": "migrations"
23
- },
24
- "plugins": {
25
- "paths": [
26
- "plugin.ts"
27
- ],
28
- "typescript": true
29
- },
30
- "types": {
31
- "autogenerate": true
32
- }
33
- }
@@ -1,5 +0,0 @@
1
- /// <reference path="./global.d.ts" />
2
- import { FastifyInstance } from 'fastify'
3
-
4
- export default async function (app: FastifyInstance) {
5
- }
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "esModuleInterop": true,
5
- "target": "es2019",
6
- "sourceMap": true,
7
- "pretty": true,
8
- "noEmitOnError": true,
9
- "outDir": "dist"
10
- },
11
- "watchOptions": {
12
- "watchFile": "fixedPollingInterval",
13
- "watchDirectory": "fixedPollingInterval",
14
- "fallbackPolling": "dynamicPriority",
15
- "synchronousWatchDirectory": true,
16
- "excludeDirectories": [
17
- "**/node_modules",
18
- "dist"
19
- ]
20
- }
21
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Movie
3
- * A Movie
4
- */
5
- declare interface Movie {
6
- id?: number;
7
- title: string;
8
- }
9
- export { Movie }
@@ -1,7 +0,0 @@
1
- import { Movie } from './Movie'
2
-
3
- interface EntityTypes {
4
- Movie: Movie
5
- }
6
-
7
- export { EntityTypes, Movie }