@platformatic/service 0.17.1 → 0.19.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 (57) hide show
  1. package/fixtures/hello/platformatic.service.json +3 -0
  2. package/fixtures/hello-client/hello/hello.cjs +21 -0
  3. package/fixtures/hello-client/hello/hello.d.ts +34 -0
  4. package/fixtures/hello-client/hello/hello.openapi.json +22 -0
  5. package/fixtures/hello-client/hello/package.json +5 -0
  6. package/fixtures/hello-client/platformatic.service.json +17 -0
  7. package/fixtures/hello-client/plugin.js +8 -0
  8. package/fixtures/hello-client-ts/dist/plugin.js +21 -0
  9. package/fixtures/hello-client-ts/dist/plugin.js.map +1 -0
  10. package/fixtures/hello-client-ts/hello/hello.cjs +21 -0
  11. package/fixtures/hello-client-ts/hello/hello.d.ts +34 -0
  12. package/fixtures/hello-client-ts/hello/hello.openapi.json +22 -0
  13. package/fixtures/hello-client-ts/hello/package.json +5 -0
  14. package/fixtures/hello-client-ts/platformatic.service.json +18 -0
  15. package/fixtures/hello-client-ts/plugin.ts +8 -0
  16. package/fixtures/hello-client-ts/tsconfig.json +22 -0
  17. package/help/schema.txt +1 -1
  18. package/index.d.ts +18 -0
  19. package/index.js +57 -2
  20. package/index.test-d.ts +27 -0
  21. package/lib/compile.js +2 -2
  22. package/lib/config.js +0 -22
  23. package/lib/graphql.js +21 -0
  24. package/lib/load-config.js +6 -1
  25. package/lib/openapi-schema-defs.js +1140 -0
  26. package/lib/openapi.js +42 -0
  27. package/lib/schema.js +334 -27
  28. package/lib/utils.js +12 -1
  29. package/package.json +16 -6
  30. package/service.mjs +0 -0
  31. package/test/cli/compile.test.mjs +55 -33
  32. package/test/cli/gen-schema.test.mjs +1 -2
  33. package/test/cli/watch.test.mjs +13 -6
  34. package/test/clients.test.js +59 -0
  35. package/test/config.test.js +2 -1
  36. package/test/fixtures/bad-typescript-plugin/dist/tsconfig.tsbuildinfo +1 -1
  37. package/test/fixtures/hello-world-resolver.js +16 -0
  38. package/test/fixtures/typescript-autoload/platformatic.service.json +13 -0
  39. package/test/fixtures/typescript-autoload/routes/plugin.ts +5 -0
  40. package/test/fixtures/typescript-autoload/tsconfig.json +22 -0
  41. package/test/graphql.test.js +154 -0
  42. package/test/helper.js +1 -2
  43. package/test/https.test.js +58 -0
  44. package/test/routes.test.js +123 -5
  45. package/test/tmp/typescript-plugin-clone-3/dist/tsconfig.tsbuildinfo +1 -1
  46. package/test/tmp/typescript-plugin-clone-4/dist/tsconfig.tsbuildinfo +1 -1
  47. package/test/tmp/typescript-plugin-clone-7/inner-folder/dist/plugin.js +18 -0
  48. package/test/tmp/typescript-plugin-clone-7/inner-folder/dist/plugin.js.map +1 -0
  49. package/test/tmp/typescript-plugin-clone-7/inner-folder/platformatic.service.json +13 -0
  50. package/test/tmp/typescript-plugin-clone-7/inner-folder/plugin.ts +5 -0
  51. package/test/tmp/typescript-plugin-clone-7/inner-folder/tsconfig.json +22 -0
  52. package/test/tmp/typescript-plugin-clone-8/dist/routes/plugin.js +7 -0
  53. package/test/tmp/typescript-plugin-clone-8/dist/routes/plugin.js.map +1 -0
  54. package/test/tmp/typescript-plugin-clone-8/dist/tsconfig.tsbuildinfo +1 -0
  55. package/test/tmp/typescript-plugin-clone-8/platformatic.service.json +13 -0
  56. package/test/tmp/typescript-plugin-clone-8/routes/plugin.ts +5 -0
  57. package/test/tmp/typescript-plugin-clone-8/tsconfig.json +22 -0
