-
Notifications
You must be signed in to change notification settings - Fork 161
Closed
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilityparserThis item relates to the Parser UtilityThis item relates to the Parser Utility
Milestone
Description
Use case
Similar to middy middleware we want to use build-in schemas and envelopes to parse and extract events using decorators.
Solution/User Experience
Based on the RFC the decorator should take model and envelope as an param object:
const order = z.object({
id: z.number(),
description: z.string(),
});
type Order = z.infer<typeof order>;
class Lambda implements LambdaInterface {
// Decorate your handler class method
@logger.injectLambdaContext()
@parser({eventBridgeEnvelope, order})
public async handler(
_event: OrderModel,
_context: Context
): Promise<void> {
logger.info(`Received order model ${_event}`);
}
}
we should also be able to pass only the model, which can be a custom event or an extension of the built-in schema i.e.
const order = z.object({
id: z.number(),
description: z.string(),
});
const customEBschema = EventBridgeSchema.extend({
detail: order,
});
Alternative solutions
No response
Acknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilityparserThis item relates to the Parser UtilityThis item relates to the Parser Utility
Type
Projects
Status
Shipped