Skip to content

chore: add middy like interfaces to commons package #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/commons/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './utils/lambda';
export * from './utils/middy';
export * as ContextExamples from './tests/resources/contexts';
export * as Events from './tests/resources/events';
19 changes: 19 additions & 0 deletions packages/commons/src/utils/middy/MiddyInterfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Context } from 'aws-lambda';

interface MiddyLikeRequest<TEvent = unknown, TResult = unknown, TErr = Error, TContext extends Context = Context> {
event: TEvent
context: TContext
response: TResult | null
error: TErr | null
internal: {
[key: string]: unknown
}
}

declare type MiddlewareFn<TEvent = unknown, TResult = unknown, TErr = Error, TContext extends Context = Context> = (request: MiddyLikeRequest<TEvent, TResult, TErr, TContext>) => unknown;

export interface MiddyLikeMiddlewareObj<TEvent = unknown, TResult = unknown, TErr = Error, TContext extends Context = Context> {
before?: MiddlewareFn<TEvent, TResult, TErr, TContext>
after?: MiddlewareFn<TEvent, TResult, TErr, TContext>
onError?: MiddlewareFn<TEvent, TResult, TErr, TContext>
}
1 change: 1 addition & 0 deletions packages/commons/src/utils/middy/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './MiddyInterfaces';