Skip to content

Commit 6a0da6b

Browse files
committed
feat(parser): add schema envelopes (#1815)
* first envelope * add abstract class * add tests * add more tests * fix tests * add envelopes * add middy parser * minor schema changes * add more envelopes and tests, refactored utils to autocomplete event files * simplified check * remove middleware from this branch * refactored from class to function envelopes * removed parser tests, should be in another branch * add parser to pre push * consistent naming
1 parent 057685d commit 6a0da6b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: packages/parser/src/envelopes/eventbridge.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { parse } from './envelope.js';
2+
import { z, ZodSchema } from 'zod';
3+
import { EventBridgeSchema } from '../schemas/eventbridge.js';
4+
5+
/**
6+
* Envelope for EventBridge schema that extracts and parses data from the `detail` key.
7+
*/
8+
export const eventBridgeEnvelope = <T extends ZodSchema>(
9+
data: unknown,
10+
schema: T
11+
): z.infer<T> => {
12+
return parse(EventBridgeSchema.parse(data).detail, schema);
13+
};

0 commit comments

Comments
 (0)