@spytecgps/lambda-utils 0.0.2 → 0.0.5
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/dist/apiGwWrapper.d.ts +4 -0
- package/dist/errors/UnauthorizedError.d.ts +3 -0
- package/dist/errors/index.d.ts +2 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/response.d.ts +4 -8
- package/dist/types.d.ts +18 -10
- package/dist/validation/custom.d.ts +4 -0
- package/dist/validation/index.d.ts +3 -0
- package/dist/validation/validateEvent.d.ts +3 -0
- package/dist/wrappers/apiGwWrapper.d.ts +4 -0
- package/dist/wrappers/index.d.ts +3 -0
- package/dist/wrappers/response.d.ts +8 -0
- package/package.json +4 -2
package/dist/response.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { HandlerResponse } from './types';
|
|
2
|
+
import { APIGatewayProxyResult } from 'aws-lambda';
|
|
3
|
+
export declare const buildResponseBody: <T>(statusCode: number, message: string, data?: T) => {
|
|
2
4
|
success: boolean;
|
|
3
5
|
message: string;
|
|
4
6
|
result: T;
|
|
5
7
|
};
|
|
6
|
-
export declare const
|
|
7
|
-
headers: {
|
|
8
|
-
'Content-Type': string;
|
|
9
|
-
};
|
|
10
|
-
statusCode: number;
|
|
11
|
-
body: string;
|
|
12
|
-
};
|
|
8
|
+
export declare const buildProxyResult: <R>({ statusCode, message, data, headers, }: HandlerResponse<R>) => APIGatewayProxyResult;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { APIGatewayProxyWithLambdaAuthorizerEvent } from 'aws-lambda';
|
|
2
|
-
import { ObjectSchema
|
|
2
|
+
import { ObjectSchema } from 'joi';
|
|
3
|
+
export interface SpytecAuthorizedResources {
|
|
4
|
+
devices: string[];
|
|
5
|
+
}
|
|
3
6
|
export interface SpytecAuthContext {
|
|
4
7
|
type: 'user' | 'client';
|
|
5
8
|
userId?: string;
|
|
6
9
|
clientId: number;
|
|
7
|
-
resources:
|
|
8
|
-
devices: string[];
|
|
9
|
-
};
|
|
10
|
+
resources: SpytecAuthorizedResources;
|
|
10
11
|
}
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export declare type BaseEvent = APIGatewayProxyWithLambdaAuthorizerEvent<SpytecAuthContext>;
|
|
13
|
+
export interface WrapperArgs<E, R> {
|
|
14
|
+
event: BaseEvent;
|
|
15
|
+
schema?: ObjectSchema<E>;
|
|
16
|
+
handler: (event: E) => Promise<HandlerResponse<R>>;
|
|
15
17
|
}
|
|
16
|
-
export interface
|
|
17
|
-
|
|
18
|
+
export interface HandlerResponse<R> {
|
|
19
|
+
statusCode?: number;
|
|
20
|
+
headers?: {
|
|
21
|
+
[header: string]: boolean | number | string;
|
|
22
|
+
};
|
|
23
|
+
isBase64Encoded?: boolean;
|
|
24
|
+
message?: string;
|
|
25
|
+
data?: R;
|
|
18
26
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { APIGatewayProxyResult } from 'aws-lambda';
|
|
2
|
+
import { HandlerResponse } from '../types';
|
|
3
|
+
export declare const buildResponseBody: <T>(statusCode: number, message: string, data?: T) => {
|
|
4
|
+
success: boolean;
|
|
5
|
+
message: string;
|
|
6
|
+
result: T;
|
|
7
|
+
};
|
|
8
|
+
export declare const buildProxyResult: <R>({ statusCode, message, data, headers, }: HandlerResponse<R>) => APIGatewayProxyResult;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spytecgps/lambda-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Lambda Utils",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"version": "npm run format && git add -A src",
|
|
9
|
+
"preversion": "npm test",
|
|
9
10
|
"postversion": "git push && git push --tags",
|
|
10
11
|
"prepublishOnly": "npm test && npm run lint",
|
|
11
12
|
"prepare": "npm run build",
|
|
@@ -27,7 +28,8 @@
|
|
|
27
28
|
},
|
|
28
29
|
"homepage": "https://github.com/spytecgps/lambda-utils#readme",
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"joi": "^17.4.0"
|
|
31
|
+
"joi": "^17.4.0",
|
|
32
|
+
"qs": "^6.10.1"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
35
|
"@types/aws-lambda": "^8.10.76",
|