@platformatic/sql-mapper 0.21.0 → 0.22.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/mapper.js +5 -1
- package/package.json +3 -3
- package/test/mapper.test.js +13 -0
package/mapper.js
CHANGED
|
@@ -171,7 +171,11 @@ async function sqlMapper (app, opts) {
|
|
|
171
171
|
app.onClose(() => mapper.db.dispose())
|
|
172
172
|
// TODO this would need to be refactored as other plugins
|
|
173
173
|
// would need to use this same namespace
|
|
174
|
-
app.
|
|
174
|
+
if (app.hasDecorator('platformatic')) {
|
|
175
|
+
Object.assign(app.platformatic, mapper)
|
|
176
|
+
} else {
|
|
177
|
+
app.decorate('platformatic', mapper)
|
|
178
|
+
}
|
|
175
179
|
|
|
176
180
|
app.decorateRequest('platformaticContext', null)
|
|
177
181
|
app.addHook('onRequest', function (req, reply, done) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/sql-mapper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "A data mapper utility for SQL databases",
|
|
5
5
|
"main": "mapper.js",
|
|
6
6
|
"repository": {
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"fastify": "^4.
|
|
17
|
+
"fastify": "^4.17.0",
|
|
18
18
|
"snazzy": "^9.0.0",
|
|
19
19
|
"standard": "^17.0.0",
|
|
20
20
|
"tap": "^16.3.4",
|
|
21
|
-
"tsd": "^0.28.
|
|
21
|
+
"tsd": "^0.28.1"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@databases/mysql": "^5.2.1",
|
package/test/mapper.test.js
CHANGED
|
@@ -221,3 +221,16 @@ test('platformaticContext', async ({ plan, equal, teardown }) => {
|
|
|
221
221
|
const res = await app.inject('/')
|
|
222
222
|
equal(res.statusCode, 200)
|
|
223
223
|
})
|
|
224
|
+
|
|
225
|
+
test('platformatic decorator already present', async ({ teardown }) => {
|
|
226
|
+
async function onDatabaseLoad (db, sql) {
|
|
227
|
+
}
|
|
228
|
+
const app = fastify()
|
|
229
|
+
app.decorate('platformatic', {})
|
|
230
|
+
teardown(() => app.close())
|
|
231
|
+
app.register(plugin, {
|
|
232
|
+
connectionString: connInfo.connectionString,
|
|
233
|
+
onDatabaseLoad
|
|
234
|
+
})
|
|
235
|
+
await app.ready()
|
|
236
|
+
})
|