@platformatic/db-core 1.4.0 → 1.5.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.
- package/index.js +47 -1
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -24,7 +24,7 @@ module.exports = fp(async function (app, opts) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function registerAndConfig ({ module, configKey }) {
|
|
27
|
-
if (opts
|
|
27
|
+
if (shouldRegister(opts, configKey)) {
|
|
28
28
|
const sqlModule = require(module)
|
|
29
29
|
const config = typeof opts[configKey] === 'object' ? opts[configKey] : {}
|
|
30
30
|
return app.register(sqlModule, {
|
|
@@ -34,4 +34,50 @@ module.exports = fp(async function (app, opts) {
|
|
|
34
34
|
}
|
|
35
35
|
})
|
|
36
36
|
|
|
37
|
+
function shouldRegister (opts, configKey) {
|
|
38
|
+
const enabledKey = 'enabled'
|
|
39
|
+
const config = opts[configKey]
|
|
40
|
+
|
|
41
|
+
// If config is not defined or set to true, default is to register.
|
|
42
|
+
// For example, in addition to `openapi` and `graphql, the `events` config
|
|
43
|
+
// also would be registered since it's not provided.
|
|
44
|
+
//
|
|
45
|
+
// {
|
|
46
|
+
// "openapi": true,
|
|
47
|
+
// "graphql": true
|
|
48
|
+
// }
|
|
49
|
+
if (config === undefined || config === true) {
|
|
50
|
+
return true
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// If the top-level key is false or the enabled key is set to false,
|
|
54
|
+
// do not register.
|
|
55
|
+
//
|
|
56
|
+
// {
|
|
57
|
+
// "openapi": false,
|
|
58
|
+
// "graphql": {
|
|
59
|
+
// "enabled": false
|
|
60
|
+
// },
|
|
61
|
+
// }
|
|
62
|
+
if (config === false || opts[configKey][enabledKey] === false) {
|
|
63
|
+
return false
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (config === 'false' || opts[configKey][enabledKey] === 'false') {
|
|
67
|
+
return false
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// For everything else, register away!
|
|
71
|
+
// {
|
|
72
|
+
// "graphql": {},
|
|
73
|
+
// "openapi": {
|
|
74
|
+
// "enabled": true
|
|
75
|
+
// },
|
|
76
|
+
// "events": {
|
|
77
|
+
// "enabled": "{PLT_EVENTS_ENABLED}"
|
|
78
|
+
// }
|
|
79
|
+
// }
|
|
80
|
+
return true
|
|
81
|
+
}
|
|
82
|
+
|
|
37
83
|
module.exports.connect = sqlMapper.connect
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/db-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"fastify-plugin": "^4.5.1",
|
|
25
|
-
"@platformatic/sql-events": "1.
|
|
26
|
-
"@platformatic/sql-graphql": "1.
|
|
27
|
-
"@platformatic/sql-mapper": "1.
|
|
28
|
-
"@platformatic/sql-openapi": "1.
|
|
25
|
+
"@platformatic/sql-events": "1.5.0",
|
|
26
|
+
"@platformatic/sql-graphql": "1.5.0",
|
|
27
|
+
"@platformatic/sql-mapper": "1.5.0",
|
|
28
|
+
"@platformatic/sql-openapi": "1.5.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"test": "standard | snazzy && tap test/*test.js",
|