Comparing version 0.20.5 to 0.21.0
@@ -1,33 +0,47 @@ | ||
import { Callback, Context, Handler, ProxyResult } from 'aws-lambda'; | ||
import { | ||
Callback, | ||
Context, | ||
Handler | ||
} from 'aws-lambda'; | ||
type AsyncHandler = (event: any, context: Context) => Promise<ProxyResult | object>; | ||
declare type EventType<T> = | ||
T extends (event: infer EventArgType, context: Context, callback: Callback<any>) => void ? EventArgType : | ||
T extends (event: infer EventArgType, context: Context) => Promise<any> ? EventArgType : | ||
never; | ||
declare var middy: { | ||
(handler: Handler | AsyncHandler): middy.IMiddy; | ||
}; | ||
declare type HandlerReturnType<T> = | ||
T extends (event: any, context: Context) => Promise<infer RetType> ? RetType : | ||
T extends (event: any, context: Context, callback: Callback<infer RetType>) => void ? RetType : | ||
never; | ||
declare type AsyncHandler<C extends Context> = | ||
((event: any, context: C, callback: Callback<any>) => void) | | ||
((event: any, context: C) => Promise<any>); | ||
declare const middy: <H extends AsyncHandler<C>, C extends Context = Context>(handler: H) => middy.Middy< | ||
EventType<H>, | ||
HandlerReturnType<H> | ||
>; | ||
declare namespace middy { | ||
interface IMiddy extends Handler { | ||
use: IMiddyUseFunction; | ||
before: (callbackFn: IMiddyMiddlewareFunction) => IMiddy; | ||
after: (callbackFn: IMiddyMiddlewareFunction) => IMiddy; | ||
onError: (callbackFn: IMiddyMiddlewareFunction) => IMiddy; | ||
interface Middy<T, R> extends Handler<T, R> { | ||
use: <C extends MiddlewareObject<T, R>>(middleware: C) => Middy<T, R>; | ||
before: (callbackFn: MiddlewareFunction<T, R>) => Middy<T, R>; | ||
after: (callbackFn: MiddlewareFunction<T, R>) => Middy<T, R>; | ||
onError: (callbackFn: MiddlewareFunction<T, R>) => Middy<T, R>; | ||
} | ||
type IMiddyUseFunction = (config?: object) => IMiddy; | ||
type Middleware<C extends any, T = any, R = any> = (config?: C) => MiddlewareObject<T, R>; | ||
interface IMiddyMiddlewareObject { | ||
before?: IMiddyMiddlewareFunction; | ||
after?: IMiddyMiddlewareFunction; | ||
onError?: IMiddyMiddlewareFunction; | ||
interface MiddlewareObject<T, R> { | ||
before?: MiddlewareFunction<T, R>; | ||
after?: MiddlewareFunction<T, R>; | ||
onError?: MiddlewareFunction<T, R>; | ||
} | ||
type IMiddyMiddlewareFunction = ( | ||
handler: IHandlerLambda, | ||
next: IMiddyNextFunction | ||
) => void | Promise<any>; | ||
type MiddlewareFunction<T, R> = (handler: HandlerLambda<T, R>, next: NextFunction) => void | Promise<any>; | ||
type IMiddyNextFunction = (error?: any) => void; | ||
type NextFunction = (error?: any) => void; | ||
interface IHandlerLambda<T = any, V = object> { | ||
interface HandlerLambda<T = any, V = {}> { | ||
event: T; | ||
@@ -37,3 +51,3 @@ context: Context; | ||
error: Error; | ||
callback: Callback; | ||
callback: Callback<T>; | ||
} | ||
@@ -43,1 +57,2 @@ } | ||
export = middy; | ||
export as namespace middy; |
@@ -82,18 +82,18 @@ import { SSM } from 'aws-sdk' | ||
declare function cache(opts?: ICacheOptions): middy.IMiddyMiddlewareObject; | ||
declare function cors(opts?: ICorsOptions): middy.IMiddyMiddlewareObject; | ||
declare function doNotWaitForEmptyEventLoop(opts?: IDoNotWaitForEmtpyEventLoopOptions): middy.IMiddyMiddlewareObject; | ||
declare function httpContentNegotiation(opts?: IHTTPContentNegotiationOptions): middy.IMiddyMiddlewareObject; | ||
declare function httpErrorHandler(opts?: IHTTPErrorHandlerOptions): middy.IMiddyMiddlewareObject; | ||
declare function httpEventNormalizer(): middy.IMiddyMiddlewareObject; | ||
declare function httpHeaderNormalizer(opts?: IHTTPHeaderNormalizerOptions): middy.IMiddyMiddlewareObject; | ||
declare function httpPartialResponse(opts?: IHTTPPartialResponseOptions): middy.IMiddyMiddlewareObject; | ||
declare function jsonBodyParser(): middy.IMiddyMiddlewareObject; | ||
declare function s3KeyNormalizer(): middy.IMiddyMiddlewareObject; | ||
declare function secretsManager(opts?: ISecretsManagerOptions): middy.IMiddyMiddlewareObject; | ||
declare function ssm(opts?: ISSMOptions): middy.IMiddyMiddlewareObject; | ||
declare function validator(opts?: IValidatorOptions): middy.IMiddyMiddlewareObject; | ||
declare function urlEncodeBodyParser(opts?: IURLEncodeBodyParserOptions): middy.IMiddyMiddlewareObject; | ||
declare function warmup(opts?: IWarmupOptions): middy.IMiddyMiddlewareObject; | ||
declare const cache: middy.Middleware<ICacheOptions>; | ||
declare const cors: middy.Middleware<ICorsOptions>; | ||
declare const doNotWaitForEmptyEventLoop: middy.Middleware<IDoNotWaitForEmtpyEventLoopOptions>; | ||
declare const httpContentNegotiation: middy.Middleware<IHTTPContentNegotiationOptions>; | ||
declare const httpErrorHandler: middy.Middleware<IHTTPErrorHandlerOptions>; | ||
declare const httpEventNormalizer: middy.Middleware<never>; | ||
declare const httpHeaderNormalizer: middy.Middleware<IHTTPHeaderNormalizerOptions>; | ||
declare const httpPartialResponse: middy.Middleware<IHTTPPartialResponseOptions>; | ||
declare const jsonBodyParser: middy.Middleware<never>; | ||
declare const s3KeyNormalizer: middy.Middleware<never>; | ||
declare const secretsManager: middy.Middleware<ISecretsManagerOptions>; | ||
declare const ssm: middy.Middleware<ISSMOptions>; | ||
declare const validator: middy.Middleware<IValidatorOptions>; | ||
declare const urlEncodeBodyParser: middy.Middleware<IURLEncodeBodyParserOptions>; | ||
declare const warmup: middy.Middleware<IWarmupOptions>; | ||
export as namespace middlewares; |
{ | ||
"name": "middy", | ||
"version": "0.20.5", | ||
"version": "0.21.0", | ||
"description": "🛵 The stylish Node.js middleware engine for AWS Lambda", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -42,3 +42,3 @@ import middy from '../../'; | ||
handler | ||
.use(middleware) | ||
.use(middleware()) | ||
.after(after) | ||
@@ -45,0 +45,0 @@ .before(before) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
170476
4273