Skip to content

Feature request: allow parser set event type of handler with middy #2407

Closed
@yamatatsu

Description

@yamatatsu

Use case

middy can pass event type like as this. So we can pass inferred event type from zod schema to handler.

Solution/User Experience

const detailSchema = z.object({
	date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
	message: z.string(),
});

export const handler = middy()
	// when using parser
	.use(parser({ schema: detailSchema, envelope: EventBridgeEnvelope }))
	// handler will get event type already inferred without type annotation.
	.handler(async (event) => {
		logger.inf(event.detail.message)
	});

Alternative solutions

No response

Acknowledgment

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/shippedfeature-requestThis item refers to a feature request for an existing or new utilityparserThis item relates to the Parser Utility

Type

No type

Projects

Status

Shipped

Relationships

None yet

Development

No branches or pull requests

Issue actions