-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFunctionEvent.js
More file actions
41 lines (40 loc) · 1.33 KB
/
FunctionEvent.js
File metadata and controls
41 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* FunctionEvent is the first parameter of OpenAPI Node Template handler method.
*
* It contains following fields from OpenAPI Backend:
*
* - `body`
* - `requestBody` - parsed body
* - `cookies`
* - `headers`
* - `method`
* - `query`
* - `path`
* - `params` - path parsed to path params
*
* Some specific fields of the Node Template:
*
* - `files` - files in case of multipart message
*
* Low-level accessors:
*
* - `req` - original Node HTTP Request
* - `oabContext` - OpenAPI Backend context where some of the fields are already extracted. This can be used when you want to use some fields that were not translated by Node Template. Find more here - https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#context-object
*/
class FunctionEvent {
constructor(c, req) {
// extract data from Context of OpenAPI Backend
// https://github.com/anttiviljami/openapi-backend/blob/master/DOCS.md#context-object
this.body = c.request.body;
this.cookies = c.request.cookies;
this.headers = c.request.headers;
this.method = c.request.method;
this.query = c.request.query;
this.path = c.request.path;
this.params = c.request.params;
this.files = req.files;
this.req = req;
this.oabContext = c;
}
}
module.exports = FunctionEvent;