ag-common 0.0.15 → 0.0.16
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.
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { APIGatewayEvent, APIGatewayProxyResult } from 'aws-lambda';
|
|
2
2
|
import { User } from '../../ui/helpers/jwt';
|
|
3
|
-
|
|
3
|
+
import { TLang } from '../../common/helpers/i18n';
|
|
4
|
+
export declare type NextType<T> = ({ event, body, params, userProfile, lang, }: {
|
|
4
5
|
params: Record<string, string>;
|
|
5
6
|
event: APIGatewayEvent;
|
|
6
7
|
body: T;
|
|
7
8
|
userProfile?: User;
|
|
9
|
+
lang: TLang;
|
|
8
10
|
}) => Promise<APIGatewayProxyResult>;
|
|
9
11
|
export declare function validateOpenApi<T>({ event, next, authorized, schema, COGNITO_USER_POOL_ID, }: {
|
|
10
12
|
COGNITO_USER_POOL_ID: string;
|
|
@@ -18,6 +18,7 @@ const validations_1 = require("./validations");
|
|
|
18
18
|
const log_1 = require("../../common/helpers/log");
|
|
19
19
|
const object_1 = require("../../common/helpers/object");
|
|
20
20
|
const api_1 = require("./api");
|
|
21
|
+
const i18n_1 = require("../../common/helpers/i18n");
|
|
21
22
|
//
|
|
22
23
|
const getOperation = ({ path, method, resource, schema, }) => {
|
|
23
24
|
var _a;
|
|
@@ -42,7 +43,7 @@ const getOperation = ({ path, method, resource, schema, }) => {
|
|
|
42
43
|
return { operation, pathParams };
|
|
43
44
|
};
|
|
44
45
|
function validateOpenApi({ event, next, authorized, schema, COGNITO_USER_POOL_ID, }) {
|
|
45
|
-
var _a, _b, _c, _d;
|
|
46
|
+
var _a, _b, _c, _d, _e;
|
|
46
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
48
|
const request = {
|
|
48
49
|
method: event.httpMethod,
|
|
@@ -110,6 +111,7 @@ function validateOpenApi({ event, next, authorized, schema, COGNITO_USER_POOL_ID
|
|
|
110
111
|
event,
|
|
111
112
|
body: (event.body && JSON.parse(event.body)),
|
|
112
113
|
userProfile,
|
|
114
|
+
lang: (0, i18n_1.getValidatedLang)((_e = event.headers['x-lang']) !== null && _e !== void 0 ? _e : ''),
|
|
113
115
|
});
|
|
114
116
|
return res;
|
|
115
117
|
});
|