@@ -9,5 +9,8 @@
9
9
  "plugins": {
10
10
  "paths": ["./plugin.js"]
11
11
  },
12
+ "service": {
13
+ "openapi": true
14
+ },
12
15
  "metrics": false
13
16
  }
@@ -0,0 +1,21 @@
1
+ 'use strict'
2
+
3
+ const pltClient = require('@platformatic/client')
4
+ const { join } = require('path')
5
+
6
+ async function generateHelloClientPlugin (app, opts) {
7
+ app.register(pltClient, {
8
+ type: 'openapi',
9
+ name: 'hello',
10
+ path: join(__dirname, 'hello.openapi.json'),
11
+ url: opts.url
12
+ })
13
+ }
14
+
15
+ generateHelloClientPlugin[Symbol.for('plugin-meta')] = {
16
+ name: 'hello OpenAPI Client'
17
+ }
18
+ generateHelloClientPlugin[Symbol.for('skip-override')] = true
19
+
20
+ module.exports = generateHelloClientPlugin
21
+ module.exports.default = generateHelloClientPlugin
@@ -0,0 +1,34 @@
1
+ import { FastifyPluginAsync } from 'fastify'
2
+
3
+ interface GetRequest {
4
+ }
5
+
6
+ interface GetResponse {
7
+ }
8
+
9
+ interface Hello {
10
+ get(req: GetRequest): Promise<GetResponse>;
11
+ }
12
+
13
+ type HelloPlugin = FastifyPluginAsync<NonNullable<hello.HelloOptions>>
14
+
15
+ declare module 'fastify' {
16
+ interface FastifyInstance {
17
+ 'hello': Hello;
18
+ }
19
+
20
+ interface FastifyRequest {
21
+ 'hello': Hello;
22
+ }
23
+ }
24
+
25
+ declare namespace hello {
26
+ export interface HelloOptions {
27
+ url: string
28
+ }
29
+ export const hello: HelloPlugin;
30
+ export { hello as default };
31
+ }
32
+
33
+ declare function hello(...params: Parameters<HelloPlugin>): ReturnType<HelloPlugin>;
34
+ export = hello;
@@ -0,0 +1,22 @@
1
+ {
2
+ "openapi": "3.0.3",
3
+ "info": {
4
+ "title": "Platformatic",
5
+ "description": "This is a service built on top of Platformatic",
6
+ "version": "1.0.0"
7
+ },
8
+ "components": {
9
+ "schemas": {}
10
+ },
11
+ "paths": {
12
+ "/": {
13
+ "get": {
14
+ "responses": {
15
+ "200": {
16
+ "description": "Default Response"
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "hello",
3
+ "main": "./hello.cjs",
4
+ "types": "./hello.d.ts"
5
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "server": {
3
+ "hostname": "127.0.0.1",
4
+ "port": 0,
5
+ "logger": {
6
+ "level": "info"
7
+ }
8
+ },
9
+ "plugins": {
10
+ "paths": ["./plugin.js"]
11
+ },
12
+ "clients": [{
13
+ "path": "./hello",
14
+ "url": "{PLT_CLIENT_URL}"
15
+ }],
16
+ "metrics": false
17
+ }
@@ -0,0 +1,8 @@
1
+ 'use default'
2
+
3
+ /** @type {import('fastify').FastifyPluginAsync<{ optionA: boolean, optionB: string }>} */
4
+ module.exports = async function (app) {
5
+ app.get('/', async () => {
6
+ return app.hello.get()
7
+ })
8
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ /// <reference path="./hello" />
13
+ function default_1(app) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ app.get('/', () => __awaiter(this, void 0, void 0, function* () {
16
+ return app.hello.get({});
17
+ }));
18
+ });
19
+ }
20
+ exports.default = default_1;
21
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../plugin.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,gCAAgC;AAEhC,mBAA+B,GAAoB;;QACjD,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAS,EAAE;YACtB,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC1B,CAAC,CAAA,CAAC,CAAA;IACJ,CAAC;CAAA;AAJD,4BAIC"}
@@ -0,0 +1,21 @@
1
+ 'use strict'
2
+
3
+ const pltClient = require('@platformatic/client')
4
+ const { join } = require('path')
5
+
6
+ async function generateHelloClientPlugin (app, opts) {
7
+ app.register(pltClient, {
8
+ type: 'openapi',
9
+ name: 'hello',
10
+ path: join(__dirname, 'hello.openapi.json'),
11
+ url: opts.url
12
+ })
13
+ }
14
+
15
+ generateHelloClientPlugin[Symbol.for('plugin-meta')] = {
16
+ name: 'hello OpenAPI Client'
17
+ }
18
+ generateHelloClientPlugin[Symbol.for('skip-override')] = true
19
+
20
+ module.exports = generateHelloClientPlugin
21
+ module.exports.default = generateHelloClientPlugin
@@ -0,0 +1,34 @@
1
+ import { FastifyPluginAsync } from 'fastify'
2
+
3
+ interface GetRequest {
4
+ }
5
+
6
+ interface GetResponse {
7
+ }
8
+
9
+ interface Hello {
10
+ get(req: GetRequest): Promise<GetResponse>;
11
+ }
12
+
13
+ type HelloPlugin = FastifyPluginAsync<NonNullable<hello.HelloOptions>>
14
+
15
+ declare module 'fastify' {
16
+ interface FastifyInstance {
17
+ 'hello': Hello;
18
+ }
19
+
20
+ interface FastifyRequest {
21
+ 'hello': Hello;
22
+ }
23
+ }
24
+
25
+ declare namespace hello {
26
+ export interface HelloOptions {
27
+ url: string
28
+ }
29
+ export const hello: HelloPlugin;
30
+ export { hello as default };
31
+ }
32
+
33
+ declare function hello(...params: Parameters<HelloPlugin>): ReturnType<HelloPlugin>;
34
+ export = hello;
@@ -0,0 +1,22 @@
1
+ {
2
+ "openapi": "3.0.3",
3
+ "info": {
4
+ "title": "Platformatic",
5
+ "description": "This is a service built on top of Platformatic",
6
+ "version": "1.0.0"
7
+ },
8
+ "components": {
9
+ "schemas": {}
10
+ },
11
+ "paths": {
12
+ "/": {
13
+ "get": {
14
+ "responses": {
15
+ "200": {
16
+ "description": "Default Response"
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "hello",
3
+ "main": "./hello.cjs",
4
+ "types": "./hello.d.ts"
5
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "server": {
3
+ "hostname": "127.0.0.1",
4
+ "port": 0,
5
+ "logger": {
6
+ "level": "info"
7
+ }
8
+ },
9
+ "plugins": {
10
+ "paths": ["./plugin.ts"],
11
+ "typescript": true
12
+ },
13
+ "clients": [{
14
+ "path": "./hello",
15
+ "url": "{PLT_CLIENT_URL}"
16
+ }],
17
+ "metrics": false
18
+ }
@@ -0,0 +1,8 @@
1
+ import { FastifyInstance } from 'fastify'
2
+ /// <reference path="./hello" />
3
+
4
+ export default async function (app: FastifyInstance) {
5
+ app.get('/', async () => {
6
+ return app.hello.get({})
7
+ })
8
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "esModuleInterop": true,
5
+ "target": "es6",
6
+ "moduleResolution": "node",
7
+ "sourceMap": true,
8
+ "pretty": true,
9
+ "noEmitOnError": true,
10
+ "outDir": "dist"
11
+ },
12
+ "watchOptions": {
13
+ "watchFile": "fixedPollingInterval",
14
+ "watchDirectory": "fixedPollingInterval",
15
+ "fallbackPolling": "dynamicPriority",
16
+ "synchronousWatchDirectory": true,
17
+ "excludeDirectories": [
18
+ "**/node_modules",
19
+ "dist"
20
+ ]
21
+ }
22
+ }
package/help/schema.txt CHANGED
@@ -3,7 +3,7 @@ Update the config schema file:
3
3
  * `schema config` - update the JSON schema config available on `platformatic.service.schema.json`
4
4
 
5
5
  Your configuration on `platformatic.service.json` has a schema defined to improve the developer experience and avoid mistakes when updating the configuration of Platformatic Service.
6
- When you run `platformatic service init`, a new JSON `$schema` property is added in `platformatic.service.json`. This can allow your IDE to add suggestions (f.e. mandatory/missing fields, types, default values) by opening the config in `platformatic.service.json`.
6
+ When you initialize a new Platformatic service (f.e. running `npm create platformatic@latest`), a new JSON `$schema` property is added in the `platformatic.service.json` config. This can allow your IDE to add suggestions (f.e. mandatory/missing fields, types, default values) by opening the config in `platformatic.service.json`.
7
7
  Running `platformatic service schema config` you can update your schema so that it matches well the latest changes available on your config.
8
8
 
9
9
 
package/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { FastifyInstance, InjectOptions, LightMyRequestResponse } from "fastify"
2
+
3
+ export type pltServiceHandlerBuildServer = {
4
+ app: FastifyInstance
5
+ address: string
6
+ port: number
7
+ restart: () => Promise<void>
8
+ listen: () => Promise<{
9
+ address: string
10
+ port: number
11
+ }>
12
+ stop: () => Promise<void>
13
+ inject: (opts: InjectOptions | string) => Promise<LightMyRequestResponse>
14
+ }
15
+
16
+ declare module '@platformatic/service' {
17
+ export function buildServer(opts: object, app?: object, ConfigManagerContructor?: object): Promise<pltServiceHandlerBuildServer>
18
+ }
package/index.js CHANGED
@@ -12,6 +12,8 @@ const compiler = require('./lib/compile')
12
12
  const { join, dirname, resolve } = require('path')
13
13
  const { readFile } = require('fs/promises')
14
14
  const wrapperPath = join(__dirname, 'lib', 'sandbox-wrapper.js')
15
+ const setupOpenAPI = require('./lib/openapi.js')
16
+ const setupGraphQL = require('./lib/graphql.js')
15
17
 
16
18
  function createServerConfig (config) {
17
19
  // convert the config file to a new structure
@@ -49,6 +51,7 @@ async function platformaticService (app, opts, toLoad = []) {
49
51
  {
50
52
  const fileWatcher = opts.fileWatcher
51
53
  const configManager = opts.configManager
54
+ /* c8 ignore next 3 */
52
55
  if (fileWatcher !== undefined) {
53
56
  app.platformatic.fileWatcher = fileWatcher
54
57
  }
@@ -58,9 +61,31 @@ async function platformaticService (app, opts, toLoad = []) {
58
61
  }
59
62
  }
60
63
 
64
+ {
65
+ const serviceConfig = app.platformatic.config?.service
66
+
67
+ // for some unknown reason, c8 is not detecting any of this
68
+ // despite being covered by test/routes.test.js
69
+ /* c8 ignore next 3 */
70
+ if (serviceConfig?.openapi) {
71
+ await setupOpenAPI(app, app.platformatic.config?.service?.openapi)
72
+ }
73
+
74
+ /* c8 ignore next 3 */
75
+ if (serviceConfig?.graphql) {
76
+ await setupGraphQL(app, app.platformatic.config?.service?.graphql)
77
+ }
78
+ }
79
+
80
+ for (const plugin of (app.platformatic.config.clients || [])) {
81
+ app.register(require(plugin.path), {
82
+ url: plugin.url
83
+ })
84
+ }
85
+
61
86
  if (opts.plugins) {
62
87
  // if we don't have a fullPath, let's assume we are in a test and we can use the current working directory
63
- const configPath = app.platformatic.configManager.fullPath || process.cwd()
88
+ const configPath = app.platformatic.configManager.fullPath || join(process.cwd(), 'platformatic.db.json')
64
89
  const tsConfigPath = join(dirname(configPath), 'tsconfig.json')
65
90
  /* c8 ignore next 21 */
66
91
  if (await isFileAccessible(tsConfigPath)) {
@@ -125,6 +150,7 @@ async function platformaticService (app, opts, toLoad = []) {
125
150
 
126
151
  app.register(require('@fastify/cors'), opts.cors)
127
152
  }
153
+
128
154
  if (isKeyEnabled('healthCheck', opts)) {
129
155
  app.register(underPressure, {
130
156
  exposeStatusRoute: '/status',
@@ -173,6 +199,24 @@ function adjustConfigAfterMerge (options, stash) {
173
199
  }
174
200
  }
175
201
 
202
+ async function adjustHttpsKeyAndCert (arg) {
203
+ if (typeof arg === 'string') {
204
+ return arg
205
+ }
206
+
207
+ if (!Array.isArray(arg)) {
208
+ // { path: pathToKeyOrCert }
209
+ return readFile(arg.path)
210
+ }
211
+
212
+ // Array of strings or objects.
213
+ for (let i = 0; i < arg.length; ++i) {
214
+ arg[i] = await adjustHttpsKeyAndCert(arg[i])
215
+ }
216
+
217
+ return arg
218
+ }
219
+
176
220
  async function buildServer (options, app, ConfigManagerContructor) {
177
221
  app = app || platformaticService
178
222
  ConfigManagerContructor = ConfigManagerContructor || ConfigManager
@@ -188,6 +232,16 @@ async function buildServer (options, app, ConfigManagerContructor) {
188
232
  options = deepmerge({}, options, cm.current)
189
233
  options.configManager = cm
190
234
  adjustConfigAfterMerge(options, stash)
235
+
236
+ if (options.server.https) {
237
+ options.server.https.key = await adjustHttpsKeyAndCert(options.server.https.key)
238
+ options.server.https.cert = await adjustHttpsKeyAndCert(options.server.https.cert)
239
+ options.server = { ...options.server, ...options.server.https }
240
+ delete options.server.https
241
+ options.server.protocol = 'https'
242
+ } else {
243
+ options.server.protocol = 'http'
244
+ }
191
245
  }
192
246
  const serverConfig = createServerConfig(options)
193
247
 
@@ -197,9 +251,10 @@ async function buildServer (options, app, ConfigManagerContructor) {
197
251
 
198
252
  Object.defineProperty(handler, 'url', {
199
253
  get () {
254
+ const protocol = serverConfig.protocol
200
255
  const address = handler.address
201
256
  const port = handler.port
202
- const url = `http://${address}:${port}`
257
+ const url = `${protocol}://${address}:${port}`
203
258
  return url
204
259
  }
205
260
  })
@@ -0,0 +1,27 @@
1
+ import { expectError, expectType } from 'tsd';
2
+ import {
3
+ FastifyInstance,
4
+ LightMyRequestResponse,
5
+ } from 'fastify';
6
+ import { pltServiceHandlerBuildServer } from '.';
7
+
8
+ const server: pltServiceHandlerBuildServer = {
9
+ app: {} as FastifyInstance,
10
+ address: 'localhost',
11
+ port: 3000,
12
+ restart: async () => {},
13
+ listen: async () => ({ address: 'localhost', port: 3000 }),
14
+ stop: async () => {},
15
+ inject: async () => ({} as LightMyRequestResponse),
16
+ };
17
+
18
+ expectType<pltServiceHandlerBuildServer>(server);
19
+ expectError<pltServiceHandlerBuildServer>({...server, app: 'WRONG' });
20
+ expectError<pltServiceHandlerBuildServer>({...server, address: 42 });
21
+ expectError<pltServiceHandlerBuildServer>({...server, port: 'WRONG' });
22
+ expectError<pltServiceHandlerBuildServer>({...server, restart: 'WRONG' });
23
+ expectError<pltServiceHandlerBuildServer>({...server, listen: 'WRONG' });
24
+ expectError<pltServiceHandlerBuildServer>({...server, listen: async () => ({ address: 42, port: 3000 }), });
25
+ expectError<pltServiceHandlerBuildServer>({...server, listen: async () => ({ address: 'localhost', port: 'WRONG' }), });
26
+ expectError<pltServiceHandlerBuildServer>({...server, stop: 'WRONG' });
27
+ expectError<pltServiceHandlerBuildServer>({...server, inject: 'WRONG' });
package/lib/compile.js CHANGED
@@ -64,7 +64,7 @@ async function compile (cwd) {
64
64
  }
65
65
 
66
66
  try {
67
- await execa(tscExecutablePath, ['--project', 'tsconfig.json'], { cwd })
67
+ await execa(tscExecutablePath, ['--project', 'tsconfig.json', '--rootDir', '.'], { cwd })
68
68
  logger.info('Typescript compilation completed successfully.')
69
69
  return true
70
70
  } catch (error) {
@@ -83,7 +83,7 @@ async function compileWatch (cwd) {
83
83
  }
84
84
 
85
85
  try {
86
- await execa(tscExecutablePath, ['--project', 'tsconfig.json', '--incremental'], { cwd })
86
+ await execa(tscExecutablePath, ['--project', 'tsconfig.json', '--incremental', '--rootDir', '.'], { cwd })
87
87
  logger.info('Typescript compilation completed successfully. Starting watch mode.')
88
88
  } catch (error) {
89
89
  throw new Error('Failed to compile typescript files: ' + error)
package/lib/config.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  const ConfigManager = require('@platformatic/config')
4
- const { resolve } = require('path')
5
4
  const { schema } = require('./schema')
6
5
 
7
6
  class ServiceConfigManager extends ConfigManager {
@@ -19,27 +18,6 @@ class ServiceConfigManager extends ConfigManager {
19
18
  envWhitelist: ['PORT', ...(opts.envWhitelist || [])]
20
19
  })
21
20
  }
22
-
23
- _transformConfig () {
24
- const fixPluginPath = (plugin) => {
25
- // for some reasons c8 does not detect these
26
- /* c8 ignore next 3 */
27
- if (typeof plugin === 'string') {
28
- plugin = { path: plugin }
29
- }
30
- plugin.path = this._fixRelativePath(plugin.path)
31
- return plugin
32
- }
33
-
34
- // relative-to-absolute plugin path
35
- if (this.current.plugins?.paths) {
36
- this.current.plugins.paths = this.current.plugins.paths.map(fixPluginPath)
37
- }
38
- }
39
-
40
- _fixRelativePath (path) {
41
- return resolve(this.dirname, path)
42
- }
43
21
  }
44
22
 
45
23
  module.exports = ServiceConfigManager
package/lib/graphql.js ADDED
@@ -0,0 +1,21 @@
1
+ 'use strict'
2
+
3
+ const mercurius = require('mercurius')
4
+ const deepmerge = require('@fastify/deepmerge')({ all: true })
5
+ const fp = require('fastify-plugin')
6
+
7
+ // For some unknown reason, c8 is not detecting any of this
8
+ // despite being covered by test/graphql.test.js
9
+ /* c8 ignore next 12 */
10
+ async function setupGraphQL (app, opts) {
11
+ if (typeof opts !== 'object') {
12
+ opts = {}
13
+ }
14
+ const graphqlOptions = deepmerge({
15
+ graphiql: true
16
+ }, opts)
17
+
18
+ app.register(mercurius, graphqlOptions)
19
+ }
20
+
21
+ module.exports = fp(setupGraphQL)
@@ -37,7 +37,12 @@ async function loadConfig (minimistConfig, _args, configOpts = {}, Manager = Con
37
37
  }
38
38
  await access(args.config)
39
39
  } catch (err) {
40
- console.error('Missing config file')
40
+ console.error(`
41
+ Missing config file!
42
+ Be sure to have a config file with one of the following names: ${ourConfigFiles.join('\n')}
43
+ In alternative run "npm create platformatic@latest" to generate a basic plt service config.
44
+ Error: ${err}
45
+ `)
41
46
  process.exit(1)
42
47
  }
43
48