@kravc/dos 1.9.4 → 1.10.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/package.json +1 -2
- package/src/Document.js +6 -0
- package/src/Service.js +2 -2
- package/src/helpers/createContext.js +7 -4
- package/src/helpers/handler.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kravc/dos",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Convention-based, easy-to-use library for building API-driven serverless services.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Service",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"Lambda Function"
|
|
13
13
|
],
|
|
14
14
|
"main": "src/index.js",
|
|
15
|
-
"types": "src/index.d.ts",
|
|
16
15
|
"repository": {
|
|
17
16
|
"type": "git",
|
|
18
17
|
"url": "http://github.com/alexkravets/dos.git"
|
package/src/Document.js
CHANGED
|
@@ -136,6 +136,8 @@ class Document extends Component {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
static async read(context, query, options) {
|
|
139
|
+
this._extendWithPartition(context, query)
|
|
140
|
+
|
|
139
141
|
const item = await this._read(query, options)
|
|
140
142
|
|
|
141
143
|
if (!item) {
|
|
@@ -197,6 +199,8 @@ class Document extends Component {
|
|
|
197
199
|
originalDocument = await this.read(context, query)
|
|
198
200
|
}
|
|
199
201
|
|
|
202
|
+
this._extendWithPartition(context, query)
|
|
203
|
+
|
|
200
204
|
const updatedItem = await this._update(query, mutation)
|
|
201
205
|
|
|
202
206
|
const document = new this(context, updatedItem)
|
|
@@ -232,6 +236,8 @@ class Document extends Component {
|
|
|
232
236
|
context so can be referenced in the after action helper */
|
|
233
237
|
const originalDocument = await this.read(context, query)
|
|
234
238
|
|
|
239
|
+
this._extendWithPartition(context, query)
|
|
240
|
+
|
|
235
241
|
await this._delete(query)
|
|
236
242
|
|
|
237
243
|
if (this.afterDelete) {
|
package/src/Service.js
CHANGED
|
@@ -104,8 +104,8 @@ class Service {
|
|
|
104
104
|
return get(this._spec.paths, `${httpPath}.${httpMethod}.operationId`, 'NONE')
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
handler(request,
|
|
108
|
-
return handler(this)(request,
|
|
107
|
+
handler(request, extraContext) {
|
|
108
|
+
return handler(this)(request, extraContext)
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
async process(context) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
const { parse } = require('url')
|
|
3
|
+
const { parse } = require('url')
|
|
5
4
|
const { v4: uuid } = require('uuid')
|
|
5
|
+
const { get, isString } = require('lodash')
|
|
6
|
+
|
|
7
|
+
const createContext = (service, request, extraContext = {}) => {
|
|
8
|
+
const { logger = console } = extraContext
|
|
6
9
|
|
|
7
|
-
const createContext = (service, request, logger = console) => {
|
|
8
10
|
let httpPath
|
|
9
11
|
let httpMethod
|
|
10
12
|
|
|
@@ -37,7 +39,8 @@ const createContext = (service, request, logger = console) => {
|
|
|
37
39
|
httpPath,
|
|
38
40
|
requestId,
|
|
39
41
|
httpMethod,
|
|
40
|
-
operationId
|
|
42
|
+
operationId,
|
|
43
|
+
...extraContext,
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
for (const name in request.headers) {
|
package/src/helpers/handler.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const logRequest = require('./logRequest')
|
|
4
|
-
const createContext
|
|
4
|
+
const createContext = require('./createContext')
|
|
5
5
|
const specMiddleware = require('./specMiddleware')
|
|
6
6
|
|
|
7
7
|
const handler = (service, _createContext = createContext, _middleware = specMiddleware) => {
|
|
8
|
-
return (request,
|
|
9
|
-
const context = _createContext(service, request,
|
|
8
|
+
return (request, extraContext) => {
|
|
9
|
+
const context = _createContext(service, request, extraContext)
|
|
10
10
|
|
|
11
11
|
const result = _middleware(service, context)
|
|
12
12
|
|