serverless-simple-middleware 0.0.53 → 0.0.56

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.
Files changed (51) hide show
  1. package/.prettierignore +2 -2
  2. package/README.md +4 -4
  3. package/dist/aws/config.d.ts +15 -15
  4. package/dist/aws/config.js +29 -29
  5. package/dist/aws/define.d.ts +21 -21
  6. package/dist/aws/define.js +8 -8
  7. package/dist/aws/index.d.ts +3 -3
  8. package/dist/aws/index.js +8 -8
  9. package/dist/aws/simple.d.ts +44 -44
  10. package/dist/aws/simple.js +659 -656
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.js +8 -8
  13. package/dist/middleware/aws.d.ts +25 -25
  14. package/dist/middleware/aws.js +128 -128
  15. package/dist/middleware/base.d.ts +54 -54
  16. package/dist/middleware/base.js +140 -140
  17. package/dist/middleware/build.d.ts +3 -3
  18. package/dist/middleware/build.js +234 -234
  19. package/dist/middleware/index.d.ts +12 -12
  20. package/dist/middleware/index.js +22 -22
  21. package/dist/middleware/logger.d.ts +18 -18
  22. package/dist/middleware/logger.js +71 -71
  23. package/dist/middleware/mysql.d.ts +44 -44
  24. package/dist/middleware/mysql.js +289 -289
  25. package/dist/middleware/trace.d.ts +86 -86
  26. package/dist/middleware/trace.js +255 -255
  27. package/dist/utils/index.d.ts +2 -2
  28. package/dist/utils/index.js +7 -7
  29. package/dist/utils/logger.d.ts +26 -26
  30. package/dist/utils/logger.js +73 -73
  31. package/dist/utils/misc.d.ts +1 -1
  32. package/dist/utils/misc.js +9 -9
  33. package/jest.config.js +7 -7
  34. package/package.json +61 -61
  35. package/src/aws/config.ts +46 -46
  36. package/src/aws/define.ts +29 -29
  37. package/src/aws/index.ts +3 -3
  38. package/src/aws/simple.ts +529 -531
  39. package/src/index.ts +3 -3
  40. package/src/middleware/aws.ts +78 -78
  41. package/src/middleware/base.ts +164 -164
  42. package/src/middleware/build.ts +173 -173
  43. package/src/middleware/index.ts +20 -20
  44. package/src/middleware/logger.ts +28 -28
  45. package/src/middleware/mysql.ts +210 -210
  46. package/src/middleware/trace.ts +269 -269
  47. package/src/utils/index.ts +2 -2
  48. package/src/utils/logger.ts +94 -94
  49. package/src/utils/misc.ts +11 -11
  50. package/tsconfig.json +15 -15
  51. package/tslint.json +12 -12
