@spytecgps/lambda-utils 3.0.0 → 3.0.2
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/errors/GoneError.d.ts +6 -0
- package/dist/errors/index.d.ts +2 -1
- package/dist/index.js +10 -3
- package/dist/middleware/index.d.ts +2 -1
- package/package.json +1 -1
- package/dist/wrappers/apiGatewayEventWrapper.d.ts +0 -4
- package/dist/wrappers/index.d.ts +0 -5
- package/dist/wrappers/response.d.ts +0 -8
- package/dist/wrappers/sqsEventWrapper.d.ts +0 -3
- package/dist/wrappers/sqsEventWrapperWithReturn.d.ts +0 -3
package/dist/errors/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import BadRequestError from './BadRequestError';
|
|
|
2
2
|
import BaseError from './BaseError';
|
|
3
3
|
import ConflictError from './ConflictError';
|
|
4
4
|
import ForbiddenError from './ForbiddenError';
|
|
5
|
+
import GoneError from './GoneError';
|
|
5
6
|
import HttpError from './HttpError';
|
|
6
7
|
import NotFoundError from './NotFoundError';
|
|
7
8
|
import UnauthorizedError from './UnauthorizedError';
|
|
8
|
-
export { BadRequestError,
|
|
9
|
+
export { BadRequestError, BaseError, ConflictError, ForbiddenError, GoneError, HttpError, NotFoundError, UnauthorizedError, };
|
package/dist/index.js
CHANGED
|
@@ -79,6 +79,12 @@ class ForbiddenError extends HttpError {
|
|
|
79
79
|
name = 'ForbiddenError';
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
class GoneError extends HttpError {
|
|
83
|
+
code = 410;
|
|
84
|
+
statusCode = 410;
|
|
85
|
+
name = 'GoneError';
|
|
86
|
+
}
|
|
87
|
+
|
|
82
88
|
class NotFoundError extends HttpError {
|
|
83
89
|
code = 404;
|
|
84
90
|
statusCode = 404;
|
|
@@ -176,7 +182,7 @@ const normalizerMiddleware = () => {
|
|
|
176
182
|
};
|
|
177
183
|
};
|
|
178
184
|
|
|
179
|
-
const offlineAuth = ({ authFunctionName = 'spytec-web-api-auth-prod-
|
|
185
|
+
const offlineAuth = ({ authFunctionName = 'spytec-web-api-auth-prod-AuthorizerFunctionV4', enabled = isOffline(), logger, }) => {
|
|
180
186
|
const lambdaClient = new clientLambda.LambdaClient({ region: process.env.AWS_REGION });
|
|
181
187
|
return {
|
|
182
188
|
before: async (request) => {
|
|
@@ -305,7 +311,7 @@ const getBaseMiddlewares = ({ logger }) => [
|
|
|
305
311
|
ioLogger({ logger }),
|
|
306
312
|
];
|
|
307
313
|
// Function that returns API Gateway middlewares with required logger
|
|
308
|
-
const getApiGatewayMiddlewares = ({ logger }) => [
|
|
314
|
+
const getApiGatewayMiddlewares = ({ logger, offlineAuthEnabled = true }) => [
|
|
309
315
|
httpResponseSerializer({
|
|
310
316
|
serializers: [
|
|
311
317
|
{
|
|
@@ -324,7 +330,7 @@ const getApiGatewayMiddlewares = ({ logger }) => [
|
|
|
324
330
|
default: 'application/json',
|
|
325
331
|
}),
|
|
326
332
|
responseWrapper({ logger }),
|
|
327
|
-
offlineAuth({ logger }),
|
|
333
|
+
offlineAuth({ logger, enabled: offlineAuthEnabled }),
|
|
328
334
|
normalizerMiddleware(),
|
|
329
335
|
];
|
|
330
336
|
|
|
@@ -618,6 +624,7 @@ exports.BadRequestError = BadRequestError;
|
|
|
618
624
|
exports.BaseError = BaseError;
|
|
619
625
|
exports.ConflictError = ConflictError;
|
|
620
626
|
exports.ForbiddenError = ForbiddenError;
|
|
627
|
+
exports.GoneError = GoneError;
|
|
621
628
|
exports.HttpError = HttpError;
|
|
622
629
|
exports.LambdaCache = LambdaCache;
|
|
623
630
|
exports.NotFoundError = NotFoundError;
|
|
@@ -14,6 +14,7 @@ interface BaseMiddlewaresOptions {
|
|
|
14
14
|
}
|
|
15
15
|
interface ApiGatewayMiddlewaresOptions {
|
|
16
16
|
logger: HapnLogger;
|
|
17
|
+
offlineAuthEnabled?: boolean;
|
|
17
18
|
}
|
|
18
19
|
declare const getBaseMiddlewares: ({ logger }: BaseMiddlewaresOptions) => ({
|
|
19
20
|
before: ({ event, context }: {
|
|
@@ -23,7 +24,7 @@ declare const getBaseMiddlewares: ({ logger }: BaseMiddlewaresOptions) => ({
|
|
|
23
24
|
} | middy.MiddlewareObj<any, any, Error, import("aws-lambda").Context> | {
|
|
24
25
|
before: (request: any) => string;
|
|
25
26
|
})[];
|
|
26
|
-
declare const getApiGatewayMiddlewares: ({ logger }: ApiGatewayMiddlewaresOptions) => (middy.MiddlewareObj<any, any, Error, import("aws-lambda").Context> | {
|
|
27
|
+
declare const getApiGatewayMiddlewares: ({ logger, offlineAuthEnabled }: ApiGatewayMiddlewaresOptions) => (middy.MiddlewareObj<any, any, Error, import("aws-lambda").Context> | {
|
|
27
28
|
before: (request: any) => Promise<void>;
|
|
28
29
|
} | {
|
|
29
30
|
after: (req: any) => void;
|
package/package.json
CHANGED
package/dist/wrappers/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import apiGatewayEventWrapper from './apiGatewayEventWrapper';
|
|
2
|
-
import sqsEventWrapper from './sqsEventWrapper';
|
|
3
|
-
import sqsEventWrapperWithReturn from './sqsEventWrapperWithReturn';
|
|
4
|
-
export { apiGatewayEventWrapper, sqsEventWrapper, sqsEventWrapperWithReturn };
|
|
5
|
-
export * from './response';
|
|
@@ -1,8 +0,0 @@
|
|
|
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 | undefined;
|
|
7
|
-
};
|
|
8
|
-
export declare const buildProxyResult: <R>({ statusCode, message, data, headers, multiValueHeaders, rawResult, stringifyBody, }: HandlerResponse<R>) => APIGatewayProxyResult;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { BaseRecord, SQSWrapperArgsWithReturn } from '../types';
|
|
2
|
-
declare const sqsEventWrapper: <RecordType extends BaseRecord, T>({ event, context, schema, handler, singleHandler, mode, }: SQSWrapperArgsWithReturn<RecordType, T>) => Promise<T | T[]>;
|
|
3
|
-
export default sqsEventWrapper;
|