You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, all Object Storage Endpoints come bundled with the following transformation code.
22
+
23
+
```JavaScript
24
+
/**
25
+
* @paraminput - The input object
26
+
* @paraminput.events - The array of events in the batch. The number of events in the batch is capped by the Object Storage Endpoint's batch size.
27
+
* @paraminput.events[].payload - The message payload (string or JSON)
28
+
* @paraminput.events[].eventType - The message event type (string)
29
+
*
30
+
* @returns Object describing what will be put to the bucket.
31
+
* @returns returns.config
32
+
* @returns returns.config.format - The format of the request object put to the bucket. Valid values are "jsonl", "json", or "raw" (Defaults to jsonl).
33
+
* @returns returns.config.key - The name of the object that will be put to the bucket. This will be suffixed with a timestamp to avoid duplicate object names.
34
+
* @returns returns.data - The array of events to send to the bucket. This will be formatted according to the format.
35
+
*/
36
+
functionhandler(input) {
37
+
return {
38
+
config: {
39
+
format:"jsonl",
40
+
key:"object-generated-by-svix"
41
+
},
42
+
data:input.events
43
+
}
44
+
}
45
+
```
46
+
47
+
`input.events` is the list of webhooks received by the endpoint, processed in batches.
48
+
49
+
`config` describes the object put in the destination - the key name of the object, and the format of the object saved to the bucket.
50
+
51
+
By default, the actual object key is always suffixed with a timestamp after the transformations are run. This ensures each event batch is saved as a unique object in the bucket.
52
+
53
+
For example, if the endpoint receives the following events:
If you want to control the format of the object more precisely, you can use `config.format = "raw"`, and set `data` to a string of the exact file contents you want.
0 commit comments