package/.prettierignore CHANGED
@@ -1,3 +1,3 @@
1
- tslint.json
2
- tsconfig.json
1
+ tslint.json
2
+ tsconfig.json
3
3
  package.json
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Serverless simple middleware
2
-
3
- This is just simple middleware for me to translate the interface of lambda's handler to use `request => response`.
4
-
1
+ # Serverless simple middleware
2
+
3
+ This is just simple middleware for me to translate the interface of lambda's handler to use `request => response`.
4
+
@@ -1,15 +1,15 @@
1
- import { AWSComponent } from './define';
2
- export interface AWSConfig {
3
- [key: string]: string | boolean | number | undefined;
4
- }
5
- export interface AWSConfigs {
6
- [service: string]: AWSConfig;
7
- }
8
- export declare type AWSConfigResolver = (service: string) => AWSConfig;
9
- export declare type SimpleAWSConfigLoadParam = AWSConfigs | string;
10
- export declare class SimpleAWSConfig {
11
- private configs;
12
- constructor(configs?: AWSConfigs);
13
- get: (service: AWSComponent) => AWSConfig | undefined;
14
- }
15
- export declare const loadAWSConfig: (newConfigsOrUrl: SimpleAWSConfigLoadParam) => Promise<SimpleAWSConfig>;
1
+ import { AWSComponent } from './define';
2
+ export interface AWSConfig {
3
+ [key: string]: string | boolean | number | undefined;
4
+ }
5
+ export interface AWSConfigs {
6
+ [service: string]: AWSConfig;
7
+ }
8
+ export declare type AWSConfigResolver = (service: string) => AWSConfig;
9
+ export declare type SimpleAWSConfigLoadParam = AWSConfigs | string;
10
+ export declare class SimpleAWSConfig {
11
+ private configs;
12
+ constructor(configs?: AWSConfigs);
13
+ get: (service: AWSComponent) => AWSConfig | undefined;
14
+ }
15
+ export declare const loadAWSConfig: (newConfigsOrUrl: SimpleAWSConfigLoadParam) => Promise<SimpleAWSConfig>;
@@ -1,29 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var cross_fetch_1 = require("cross-fetch");
4
- var fs = require("fs");
5
- var SimpleAWSConfig = /** @class */ (function () {
6
- function SimpleAWSConfig(configs) {
7
- var _this = this;
8
- this.get = function (service) {
9
- return _this.configs ? _this.configs[service] : undefined;
10
- };
11
- this.configs = configs;
12
- }
13
- return SimpleAWSConfig;
14
- }());
15
- exports.SimpleAWSConfig = SimpleAWSConfig;
16
- exports.loadAWSConfig = function (newConfigsOrUrl) {
17
- if (typeof newConfigsOrUrl === 'string') {
18
- if (/^http.*json$/.test(newConfigsOrUrl)) {
19
- return cross_fetch_1.default(newConfigsOrUrl)
20
- .then(function (r) { return r.json(); })
21
- .then(exports.loadAWSConfig);
22
- }
23
- else if (/json$/.test(newConfigsOrUrl)) {
24
- return exports.loadAWSConfig(JSON.parse(fs.readFileSync(newConfigsOrUrl, 'utf-8')));
25
- }
26
- return exports.loadAWSConfig(JSON.parse(newConfigsOrUrl));
27
- }
28
- return Promise.resolve(new SimpleAWSConfig(newConfigsOrUrl));
29
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var cross_fetch_1 = require("cross-fetch");
4
+ var fs = require("fs");
5
+ var SimpleAWSConfig = /** @class */ (function () {
6
+ function SimpleAWSConfig(configs) {
7
+ var _this = this;
8
+ this.get = function (service) {
9
+ return _this.configs ? _this.configs[service] : undefined;
10
+ };
11
+ this.configs = configs;
12
+ }
13
+ return SimpleAWSConfig;
14
+ }());
15
+ exports.SimpleAWSConfig = SimpleAWSConfig;
16
+ exports.loadAWSConfig = function (newConfigsOrUrl) {
17
+ if (typeof newConfigsOrUrl === 'string') {
18
+ if (/^http.*json$/.test(newConfigsOrUrl)) {
19
+ return cross_fetch_1.default(newConfigsOrUrl)
20
+ .then(function (r) { return r.json(); })
21
+ .then(exports.loadAWSConfig);
22
+ }
23
+ else if (/json$/.test(newConfigsOrUrl)) {
24
+ return exports.loadAWSConfig(JSON.parse(fs.readFileSync(newConfigsOrUrl, 'utf-8')));
25
+ }
26
+ return exports.loadAWSConfig(JSON.parse(newConfigsOrUrl));
27
+ }
28
+ return Promise.resolve(new SimpleAWSConfig(newConfigsOrUrl));
29
+ };
@@ -1,21 +1,21 @@
1
- export declare enum AWSComponent {
2
- s3 = "s3",
3
- sqs = "sqs",
4
- dynamodb = "dynamodb"
5
- }
6
- export interface SQSMessageBody<T> {
7
- handle: string;
8
- body?: T;
9
- }
10
- export interface S3SignedUrlParams {
11
- Key?: string;
12
- Expires?: number;
13
- ContentType?: string;
14
- ACL?: 'private' | 'public-read' | 'public-read-write' | 'authenticated-read' | string;
15
- ResponseContentDisposition?: string;
16
- ResponseContentType?: string;
17
- }
18
- export interface S3SignedUrlResult {
19
- key: string;
20
- url: string;
21
- }
1
+ export declare enum AWSComponent {
2
+ s3 = "s3",
3
+ sqs = "sqs",
4
+ dynamodb = "dynamodb"
5
+ }
6
+ export interface SQSMessageBody<T> {
7
+ handle: string;
8
+ body?: T;
9
+ }
10
+ export interface S3SignedUrlParams {
11
+ Key?: string;
12
+ Expires?: number;
13
+ ContentType?: string;
14
+ ACL?: 'private' | 'public-read' | 'public-read-write' | 'authenticated-read' | string;
15
+ ResponseContentDisposition?: string;
16
+ ResponseContentType?: string;
17
+ }
18
+ export interface S3SignedUrlResult {
19
+ key: string;
20
+ url: string;
21
+ }
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var AWSComponent;
4
- (function (AWSComponent) {
5
- AWSComponent["s3"] = "s3";
6
- AWSComponent["sqs"] = "sqs";
7
- AWSComponent["dynamodb"] = "dynamodb";
8
- })(AWSComponent = exports.AWSComponent || (exports.AWSComponent = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var AWSComponent;
4
+ (function (AWSComponent) {
5
+ AWSComponent["s3"] = "s3";
6
+ AWSComponent["sqs"] = "sqs";
7
+ AWSComponent["dynamodb"] = "dynamodb";
8
+ })(AWSComponent = exports.AWSComponent || (exports.AWSComponent = {}));
@@ -1,3 +1,3 @@
1
- export * from './define';
2
- export * from './config';
3
- export * from './simple';
1
+ export * from './define';
2
+ export * from './config';
3
+ export * from './simple';
package/dist/aws/index.js CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
- }
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- __export(require("./define"));
7
- __export(require("./config"));
8
- __export(require("./simple"));
1
+ "use strict";
2
+ function __export(m) {
3
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
+ }
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ __export(require("./define"));
7
+ __export(require("./config"));
8
+ __export(require("./simple"));
@@ -1,44 +1,44 @@
1
- import * as AWS from 'aws-sdk';
2
- import { SimpleAWSConfig } from './config';
3
- import { S3SignedUrlParams, S3SignedUrlResult, SQSMessageBody } from './define';
4
- export declare class SimpleAWS {
5
- private queueUrls;
6
- private config;
7
- private lazyS3;
8
- private lazySqs;
9
- private lazyDynamodb;
10
- private lazyDynamodbAdmin;
11
- constructor(config?: SimpleAWSConfig);
12
- readonly s3: AWS.S3;
13
- readonly sqs: AWS.SQS;
14
- readonly dynamodb: AWS.DynamoDB.DocumentClient;
15
- readonly dynamodbAdmin: AWS.DynamoDB;
16
- getQueueUrl: (queueName: string) => Promise<string>;
17
- enqueue: (queueName: string, data: any) => Promise<number>;
18
- dequeue: <T>(queueName: string, fetchSize?: number, waitSeconds?: number, visibilityTimeout?: number) => Promise<SQSMessageBody<T>[]>;
19
- dequeueAll: <T>(queueName: string, limitSize?: number, visibilityTimeout?: number) => Promise<SQSMessageBody<T>[]>;
20
- retainMessage: (queueName: string, handle: string, seconds: number) => Promise<string>;
21
- completeMessage: (queueName: string, handle: string) => Promise<string>;
22
- completeMessages: (queueName: string, handles: string[]) => Promise<string[]>;
23
- download: (bucket: string, key: string, localPath: string) => Promise<string>;
24
- readFile: (bucket: string, key: string) => Promise<string>;
25
- upload: (bucket: string, localPath: string, key: string) => Promise<string>;
26
- writeFile: (bucket: string, key: string, content: string) => Promise<void>;
27
- getSignedUrl: (bucketName: string, key: string, operation?: "getObject" | "putObject", params?: S3SignedUrlParams | undefined) => S3SignedUrlResult;
28
- getSignedCookie: (keyPairId: string, privateKey: string, url: string, expires: number) => AWS.CloudFront.Signer.CustomPolicy;
29
- getAttachmentUrl: (bucketName: string, key: string, fileName: string, params?: S3SignedUrlParams | undefined) => S3SignedUrlResult;
30
- getDynamoDbItem: <T>(tableName: string, key: {
31
- [keyColumn: string]: string;
32
- }, defaultValue?: T | undefined) => Promise<T | undefined>;
33
- updateDynamoDbItem: (tableName: string, key: {
34
- [keyColumn: string]: string;
35
- }, columnValues: {
36
- [column: string]: any;
37
- }) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.DynamoDB.DocumentClient.UpdateItemOutput, AWS.AWSError>>;
38
- setupQueue: (queueName: string) => Promise<boolean>;
39
- setupStorage: (bucketName: string, cors: {
40
- methods: ("DELETE" | "GET" | "HEAD" | "POST" | "PUT")[];
41
- origins: string[];
42
- }) => Promise<boolean>;
43
- setupDynamoDb: (tableName: string, keyColumn: string) => Promise<boolean>;
44
- }
1
+ import * as AWS from 'aws-sdk';
2
+ import { SimpleAWSConfig } from './config';
3
+ import { S3SignedUrlParams, S3SignedUrlResult, SQSMessageBody } from './define';
4
+ export declare class SimpleAWS {
5
+ private queueUrls;
6
+ private config;
7
+ private lazyS3;
8
+ private lazySqs;
9
+ private lazyDynamodb;
10
+ private lazyDynamodbAdmin;
11
+ constructor(config?: SimpleAWSConfig);
12
+ readonly s3: AWS.S3;
13
+ readonly sqs: AWS.SQS;
14
+ readonly dynamodb: AWS.DynamoDB.DocumentClient;
15
+ readonly dynamodbAdmin: AWS.DynamoDB;
16
+ getQueueUrl: (queueName: string) => Promise<string>;
17
+ enqueue: (queueName: string, data: any) => Promise<number>;
18
+ dequeue: <T>(queueName: string, fetchSize?: number, waitSeconds?: number, visibilityTimeout?: number) => Promise<SQSMessageBody<T>[]>;
19
+ dequeueAll: <T>(queueName: string, limitSize?: number, visibilityTimeout?: number) => Promise<SQSMessageBody<T>[]>;
20
+ retainMessage: (queueName: string, handle: string, seconds: number) => Promise<string>;
21
+ completeMessage: (queueName: string, handle: string) => Promise<string>;
22
+ completeMessages: (queueName: string, handles: string[]) => Promise<string[]>;
23
+ download: (bucket: string, key: string, localPath: string) => Promise<string>;
24
+ readFile: (bucket: string, key: string) => Promise<string>;
25
+ upload: (bucket: string, localPath: string, key: string) => Promise<string>;
26
+ writeFile: (bucket: string, key: string, content: string) => Promise<void>;
27
+ getSignedUrl: (bucketName: string, key: string, operation?: "getObject" | "putObject", params?: S3SignedUrlParams | undefined) => S3SignedUrlResult;
28
+ getSignedCookie: (keyPairId: string, privateKey: string, url: string, expires: number) => AWS.CloudFront.Signer.CustomPolicy;
29
+ getAttachmentUrl: (bucketName: string, key: string, fileName: string, params?: S3SignedUrlParams | undefined) => S3SignedUrlResult;
30
+ getDynamoDbItem: <T>(tableName: string, key: {
31
+ [keyColumn: string]: string;
32
+ }, defaultValue?: T | undefined) => Promise<T | undefined>;
33
+ updateDynamoDbItem: (tableName: string, key: {
34
+ [keyColumn: string]: string;
35
+ }, columnValues: {
36
+ [column: string]: any;
37
+ }) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.DynamoDB.DocumentClient.UpdateItemOutput, AWS.AWSError>>;
38
+ setupQueue: (queueName: string) => Promise<boolean>;
39
+ setupStorage: (bucketName: string, cors: {
40
+ methods: ("DELETE" | "GET" | "HEAD" | "POST" | "PUT")[];
41
+ origins: string[];
42
+ }) => Promise<boolean>;
43
+ setupDynamoDb: (tableName: string, keyColumn: string) => Promise<boolean>;
44
+ }