lemon-core
Version:
Lemon Serverless Micro-Service Platform
69 lines (68 loc) • 2.29 kB
TypeScript
import { NextContext, NextHandler } from 'lemon-model';
import { LambdaHandler, LambdaSubHandler, NotificationHandler, WEBEvent, Context } from './lambda-handler';
/**
* param for containing headers infor
* - "x-amz-sns-message-id": "ef9765be-a053-40d8-907b-4a212b8a8b6e",
* - "x-amz-sns-message-type": "SubscriptionConfirmation",
* - "x-amz-sns-topic-arn": "arn:aws:sns:ap-northeast-2:796730245826:lemon-todaq-out",
* - "X-Forwarded-For": "54.239.116.71, 52.46.53.153",
*/
export interface NotificationParam {
snsMessageType?: string;
snsMessageId?: string;
snsTopicArn?: string;
snsSubscriptionArn?: string;
subscribeURL?: string;
signature?: string;
subject?: string;
/**
* custom attributes from origin SNS published.
*/
[key: string]: string | number;
}
export interface NotificationBody {
[key: string]: any;
}
/**
* `NextHandler` for `Notification` Event.
* @param id Request path of HTTP SNS or something.
* @param param NotificationParam
* @param body NotificationBody - any payload from origin.
* @param ctx Origin Event Infor.
*/
export declare type NotificationNextHandler = NextHandler<NotificationParam, string, NotificationBody>;
/**
* class: `LambdaNotificationHandler`
* - default Notification Handler via SNS http/https subscription.
*/
export declare class LambdaNotificationHandler extends LambdaSubHandler<NotificationHandler> {
static REPORT_ERROR: boolean;
/**
* default constructor w/ registering self.
*/
constructor(lambda: LambdaHandler, register?: boolean);
protected listeners: NotificationNextHandler[];
/**
* add listener.
* @param handler
*/
addListener(handler: NotificationNextHandler): void;
/**
* Notification Handler.
*/
handle: NotificationHandler;
/**
* Pack context as `NextContext`
* @param event origin lambda event
* @param $ctx origin context.
*/
packContext(event: WEBEvent, $ctx: Context): Promise<NextContext>;
/**
* pack to notification-param via origin event.
* @param event origin lambda event
*/
packNotificationParamBody(event: WEBEvent): {
param: NotificationParam;
body: NotificationBody;
};
}