Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial WIP of the spec #3

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
squash: moving things around
  • Loading branch information
lholmquist committed Jul 6, 2023
commit 54c032e284baa2673e6047f624488930cf880c80
58 changes: 36 additions & 22 deletions spec/drafts/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,43 +83,24 @@ module.exports = {
Functions are invoked with a context object as the first parameter. This object provides access to the incoming request information. Function developers may access several properties including, but not limited to, the HTTP request method, any query strings sent with the request, the headers, the request body, a logger and a CloudEvent.

const context = {
event: CloudEvent
log: Logger,
request: {
query: Object,
body: Object,
headers: Object,
method: String
}
},
log: Logger,
event: CloudEvent
};

### Required Context Object Attributes

The following Attributes are REQUIRED to be present in all Context Objects:

#### event

- Type: `CloudEvent`
- Description:
- Constraints:
- Examples:

#### log

- Type: `Object`
- Description: A Logging object with methods for 'info', 'warn', 'error', etc.
- Constraints:
- Up to the implementation on where the result is logged out to
- Examples:
- console.log/console.error/etc...
- an instance of a Pino logger

#### request

- Type: `Object`
- Description: An object holds information about the incoming request
- Constraints:
- Examples:

#### request.query

Expand All @@ -128,6 +109,7 @@ The following Attributes are REQUIRED to be present in all Context Objects:
- Constraints:
- For HTTP GET requests, a `request.query` SHOULD be available, if query string Attributes exist
- Examples:
- `{ param1: value, param2: value }`

#### request.body

Expand All @@ -137,21 +119,53 @@ The following Attributes are REQUIRED to be present in all Context Objects:
- The request body SHOULD NOT expose the underlying framework(express, fastify)
- For HTTP POST requests, a `request.body` SHOULD be available
- Examples:
- TODO

#### request.headers

- Type: `Object`
- Description: The HTTP request headers
- Constraints:
- Examples:
- `{ HEADER_1: value }`

#### request.method

- Type: `String`
- Description: The HTTP request method
- Constraints:
- Examples:
- GET
- POST

#### log

- Type: `Object`
- Description: A Logging object with methods for 'info', 'warn', 'error', etc.
- Constraints:
- Up to the implementation on where the result is logged out to
- Examples:
- console.log/console.error/etc...
- an instance of a Pino logger

#### event

- Type: `CloudEvent`
- Description: The event that triggered the function.
- Constraints:
- If a CloudEvent is detected, then this attribute is REQUIRED
- Examples:
- A CloudEvent Serialized as JSON:
```
{
"specversion" : "1.0",
"type" : "com.github.pull_request.opened",
"source" : "https://github.com/cloudevents/spec/pull",
"subject" : "123",
"id" : "A234-1234-1234"
...
}
```

### OPTIONAL Context Object Attributes

Expand Down