@vyriy/handler 0.7.7 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +395 -180
- package/api/api.d.ts +10 -0
- package/api/api.js +19 -0
- package/api/http/compose/compose.d.ts +2 -0
- package/api/http/compose/compose.js +1 -0
- package/api/http/compose/index.d.ts +1 -0
- package/api/http/compose/index.js +1 -0
- package/api/http/factory/factory.d.ts +2 -0
- package/api/http/factory/factory.js +1 -0
- package/api/http/factory/index.d.ts +1 -0
- package/api/http/factory/index.js +1 -0
- package/api/http/http.d.ts +3 -0
- package/api/http/http.js +14 -0
- package/api/http/index.d.ts +3 -0
- package/api/http/index.js +2 -0
- package/api/http/types.d.ts +18 -0
- package/api/http/wrappers/cors.d.ts +1 -0
- package/api/http/wrappers/cors.js +9 -0
- package/api/http/wrappers/error.d.ts +3 -0
- package/api/http/wrappers/error.js +21 -0
- package/api/http/wrappers/headers.d.ts +1 -0
- package/api/http/wrappers/headers.js +8 -0
- package/api/http/wrappers/healthcheck.d.ts +5 -0
- package/api/http/wrappers/healthcheck.js +19 -0
- package/api/http/wrappers/index.d.ts +5 -0
- package/api/http/wrappers/index.js +5 -0
- package/api/http/wrappers/logger.d.ts +2 -0
- package/api/http/wrappers/logger.js +28 -0
- package/api/index.d.ts +3 -0
- package/api/index.js +2 -0
- package/api/stream/compose/compose.d.ts +2 -0
- package/api/stream/compose/compose.js +1 -0
- package/api/stream/compose/index.d.ts +1 -0
- package/api/stream/compose/index.js +1 -0
- package/api/stream/factory/factory.d.ts +5 -0
- package/api/stream/factory/factory.js +3 -0
- package/api/stream/factory/index.d.ts +1 -0
- package/api/stream/factory/index.js +1 -0
- package/api/stream/index.d.ts +3 -0
- package/api/stream/index.js +2 -0
- package/api/stream/stream.d.ts +3 -0
- package/api/stream/stream.js +13 -0
- package/api/stream/types.d.ts +36 -0
- package/api/stream/wrappers/chaos.d.ts +2 -0
- package/{wrapper → api/stream/wrappers}/chaos.js +1 -12
- package/api/stream/wrappers/context.d.ts +1 -0
- package/api/stream/wrappers/context.js +6 -0
- package/api/stream/wrappers/cors.d.ts +1 -0
- package/api/stream/wrappers/cors.js +10 -0
- package/api/stream/wrappers/error.d.ts +3 -0
- package/{wrapper → api/stream/wrappers}/error.js +1 -18
- package/api/stream/wrappers/headers.d.ts +1 -0
- package/api/stream/wrappers/headers.js +7 -0
- package/api/stream/wrappers/healthcheck.d.ts +2 -0
- package/{wrapper → api/stream/wrappers}/healthcheck.js +1 -6
- package/api/stream/wrappers/index.d.ts +10 -0
- package/api/stream/wrappers/index.js +10 -0
- package/api/stream/wrappers/logger.d.ts +2 -0
- package/api/stream/wrappers/logger.js +20 -0
- package/api/stream/wrappers/smoke.d.ts +2 -0
- package/{wrapper → api/stream/wrappers}/smoke.js +1 -5
- package/api/stream/wrappers/timeout.d.ts +1 -0
- package/api/stream/wrappers/timeout.js +6 -0
- package/api/types.d.ts +17 -0
- package/api/wrappers/chaos.d.ts +1 -0
- package/api/wrappers/chaos.js +1 -0
- package/{wrapper → api/wrappers}/cors.d.ts +0 -1
- package/api/wrappers/cors.js +11 -0
- package/api/wrappers/error.d.ts +4 -0
- package/api/wrappers/error.js +18 -0
- package/{wrapper → api/wrappers}/headers.d.ts +0 -1
- package/{wrapper → api/wrappers}/headers.js +1 -6
- package/{wrapper → api/wrappers}/healthcheck.d.ts +0 -1
- package/api/wrappers/healthcheck.js +22 -0
- package/api/wrappers/index.d.ts +5 -0
- package/api/wrappers/index.js +5 -0
- package/compose/compose.d.ts +2 -0
- package/compose/compose.js +1 -0
- package/compose/index.d.ts +1 -0
- package/compose/index.js +1 -0
- package/create/create.d.ts +12 -0
- package/create/create.js +22 -0
- package/create/index.d.ts +1 -0
- package/create/index.js +1 -0
- package/dynamodb/dynamodb.d.ts +4 -0
- package/dynamodb/dynamodb.js +8 -0
- package/dynamodb/index.d.ts +1 -0
- package/dynamodb/index.js +1 -0
- package/eventBridge/eventBridge.d.ts +4 -0
- package/eventBridge/eventBridge.js +8 -0
- package/eventBridge/index.d.ts +1 -0
- package/eventBridge/index.js +1 -0
- package/factory/factory.d.ts +4 -0
- package/factory/factory.js +2 -0
- package/factory/index.d.ts +1 -0
- package/factory/index.js +1 -0
- package/index.d.ts +21 -19
- package/index.js +21 -19
- package/package.json +731 -185
- package/s3/index.d.ts +1 -0
- package/s3/index.js +1 -0
- package/s3/s3.d.ts +4 -0
- package/s3/s3.js +8 -0
- package/schedule/index.d.ts +1 -0
- package/schedule/index.js +1 -0
- package/schedule/schedule.d.ts +4 -0
- package/schedule/schedule.js +8 -0
- package/ses/index.d.ts +1 -0
- package/ses/index.js +1 -0
- package/ses/ses.d.ts +4 -0
- package/ses/ses.js +8 -0
- package/sns/index.d.ts +1 -0
- package/sns/index.js +1 -0
- package/sns/sns.d.ts +4 -0
- package/sns/sns.js +8 -0
- package/sqs/index.d.ts +1 -0
- package/sqs/index.js +1 -0
- package/sqs/sqs.d.ts +4 -0
- package/sqs/sqs.js +8 -0
- package/types.d.ts +12 -22
- package/{wrapper → wrappers}/chaos.d.ts +0 -1
- package/wrappers/chaos.js +35 -0
- package/{wrapper → wrappers}/context.d.ts +0 -1
- package/wrappers/context.js +6 -0
- package/{wrapper → wrappers}/error.d.ts +1 -3
- package/wrappers/error.js +9 -0
- package/wrappers/index.d.ts +6 -0
- package/wrappers/index.js +6 -0
- package/{wrapper → wrappers}/logger.d.ts +0 -1
- package/wrappers/logger.js +21 -0
- package/wrappers/smoke.d.ts +2 -0
- package/wrappers/smoke.js +5 -0
- package/{wrapper → wrappers}/timeout.d.ts +0 -1
- package/wrappers/timeout.js +6 -0
- package/api.d.ts +0 -2
- package/api.js +0 -24
- package/compose.d.ts +0 -3
- package/compose.js +0 -2
- package/dynamodb.d.ts +0 -2
- package/dynamodb.js +0 -7
- package/eventBridge.d.ts +0 -2
- package/eventBridge.js +0 -7
- package/factory.d.ts +0 -7
- package/factory.js +0 -5
- package/s3.d.ts +0 -2
- package/s3.js +0 -7
- package/schedule.d.ts +0 -2
- package/schedule.js +0 -7
- package/ses.d.ts +0 -2
- package/ses.js +0 -7
- package/sns.d.ts +0 -2
- package/sns.js +0 -7
- package/sqs.d.ts +0 -2
- package/sqs.js +0 -7
- package/wrapper/context.js +0 -11
- package/wrapper/cors.js +0 -20
- package/wrapper/logger.js +0 -39
- package/wrapper/smoke.d.ts +0 -3
- package/wrapper/timeout.js +0 -10
- /package/{wrapper → api/stream/wrappers}/stream.d.ts +0 -0
- /package/{wrapper → api/stream/wrappers}/stream.js +0 -0
|
@@ -1,2 +1 @@
|
|
|
1
1
|
export declare const withHeaders: (options?: Record<string, string> | undefined) => import("../types.js").Decorator<import("aws-lambda").APIGatewayProxyEvent, import("aws-lambda").APIGatewayProxyResult>;
|
|
2
|
-
export declare const streamWithHeaders: (options?: Record<string, string> | undefined) => import("../types.js").StreamDecorator<import("aws-lambda").APIGatewayProxyEvent>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { factory
|
|
2
|
-
import { responseStream } from './stream.js';
|
|
1
|
+
import { factory } from '../../factory/index.js';
|
|
3
2
|
const normalizeHeaders = (headers) => Object.fromEntries(Object.entries(headers ?? {}).map(([key, value]) => [key.toLowerCase(), value]));
|
|
4
3
|
const mergeHeaders = (result, options) => {
|
|
5
4
|
result.headers = {
|
|
@@ -12,7 +11,3 @@ export const withHeaders = factory(async (handler, args, options = {}) => {
|
|
|
12
11
|
const result = await handler(...args);
|
|
13
12
|
return mergeHeaders(result, options);
|
|
14
13
|
});
|
|
15
|
-
export const streamWithHeaders = streamFactory(async (handler, args, options = {}) => {
|
|
16
|
-
const [event, stream, context] = args;
|
|
17
|
-
await handler(event, responseStream(stream, { headers: normalizeHeaders(options) }), context);
|
|
18
|
-
});
|
|
@@ -6,4 +6,3 @@ export declare const withHealthcheck: (options?: HealthcheckOptions | undefined)
|
|
|
6
6
|
statusCode: number;
|
|
7
7
|
body: string;
|
|
8
8
|
}>;
|
|
9
|
-
export declare const streamWithHealthcheck: (options?: HealthcheckOptions | undefined) => import("../types.js").StreamDecorator<import("aws-lambda").APIGatewayProxyEvent>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { STATUS_CODES } from 'node:http';
|
|
2
|
+
import { factory } from '../../factory/index.js';
|
|
3
|
+
const getHealthcheckResult = async (event, options = {}) => {
|
|
4
|
+
const { path = '/healthcheck', action } = options;
|
|
5
|
+
if (event.path !== path) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
if (action) {
|
|
9
|
+
await action();
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
statusCode: 200,
|
|
13
|
+
body: JSON.stringify({
|
|
14
|
+
message: STATUS_CODES[200],
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export const withHealthcheck = factory(async (handler, args, options = {}) => {
|
|
19
|
+
const [event] = args;
|
|
20
|
+
const result = await getHealthcheckResult(event, options);
|
|
21
|
+
return result ?? handler(...args);
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const compose = (...fns) => fns.reduceRight((prevDecorator, nextDecorator) => (handler) => nextDecorator(prevDecorator(handler)));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { compose } from './compose.js';
|
package/compose/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { compose } from './compose.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const create: {
|
|
2
|
+
api: import("../types.js").Api;
|
|
3
|
+
dynamodb: (options?: import("../types.js").EventHandlerOptions<import("aws-lambda").DynamoDBStreamEvent>) => import("../types.js").Decorator<import("aws-lambda").DynamoDBStreamEvent, void>;
|
|
4
|
+
eventBridge: (options?: import("../types.js").EventHandlerOptions<import("aws-lambda").EventBridgeEvent<string, unknown>>) => import("../types.js").Decorator<import("aws-lambda").EventBridgeEvent<string, unknown>, void>;
|
|
5
|
+
httpApi: import("../types.js").HttpApi;
|
|
6
|
+
s3: (options?: import("../types.js").EventHandlerOptions<import("aws-lambda").S3Event>) => import("../types.js").Decorator<import("aws-lambda").S3Event, void>;
|
|
7
|
+
schedule: (options?: import("../types.js").EventHandlerOptions<import("aws-lambda").ScheduledEvent>) => import("../types.js").Decorator<import("aws-lambda").ScheduledEvent, void>;
|
|
8
|
+
ses: (options?: import("../types.js").EventHandlerOptions<import("aws-lambda").SESEvent>) => import("../types.js").Decorator<import("aws-lambda").SESEvent, void>;
|
|
9
|
+
sns: (options?: import("../types.js").EventHandlerOptions<import("aws-lambda").SNSEvent>) => import("../types.js").Decorator<import("aws-lambda").SNSEvent, void>;
|
|
10
|
+
sqs: (options?: import("../types.js").EventHandlerOptions<import("aws-lambda").SQSEvent>) => import("../types.js").Decorator<import("aws-lambda").SQSEvent, void>;
|
|
11
|
+
streamApi: import("../types.js").StreamApi;
|
|
12
|
+
};
|
package/create/create.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createApi } from '../api/index.js';
|
|
2
|
+
import { createDynamodb } from '../dynamodb/index.js';
|
|
3
|
+
import { createEventBridge } from '../eventBridge/index.js';
|
|
4
|
+
import { createApi as createHttpApi } from '../api/http/index.js';
|
|
5
|
+
import { createS3 } from '../s3/index.js';
|
|
6
|
+
import { createSchedule } from '../schedule/index.js';
|
|
7
|
+
import { createSes } from '../ses/index.js';
|
|
8
|
+
import { createSns } from '../sns/index.js';
|
|
9
|
+
import { createSqs } from '../sqs/index.js';
|
|
10
|
+
import { createApi as createStreamApi } from '../api/stream/index.js';
|
|
11
|
+
export const create = {
|
|
12
|
+
api: createApi,
|
|
13
|
+
dynamodb: createDynamodb,
|
|
14
|
+
eventBridge: createEventBridge,
|
|
15
|
+
httpApi: createHttpApi,
|
|
16
|
+
s3: createS3,
|
|
17
|
+
schedule: createSchedule,
|
|
18
|
+
ses: createSes,
|
|
19
|
+
sns: createSns,
|
|
20
|
+
sqs: createSqs,
|
|
21
|
+
streamApi: createStreamApi,
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { create } from './create.js';
|
package/create/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { create } from './create.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DynamoDBStreamEvent } from 'aws-lambda';
|
|
2
|
+
import type { Decorator, EventHandlerOptions } from '../types.js';
|
|
3
|
+
export declare const createDynamodb: (options?: EventHandlerOptions<DynamoDBStreamEvent>) => Decorator<DynamoDBStreamEvent, void>;
|
|
4
|
+
export declare const dynamodb: Decorator<DynamoDBStreamEvent, void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { compose } from '../compose/index.js';
|
|
2
|
+
import { withContext } from '../wrappers/context.js';
|
|
3
|
+
import { withError } from '../wrappers/error.js';
|
|
4
|
+
import { withLogger } from '../wrappers/logger.js';
|
|
5
|
+
import { withSmoke } from '../wrappers/smoke.js';
|
|
6
|
+
import { withTimeout } from '../wrappers/timeout.js';
|
|
7
|
+
export const createDynamodb = (options = {}) => compose(withError(options.error), withLogger(options.logger), withTimeout(), withContext(), withSmoke());
|
|
8
|
+
export const dynamodb = createDynamodb();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDynamodb, createDynamodb as create, dynamodb } from './dynamodb.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDynamodb, createDynamodb as create, dynamodb } from './dynamodb.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EventBridgeEvent } from 'aws-lambda';
|
|
2
|
+
import type { Decorator, EventHandlerOptions } from '../types.js';
|
|
3
|
+
export declare const createEventBridge: (options?: EventHandlerOptions<EventBridgeEvent<string, unknown>>) => Decorator<EventBridgeEvent<string, unknown>, void>;
|
|
4
|
+
export declare const eventBridge: Decorator<EventBridgeEvent<string, unknown>, void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { compose } from '../compose/index.js';
|
|
2
|
+
import { withContext } from '../wrappers/context.js';
|
|
3
|
+
import { withError } from '../wrappers/error.js';
|
|
4
|
+
import { withLogger } from '../wrappers/logger.js';
|
|
5
|
+
import { withSmoke } from '../wrappers/smoke.js';
|
|
6
|
+
import { withTimeout } from '../wrappers/timeout.js';
|
|
7
|
+
export const createEventBridge = (options = {}) => compose(withError(options.error), withLogger(options.logger), withTimeout(), withContext(), withSmoke());
|
|
8
|
+
export const eventBridge = createEventBridge();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createEventBridge, createEventBridge as create, eventBridge } from './eventBridge.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createEventBridge, createEventBridge as create, eventBridge } from './eventBridge.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { factory, getContext } from './factory.js';
|
package/factory/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { factory, getContext } from './factory.js';
|
package/index.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export * from './
|
|
19
|
-
export
|
|
1
|
+
export { api, createApi } from './api/index.js';
|
|
2
|
+
export { compose } from './compose/index.js';
|
|
3
|
+
export { compose as httpCompose } from './api/http/compose/index.js';
|
|
4
|
+
export { compose as streamCompose } from './api/stream/compose/index.js';
|
|
5
|
+
export { create } from './create/index.js';
|
|
6
|
+
export { createDynamodb, dynamodb } from './dynamodb/index.js';
|
|
7
|
+
export { createEventBridge, eventBridge } from './eventBridge/index.js';
|
|
8
|
+
export { factory, getContext } from './factory/index.js';
|
|
9
|
+
export { factory as httpFactory } from './api/http/factory/index.js';
|
|
10
|
+
export { factory as streamFactory, getContext as getStreamContext, getResponseStream, } from './api/stream/factory/index.js';
|
|
11
|
+
export { api as httpApi, createApi as createHttpApi } from './api/http/index.js';
|
|
12
|
+
export { createS3, s3 } from './s3/index.js';
|
|
13
|
+
export { createSchedule, schedule } from './schedule/index.js';
|
|
14
|
+
export { createSes, ses } from './ses/index.js';
|
|
15
|
+
export { createSns, sns } from './sns/index.js';
|
|
16
|
+
export { createSqs, sqs } from './sqs/index.js';
|
|
17
|
+
export { api as streamApi, createApi as createStreamApi } from './api/stream/index.js';
|
|
18
|
+
export * from './api/wrappers/index.js';
|
|
19
|
+
export { withCors as httpWithCors, withError as httpWithError, withHeaders as httpWithHeaders, withHealthcheck as httpWithHealthcheck, withLogger as httpWithLogger, } from './api/http/wrappers/index.js';
|
|
20
|
+
export { withApiError as streamWithApiError, withChaos as streamWithChaos, withContext as streamWithContext, withCors as streamWithCors, withHeaders as streamWithHeaders, withHealthcheck as streamWithHealthcheck, withLogger as streamWithLogger, withSmoke as streamWithSmoke, withTimeout as streamWithTimeout, responseStream, } from './api/stream/wrappers/index.js';
|
|
21
|
+
export * from './wrappers/index.js';
|
|
20
22
|
export type * from './types.js';
|
package/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export * from './
|
|
19
|
-
export
|
|
1
|
+
export { api, createApi } from './api/index.js';
|
|
2
|
+
export { compose } from './compose/index.js';
|
|
3
|
+
export { compose as httpCompose } from './api/http/compose/index.js';
|
|
4
|
+
export { compose as streamCompose } from './api/stream/compose/index.js';
|
|
5
|
+
export { create } from './create/index.js';
|
|
6
|
+
export { createDynamodb, dynamodb } from './dynamodb/index.js';
|
|
7
|
+
export { createEventBridge, eventBridge } from './eventBridge/index.js';
|
|
8
|
+
export { factory, getContext } from './factory/index.js';
|
|
9
|
+
export { factory as httpFactory } from './api/http/factory/index.js';
|
|
10
|
+
export { factory as streamFactory, getContext as getStreamContext, getResponseStream, } from './api/stream/factory/index.js';
|
|
11
|
+
export { api as httpApi, createApi as createHttpApi } from './api/http/index.js';
|
|
12
|
+
export { createS3, s3 } from './s3/index.js';
|
|
13
|
+
export { createSchedule, schedule } from './schedule/index.js';
|
|
14
|
+
export { createSes, ses } from './ses/index.js';
|
|
15
|
+
export { createSns, sns } from './sns/index.js';
|
|
16
|
+
export { createSqs, sqs } from './sqs/index.js';
|
|
17
|
+
export { api as streamApi, createApi as createStreamApi } from './api/stream/index.js';
|
|
18
|
+
export * from './api/wrappers/index.js';
|
|
19
|
+
export { withCors as httpWithCors, withError as httpWithError, withHeaders as httpWithHeaders, withHealthcheck as httpWithHealthcheck, withLogger as httpWithLogger, } from './api/http/wrappers/index.js';
|
|
20
|
+
export { withApiError as streamWithApiError, withChaos as streamWithChaos, withContext as streamWithContext, withCors as streamWithCors, withHeaders as streamWithHeaders, withHealthcheck as streamWithHealthcheck, withLogger as streamWithLogger, withSmoke as streamWithSmoke, withTimeout as streamWithTimeout, responseStream, } from './api/stream/wrappers/index.js';
|
|
21
|
+
export * from './wrappers/index.js';
|