-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
When need to allow for different request/response formats.
In general, we could have two scenario's:
- feat: a response builder that returns the type of the response body as an object #34
- A response sender that will create a response that is compliant #35
Adapters
Option 1
We could configure the response adapter like:
const api = compeller(spec, {
adapter: 'apigateway'
});
const { request, response } = api('/api/v1/line-items/{id}', 'get')Option 2
Design an interface.
If we will hand off the interfaces of statusCode, body?, headers? then we can allow for an adapter to be written like:
const responder = (
statusCode: number,
body: Record<string, unknown> = {},
headers: Record<string, unknown> = {}
) => ({
statusCode,
body: JSON.stringify(body),
headers
})
const api = compeller(spec, {
responder,
});
const { request, response } = api('/api/v1/line-items/{id}', 'get')Metadata
Metadata
Assignees
Labels
No labels