@spytecgps/lambda-utils 2.0.2-rc1 → 2.0.3
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/BadRequestError.d.ts +6 -6
- package/dist/errors/BaseError.d.ts +4 -3
- package/dist/errors/ConflictError.d.ts +6 -6
- package/dist/errors/ForbiddenError.d.ts +6 -6
- package/dist/errors/HttpError.d.ts +8 -8
- package/dist/errors/NotFoundError.d.ts +6 -6
- package/dist/errors/UnauthorizedError.d.ts +6 -6
- package/dist/errors/index.d.ts +8 -6
- package/dist/index.d.ts +7 -7
- package/dist/index.js +1 -1
- package/dist/logger/index.d.ts +4 -4
- package/dist/middleware/contextualLogger.d.ts +15 -15
- package/dist/middleware/index.d.ts +12 -12
- package/dist/middleware/ioLogger.d.ts +1 -1
- package/dist/middleware/middleware.test.d.ts +1 -1
- package/dist/middleware/responseWrapper.d.ts +3 -3
- package/dist/middleware/types.d.ts +7 -7
- package/dist/middleware/validation.d.ts +9 -9
- package/dist/types.d.ts +58 -58
- package/dist/utils/cache.d.ts +23 -23
- package/dist/utils/cacheWrapper.d.ts +2 -2
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/timeOut.d.ts +1 -1
- package/dist/validation/custom.d.ts +18 -18
- package/dist/validation/index.d.ts +6 -6
- package/dist/validation/requestContext.d.ts +14 -14
- package/dist/validation/validateEvent.d.ts +3 -3
- package/dist/wrappers/apiGatewayEventWrapper.d.ts +4 -4
- package/dist/wrappers/index.d.ts +4 -4
- package/dist/wrappers/response.d.ts +8 -8
- package/dist/wrappers/sqsEventWrapper.d.ts +3 -3
- package/package.json +3 -4
- package/dist/errors/BadRequestError.js +0 -28
- package/dist/errors/BaseError.js +0 -24
- package/dist/errors/HttpError.js +0 -32
- package/dist/errors/NotFoundError.js +0 -28
- package/dist/errors/UnauthorizedError.js +0 -28
- package/dist/errors/index.js +0 -12
- package/dist/logger/logger.d.ts +0 -3
- package/dist/logger/logger.js +0 -57
- package/dist/middleware/contextualLogger.js +0 -87
- package/dist/middleware/index.js +0 -62
- package/dist/middleware/ioLogger.js +0 -14
- package/dist/middleware/middleware.test.js +0 -167
- package/dist/middleware/responseWrapper.js +0 -12
- package/dist/middleware/types.js +0 -2
- package/dist/middleware/validation.js +0 -27
- package/dist/types.js +0 -2
- package/dist/validation/custom.js +0 -122
- package/dist/validation/index.js +0 -20
- package/dist/validation/requestContext.js +0 -54
- package/dist/validation/validateEvent.js +0 -25
- package/dist/wrappers/apiGatewayEventWrapper.js +0 -82
- package/dist/wrappers/index.js +0 -21
- package/dist/wrappers/response.js +0 -35
- package/dist/wrappers/sqsEventWrapper.js +0 -116
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class BadRequestError extends HttpError {
|
|
3
|
-
code: number;
|
|
4
|
-
statusCode: number;
|
|
5
|
-
name: string;
|
|
6
|
-
}
|
|
1
|
+
import HttpError from './HttpError';
|
|
2
|
+
export default class BadRequestError extends HttpError {
|
|
3
|
+
code: number;
|
|
4
|
+
statusCode: number;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export default class BaseError extends Error {
|
|
2
|
+
code: 500;
|
|
3
|
+
statusCode: 500;
|
|
4
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class ConflictError extends HttpError {
|
|
3
|
-
code: number;
|
|
4
|
-
statusCode: number;
|
|
5
|
-
name: string;
|
|
6
|
-
}
|
|
1
|
+
import HttpError from './HttpError';
|
|
2
|
+
export default class ConflictError extends HttpError {
|
|
3
|
+
code: number;
|
|
4
|
+
statusCode: number;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class ForbiddenError extends HttpError {
|
|
3
|
-
code: number;
|
|
4
|
-
statusCode: number;
|
|
5
|
-
name: string;
|
|
6
|
-
}
|
|
1
|
+
import HttpError from './HttpError';
|
|
2
|
+
export default class ForbiddenError extends HttpError {
|
|
3
|
+
code: number;
|
|
4
|
+
statusCode: number;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
abstract code: number;
|
|
3
|
-
abstract statusCode: number;
|
|
4
|
-
}
|
|
5
|
-
export declare class BaseError extends Error {
|
|
6
|
-
code: 500;
|
|
7
|
-
statusCode: 500;
|
|
8
|
-
}
|
|
1
|
+
export default abstract class HttpError extends Error {
|
|
2
|
+
abstract code: number;
|
|
3
|
+
abstract statusCode: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class BaseError extends Error {
|
|
6
|
+
code: 500;
|
|
7
|
+
statusCode: 500;
|
|
8
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class NotFoundError extends HttpError {
|
|
3
|
-
code: number;
|
|
4
|
-
statusCode: number;
|
|
5
|
-
name: string;
|
|
6
|
-
}
|
|
1
|
+
import HttpError from './HttpError';
|
|
2
|
+
export default class NotFoundError extends HttpError {
|
|
3
|
+
code: number;
|
|
4
|
+
statusCode: number;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class UnauthorizedError extends HttpError {
|
|
3
|
-
code: number;
|
|
4
|
-
statusCode: number;
|
|
5
|
-
name: string;
|
|
6
|
-
}
|
|
1
|
+
import HttpError from './HttpError';
|
|
2
|
+
export default class UnauthorizedError extends HttpError {
|
|
3
|
+
code: number;
|
|
4
|
+
statusCode: number;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import BadRequestError from './BadRequestError';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import BadRequestError from './BadRequestError';
|
|
2
|
+
import BaseError from './BaseError';
|
|
3
|
+
import ConflictError from './ConflictError';
|
|
4
|
+
import ForbiddenError from './ForbiddenError';
|
|
5
|
+
import HttpError from './HttpError';
|
|
6
|
+
import NotFoundError from './NotFoundError';
|
|
7
|
+
import UnauthorizedError from './UnauthorizedError';
|
|
8
|
+
export { BadRequestError, NotFoundError, UnauthorizedError, ForbiddenError, ConflictError, HttpError, BaseError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './wrappers';
|
|
2
|
-
export * from './errors';
|
|
3
|
-
export * from './validation';
|
|
4
|
-
export * from './types';
|
|
5
|
-
export * from './middleware';
|
|
6
|
-
export * from './logger';
|
|
7
|
-
export * from './utils';
|
|
1
|
+
export * from './wrappers';
|
|
2
|
+
export * from './errors';
|
|
3
|
+
export * from './validation';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './middleware';
|
|
6
|
+
export * from './logger';
|
|
7
|
+
export * from './utils';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["lambda-utils"]=r():e["lambda-utils"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var a in t)e.o(t,a)&&!e.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:t[a]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{BadRequestError:()=>x,
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["lambda-utils"]=r():e["lambda-utils"]=r()}(global,(()=>(()=>{"use strict";var e={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var a in t)e.o(t,a)&&!e.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:t[a]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{BadRequestError:()=>x,BaseError:()=>N,ConflictError:()=>_,ForbiddenError:()=>T,HttpError:()=>h,LambdaCache:()=>Y,NotFoundError:()=>z,SpytecJoi:()=>v,UnauthorizedError:()=>w,apiGatewayEventWrapper:()=>I,apiGatewayMiddlewares:()=>X,apiGatewayMiddy:()=>Q,buildProxyResult:()=>O,buildResponseBody:()=>S,defaultApiSchema:()=>A,getAuthorizerValidator:()=>f,getRequestContextValidator:()=>C,httpErrorHandler:()=>U(),httpResponseSerializer:()=>H(),iccidSchema:()=>b,imeiSchema:()=>g,json:()=>m,logger:()=>a,middy:()=>K,promiseWithCache:()=>ee,promiseWithTimeout:()=>re,requestContextValidator:()=>E,resetLogger:()=>o,sqsEventWrapper:()=>R,urlEncoded:()=>y,validateEvent:()=>j,validatorMiddleware:()=>F,withRequest:()=>t.withRequest});const t=require("@spytecgps/sdk-logger");let a=(0,t.createLogger)();const o=e=>(a=(0,t.createLogger)({base:e}),a),s=require("dayjs");var n=e.n(s);const i=require("dayjs/plugin/timezone");var l=e.n(i);const c=require("dayjs/plugin/utc");var d=e.n(c);const u=require("joi"),p=require("qs");n().extend(d()),n().extend(l());const m=u.extend((e=>({type:"object",base:e.object(),messages:{"json.valid":"must be valid JSON"},coerce(e){try{return{value:JSON.parse(e)}}catch(e){return null}},validate:(e,r)=>e?{value:e}:{value:e,errors:r.error("json.valid")}}))),y=u.extend((e=>({type:"object",base:e.object(),coerce:e=>({value:p.parse(e)})}))),g=u.string().regex(/^\d{15,16}$/).message("Invalid IMEI"),b=u.string().regex(/^[0-9A-Za-z]{18,22}$/).message("Invalid ICCID"),v=u.extend((e=>({type:"imei",messages:"Invalid IMEI",base:e.string().regex(/^\d{15,16}$/)})),(e=>({type:"iccid",messages:"Invalid ICCID",base:e.string().regex(/^[0-9A-Za-z]{18,22}$/)})),(e=>({type:"urlEncodedObject",base:e.object(),coerce:e=>({value:p.parse(e)})})),(e=>({type:"jsonObject",base:e.object(),coerce(e){try{return{value:JSON.parse(e)}}catch(e){return null}},validate:(e,r)=>e?{value:e}:{value:e,errors:r.error("json.valid")}})),(e=>({type:"delimitedArray",base:e.array().default([]),coerce:e=>({value:e.split?e.split(","):e})})),(e=>({type:"queryStringParameters",messages:"Missing query parameters",base:e.object().required()})),(e=>({type:"date",base:e.date(),prepare(e,r){try{const r=n().tz(e,"UTC");if(r.isValid())return{value:r.toDate()}}catch(e){return r.error("any.invalid")}}})),(e=>({type:"jsonArray",base:e.array(),coerce(e){try{return{value:JSON.parse(e)}}catch(e){return{value:null}}},validate:(e,r)=>Array.isArray(e)?{value:e}:{value:e,errors:r.error("jsonArray.schema")}})),(e=>({type:"base64ThenUriEncodedObject",base:e.object(),coerce(e){try{const r=decodeURIComponent(Buffer.from(e,"base64").toString());return{value:JSON.parse(r)}}catch(e){return null}},validate:(e,r)=>e?{value:e}:{value:e,errors:r.error("json.valid")}})));class h extends Error{}class w extends h{code=401;statusCode=401;name="UnauthorizedError"}const f=({scope:e,type:r}={})=>u.object({clientId:u.number(),resources:m.object({}),scope:e?u.string().pattern(new RegExp(`${e}`)).error((()=>new w(`missing scope ${e}`))):u.optional(),type:r?u.any().valid(r).error((()=>new w(`missing user type ${r}`))):u.optional(),enterprise:u.boolean().default(!1),maintenanceModule:u.boolean().default(!1)}),E=u.object({authorizer:f()}),C=(e={})=>u.object({authorizer:f(e)});class x extends h{code=400;statusCode=400;name="BadRequestError"}const j=(e,r,t)=>{if(!r)return a.warn("skipping validation"),e;const{error:o,value:s}=r.validate(e,{allowUnknown:t?.allowUnknown||!0,errors:{label:"key",wrap:{label:!1}}});if(o)throw a.error({error:o},"Validation error"),o.isJoi?new x(o.message):o;return s},A=v.object({requestContext:C()}),q={"Content-Type":"application/json","Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":!0},S=(e,r,t)=>({success:e<400,message:r,result:t||void 0}),O=({statusCode:e=200,message:r="ok",data:t,headers:a={},rawResult:o=!1,stringifyBody:s=!0})=>{const n=o?t:S(e,r,t),i=s?n&&JSON.stringify(n):t;return{headers:{...q,...a},statusCode:e,body:i}},I=async({event:e,context:r,schema:o,handler:s})=>{e&&r&&(0,t.withRequest)(e,r);try{const r=j(e,o),t=await s(r);return O(t)}catch(r){return a.error({err:r,event:(n=e,{resource:n.resource,httpMethod:n.httpMethod,queryStringParameters:n.queryStringParameters,pathParameters:n.pathParameters,body:n.body})},"apiGatewayWrapper - caught error"),O({statusCode:r.code||500,message:r.message||"Error"})}var n},R=async({event:e,context:r,schema:o,handler:s,singleHandler:n,mode:i="serial"})=>{e&&r&&(0,t.withRequest)(e,r);try{const r=j(e,o);await async function(e,r,t,a){if(!r&&!t)throw new Error("handler or singleHandler not defined");if(r)await r(e);else if(t){const r=e.Records;if("serial"===a)for(const e of r)await t(e);else"parallel"===a&&await Promise.all(r.map((e=>t(e))))}}(r,s,n,i)}catch(r){throw a.error({err:r,event:(l=e,(l.Records||[]).map((e=>({messageId:e.messageId,body:e.body,messageAttributes:e.messageAttributes}))))},"sqsEventWrapper - caught error"),r}var l};class N extends Error{code;statusCode}class _ extends h{code=409;statusCode=409;name="ConflictError"}class T extends h{code=403;statusCode=403;name="ForbiddenError"}class z extends h{code=404;statusCode=404;name="NotFoundError"}const M=require("@middy/core");var P=e.n(M);const $=require("@middy/http-error-handler");var U=e.n($);const G=require("@middy/http-response-serializer");var H=e.n(G);const k="_X_AMZN_TRACE_ID",J="x-correlation-",W=`${J}id`,B=`${J}trace-id`,D=(()=>{const e={};return{before:async({event:r,context:t})=>{if(t&&(e.requestId=t?.awsRequestId,e.function=t.functionName),e.requestId||(e.requestId=r?.requestContext?.requestId),Object.prototype.hasOwnProperty.call(r,"headers")){const t=r;Object.keys(t).forEach((r=>{r.toLowerCase().startsWith(J)&&(e[r]=t[r])}))}process.env[k]&&(e[B]=process.env[k]),e[W]||(e[W]=t?.awsRequestId),e.contextUserId=r?.requestContext?.authorizer?.claims?.userId,e.contextUserEmail=r?.requestContext?.authorizer?.claims?.email,o(e)}}})(),L=require("@middy/input-output-logger"),V=e.n(L)()({logger:e=>{const r=e?.event?"event":"response";a.info(r,e)}}),F=({schema:e,allowUnknown:r=!0})=>({before:t=>{const{error:o,value:s}=e.validate(t.event,{allowUnknown:r,errors:{label:"key",wrap:{label:!1}}});if(o)throw a.error("Validation error",{error:o}),o.isJoi?new x(o.message):o;t.event=s}}),Z=[D,V],X=[H()({serializers:[{regex:/^application\/xml$/,serializer:({body:e})=>`<message>${e}</message>`},{regex:/^application\/json$/,serializer:({body:e})=>JSON.stringify(e)},{regex:/^text\/plain$/,serializer:({body:e})=>e}],default:"application/json"}),U()({logger:e=>a.error(e)}),{after:e=>{e.response=O(e.response)}}],K=e=>P()(e).use([...Z]),Q=e=>P()(e).use([...Z,...X]);class Y{collectionName;constructor(e){this.collectionName=e??`${process.env.AWS_LAMBDA_FUNCTION_NAME}-${process.env.AWS_LAMBDA_FUNCTION_VERSION}`,global.CACHE_STORAGE||(global.CACHE_STORAGE={}),global.CACHE_STORAGE[this.collectionName]||(global.CACHE_STORAGE[this.collectionName]=new Map)}set(e,r,t){const a=1e3*t+Date.now();global.CACHE_STORAGE[this.collectionName].set(e,{value:r,expire:a})}get(e){if(!e)throw new Error("key is required!");const r=global.CACHE_STORAGE[this.collectionName].get(e);return r?!r.expire||r.expire>Date.now()?r.value:this.remove(e):null}remove(e){global.CACHE_STORAGE[this.collectionName].get(e)&&global.CACHE_STORAGE[this.collectionName].delete(e)}}const ee=async(e,r,t,a)=>{let o=r.get(t);return o||(o=await e(),r.set(t,o,a)),o},re=(e,r,t=new Error("Promise timed out"))=>{const a=new Promise(((e,a)=>{setTimeout((()=>{a(t)}),r)}));return Promise.race([e,a])};return r})()));
|
package/dist/logger/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { withRequest } from '@spytecgps/sdk-logger';
|
|
2
|
-
declare let logger:
|
|
3
|
-
declare const resetLogger: (metadata: any) => HapnLogger;
|
|
4
|
-
export { logger, withRequest, resetLogger };
|
|
1
|
+
import { HapnLogger, withRequest } from '@spytecgps/sdk-logger';
|
|
2
|
+
declare let logger: HapnLogger;
|
|
3
|
+
declare const resetLogger: (metadata: any) => HapnLogger;
|
|
4
|
+
export { logger, withRequest, resetLogger };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adapted from https://github.com/FormidableLabs/pino-lambda/blob/master/src/request.ts
|
|
3
|
-
*/
|
|
4
|
-
export declare const contextualLogger: () => {
|
|
5
|
-
before: ({ event, context }: {
|
|
6
|
-
event: any;
|
|
7
|
-
context: any;
|
|
8
|
-
}) => Promise<void>;
|
|
9
|
-
};
|
|
10
|
-
export declare const contextualLoggerMiddleware: {
|
|
11
|
-
before: ({ event, context }: {
|
|
12
|
-
event: any;
|
|
13
|
-
context: any;
|
|
14
|
-
}) => Promise<void>;
|
|
15
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Adapted from https://github.com/FormidableLabs/pino-lambda/blob/master/src/request.ts
|
|
3
|
+
*/
|
|
4
|
+
export declare const contextualLogger: () => {
|
|
5
|
+
before: ({ event, context }: {
|
|
6
|
+
event: any;
|
|
7
|
+
context: any;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
export declare const contextualLoggerMiddleware: {
|
|
11
|
+
before: ({ event, context }: {
|
|
12
|
+
event: any;
|
|
13
|
+
context: any;
|
|
14
|
+
}) => Promise<void>;
|
|
15
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import rawMiddy from '@middy/core';
|
|
2
|
-
import httpErrorHandler from '@middy/http-error-handler';
|
|
3
|
-
import httpResponseSerializer from '@middy/http-response-serializer';
|
|
4
|
-
import { Context as LambdaContext } from 'aws-lambda/handler';
|
|
5
|
-
import { MiddyInputHandler } from './types';
|
|
6
|
-
import { validatorMiddleware } from './validation';
|
|
7
|
-
declare const apiGatewayMiddlewares: (rawMiddy.MiddlewareObj<any, any, Error, LambdaContext> | {
|
|
8
|
-
after: (req: any) => void;
|
|
9
|
-
})[];
|
|
10
|
-
declare const middy: <TEvent, TResult, TContext extends LambdaContext>(handler: MiddyInputHandler<TEvent, TResult, TContext>) => rawMiddy.MiddyfiedHandler<TEvent, TResult, Error, TContext>;
|
|
11
|
-
declare const apiGatewayMiddy: <TEvent, TResult, TContext extends LambdaContext>(handler: MiddyInputHandler<TEvent, TResult, TContext>) => rawMiddy.MiddyfiedHandler<TEvent, TResult, Error, TContext>;
|
|
12
|
-
export { middy, apiGatewayMiddy, httpErrorHandler, httpResponseSerializer, validatorMiddleware, apiGatewayMiddlewares };
|
|
1
|
+
import rawMiddy from '@middy/core';
|
|
2
|
+
import httpErrorHandler from '@middy/http-error-handler';
|
|
3
|
+
import httpResponseSerializer from '@middy/http-response-serializer';
|
|
4
|
+
import { Context as LambdaContext } from 'aws-lambda/handler';
|
|
5
|
+
import { MiddyInputHandler } from './types';
|
|
6
|
+
import { validatorMiddleware } from './validation';
|
|
7
|
+
declare const apiGatewayMiddlewares: (rawMiddy.MiddlewareObj<any, any, Error, LambdaContext> | {
|
|
8
|
+
after: (req: any) => void;
|
|
9
|
+
})[];
|
|
10
|
+
declare const middy: <TEvent, TResult, TContext extends LambdaContext>(handler: MiddyInputHandler<TEvent, TResult, TContext>) => rawMiddy.MiddyfiedHandler<TEvent, TResult, Error, TContext>;
|
|
11
|
+
declare const apiGatewayMiddy: <TEvent, TResult, TContext extends LambdaContext>(handler: MiddyInputHandler<TEvent, TResult, TContext>) => rawMiddy.MiddyfiedHandler<TEvent, TResult, Error, TContext>;
|
|
12
|
+
export { middy, apiGatewayMiddy, httpErrorHandler, httpResponseSerializer, validatorMiddleware, apiGatewayMiddlewares };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ioLoggerMiddleware: import("@middy/core").MiddlewareObj<any, any, Error, import("aws-lambda").Context>;
|
|
1
|
+
export declare const ioLoggerMiddleware: import("@middy/core").MiddlewareObj<any, any, Error, import("aws-lambda").Context>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const responseWrapperMiddleware: () => {
|
|
2
|
-
after: (req: any) => void;
|
|
3
|
-
};
|
|
1
|
+
export declare const responseWrapperMiddleware: () => {
|
|
2
|
+
after: (req: any) => void;
|
|
3
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { APIGatewayProxyResult, Context as LambdaContext } from 'aws-lambda';
|
|
2
|
-
import { Callback as LambdaCallback } from 'aws-lambda/handler';
|
|
3
|
-
export type MiddyInputPromiseHandler<TEvent, TResult, TContext extends LambdaContext = LambdaContext> = (event: TEvent, context: TContext) => Promise<TResult>;
|
|
4
|
-
export interface APIResult<T = any> extends Omit<APIGatewayProxyResult, 'body'> {
|
|
5
|
-
body: T;
|
|
6
|
-
}
|
|
7
|
-
export type MiddyInputHandler<TEvent, TResult, TContext extends LambdaContext = LambdaContext> = (event: TEvent, context: TContext, callback: LambdaCallback<TResult>) => Promise<TResult>;
|
|
1
|
+
import { APIGatewayProxyResult, Context as LambdaContext } from 'aws-lambda';
|
|
2
|
+
import { Callback as LambdaCallback } from 'aws-lambda/handler';
|
|
3
|
+
export type MiddyInputPromiseHandler<TEvent, TResult, TContext extends LambdaContext = LambdaContext> = (event: TEvent, context: TContext) => Promise<TResult>;
|
|
4
|
+
export interface APIResult<T = any> extends Omit<APIGatewayProxyResult, 'body'> {
|
|
5
|
+
body: T;
|
|
6
|
+
}
|
|
7
|
+
export type MiddyInputHandler<TEvent, TResult, TContext extends LambdaContext = LambdaContext> = (event: TEvent, context: TContext, callback: LambdaCallback<TResult>) => Promise<TResult>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Joi from 'joi';
|
|
2
|
-
interface ValidatorOpts {
|
|
3
|
-
schema: Joi.Schema;
|
|
4
|
-
allowUnknown?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare const validatorMiddleware: ({ schema, allowUnknown }: ValidatorOpts) => {
|
|
7
|
-
before: (request: any) => void;
|
|
8
|
-
};
|
|
9
|
-
export {};
|
|
1
|
+
import Joi from 'joi';
|
|
2
|
+
interface ValidatorOpts {
|
|
3
|
+
schema: Joi.Schema;
|
|
4
|
+
allowUnknown?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const validatorMiddleware: ({ schema, allowUnknown }: ValidatorOpts) => {
|
|
7
|
+
before: (request: any) => void;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { APIGatewayEventRequestContext, APIGatewayProxyEvent, APIGatewayProxyWithCognitoAuthorizerEvent, APIGatewayProxyWithLambdaAuthorizerEvent, Context, SQSEvent, SQSRecord } from 'aws-lambda';
|
|
2
|
-
import { Callback } from 'aws-lambda/handler';
|
|
3
|
-
import { APIGatewayProxyEventBase } from 'aws-lambda/trigger/api-gateway-proxy';
|
|
4
|
-
import { ObjectSchema } from 'joi';
|
|
5
|
-
import * as Joi from 'joi';
|
|
6
|
-
export interface SpytecAuthorizedResources {
|
|
7
|
-
devices: string[];
|
|
8
|
-
boundaries: number[];
|
|
9
|
-
}
|
|
10
|
-
export type AuthClass = 'user' | 'client' | 'system';
|
|
11
|
-
export type DevicesAccess = 'full' | 'limited';
|
|
12
|
-
export type BoundariesAccess = 'full' | 'limited';
|
|
13
|
-
export interface SpytecAuthContext {
|
|
14
|
-
type: AuthClass;
|
|
15
|
-
userId?: string;
|
|
16
|
-
clientId: number;
|
|
17
|
-
devicesAccess: DevicesAccess;
|
|
18
|
-
boundariesAccess: BoundariesAccess;
|
|
19
|
-
minAccessDate?: string;
|
|
20
|
-
resources: SpytecAuthorizedResources;
|
|
21
|
-
principalId: string;
|
|
22
|
-
scope?: string;
|
|
23
|
-
enterprise?: boolean;
|
|
24
|
-
maintenanceModule?: boolean;
|
|
25
|
-
}
|
|
26
|
-
export type BaseAPIGatewayEvent = Omit<APIGatewayProxyEventBase<SpytecAuthContext>, 'pathParameters' | 'queryStringParameters' | 'body'>;
|
|
27
|
-
export interface WrapperArgs<E, R> {
|
|
28
|
-
event: APIGatewayProxyEvent;
|
|
29
|
-
context?: APIGatewayEventRequestContext;
|
|
30
|
-
schema?: ObjectSchema<E>;
|
|
31
|
-
handler: Handler<E, R>;
|
|
32
|
-
}
|
|
33
|
-
export type UserAPIHandler<TEvent = APIGatewayProxyWithLambdaAuthorizerEvent<SpytecAuthContext>, TResult = any> = (event: TEvent, context: APIGatewayEventRequestContext, callback: Callback<TResult>) => void | Promise<TResult>;
|
|
34
|
-
export type ServerAPIHandler<TResult = any> = (event: APIGatewayProxyWithCognitoAuthorizerEvent, context: APIGatewayEventRequestContext, callback: Callback<TResult>) => void | Promise<TResult>;
|
|
35
|
-
export type Handler<E, R> = (event: E) => Promise<HandlerResponse<R>>;
|
|
36
|
-
export interface HandlerResponse<R> {
|
|
37
|
-
statusCode?: number;
|
|
38
|
-
headers?: {
|
|
39
|
-
[header: string]: boolean | number | string;
|
|
40
|
-
};
|
|
41
|
-
isBase64Encoded?: boolean;
|
|
42
|
-
message?: string;
|
|
43
|
-
data?: R;
|
|
44
|
-
rawResult?: boolean;
|
|
45
|
-
stringifyBody?: boolean;
|
|
46
|
-
}
|
|
47
|
-
export type BaseRecord = Omit<SQSRecord, 'body' | 'messageAttributes'>;
|
|
48
|
-
export interface MessageEvent<RecordType extends BaseRecord> {
|
|
49
|
-
Records: RecordType[];
|
|
50
|
-
}
|
|
51
|
-
export type SQSWrapperArgs<RecordType extends BaseRecord> = {
|
|
52
|
-
event: SQSEvent;
|
|
53
|
-
context?: Context;
|
|
54
|
-
schema?: Joi.ObjectSchema<MessageEvent<RecordType>>;
|
|
55
|
-
handler?: (e: MessageEvent<RecordType>) => void | Promise<void>;
|
|
56
|
-
singleHandler?: (record: RecordType) => void | Promise<void>;
|
|
57
|
-
mode?: 'serial' | 'parallel';
|
|
58
|
-
};
|
|
1
|
+
import { APIGatewayEventRequestContext, APIGatewayProxyEvent, APIGatewayProxyWithCognitoAuthorizerEvent, APIGatewayProxyWithLambdaAuthorizerEvent, Context, SQSEvent, SQSRecord } from 'aws-lambda';
|
|
2
|
+
import { Callback } from 'aws-lambda/handler';
|
|
3
|
+
import { APIGatewayProxyEventBase } from 'aws-lambda/trigger/api-gateway-proxy';
|
|
4
|
+
import { ObjectSchema } from 'joi';
|
|
5
|
+
import * as Joi from 'joi';
|
|
6
|
+
export interface SpytecAuthorizedResources {
|
|
7
|
+
devices: string[];
|
|
8
|
+
boundaries: number[];
|
|
9
|
+
}
|
|
10
|
+
export type AuthClass = 'user' | 'client' | 'system';
|
|
11
|
+
export type DevicesAccess = 'full' | 'limited';
|
|
12
|
+
export type BoundariesAccess = 'full' | 'limited';
|
|
13
|
+
export interface SpytecAuthContext {
|
|
14
|
+
type: AuthClass;
|
|
15
|
+
userId?: string;
|
|
16
|
+
clientId: number;
|
|
17
|
+
devicesAccess: DevicesAccess;
|
|
18
|
+
boundariesAccess: BoundariesAccess;
|
|
19
|
+
minAccessDate?: string;
|
|
20
|
+
resources: SpytecAuthorizedResources;
|
|
21
|
+
principalId: string;
|
|
22
|
+
scope?: string;
|
|
23
|
+
enterprise?: boolean;
|
|
24
|
+
maintenanceModule?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export type BaseAPIGatewayEvent = Omit<APIGatewayProxyEventBase<SpytecAuthContext>, 'pathParameters' | 'queryStringParameters' | 'body'>;
|
|
27
|
+
export interface WrapperArgs<E, R> {
|
|
28
|
+
event: APIGatewayProxyEvent;
|
|
29
|
+
context?: APIGatewayEventRequestContext;
|
|
30
|
+
schema?: ObjectSchema<E>;
|
|
31
|
+
handler: Handler<E, R>;
|
|
32
|
+
}
|
|
33
|
+
export type UserAPIHandler<TEvent = APIGatewayProxyWithLambdaAuthorizerEvent<SpytecAuthContext>, TResult = any> = (event: TEvent, context: APIGatewayEventRequestContext, callback: Callback<TResult>) => void | Promise<TResult>;
|
|
34
|
+
export type ServerAPIHandler<TResult = any> = (event: APIGatewayProxyWithCognitoAuthorizerEvent, context: APIGatewayEventRequestContext, callback: Callback<TResult>) => void | Promise<TResult>;
|
|
35
|
+
export type Handler<E, R> = (event: E) => Promise<HandlerResponse<R>>;
|
|
36
|
+
export interface HandlerResponse<R> {
|
|
37
|
+
statusCode?: number;
|
|
38
|
+
headers?: {
|
|
39
|
+
[header: string]: boolean | number | string;
|
|
40
|
+
};
|
|
41
|
+
isBase64Encoded?: boolean;
|
|
42
|
+
message?: string;
|
|
43
|
+
data?: R;
|
|
44
|
+
rawResult?: boolean;
|
|
45
|
+
stringifyBody?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export type BaseRecord = Omit<SQSRecord, 'body' | 'messageAttributes'>;
|
|
48
|
+
export interface MessageEvent<RecordType extends BaseRecord> {
|
|
49
|
+
Records: RecordType[];
|
|
50
|
+
}
|
|
51
|
+
export type SQSWrapperArgs<RecordType extends BaseRecord> = {
|
|
52
|
+
event: SQSEvent;
|
|
53
|
+
context?: Context;
|
|
54
|
+
schema?: Joi.ObjectSchema<MessageEvent<RecordType>>;
|
|
55
|
+
handler?: (e: MessageEvent<RecordType>) => void | Promise<void>;
|
|
56
|
+
singleHandler?: (record: RecordType) => void | Promise<void>;
|
|
57
|
+
mode?: 'serial' | 'parallel';
|
|
58
|
+
};
|
package/dist/utils/cache.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export declare class LambdaCache {
|
|
2
|
-
private collectionName;
|
|
3
|
-
/**
|
|
4
|
-
* @param {String} collectionName (not required) - The collection key used to store the cache values.
|
|
5
|
-
* If not provide default collection name uses :
|
|
6
|
-
* ${process.env.AWS_LAMBDA_FUNCTION_NAME}-${process.env.AWS_LAMBDA_FUNCTION_VERSION}
|
|
7
|
-
* */
|
|
8
|
-
constructor(collectionName?: string);
|
|
9
|
-
/**
|
|
10
|
-
* @param {String} key (required) - cache key
|
|
11
|
-
* @param {Object} value (required) - cache value
|
|
12
|
-
* @param {Number} expire (required) - cache expiration time (seconds)
|
|
13
|
-
* */
|
|
14
|
-
set(key: string, value: unknown, ttl: number): void;
|
|
15
|
-
/**
|
|
16
|
-
* @param {String} key (required) - cache key to get
|
|
17
|
-
* */
|
|
18
|
-
get(key: string): unknown;
|
|
19
|
-
/**
|
|
20
|
-
* @param {String} key (required) - cache key to remove
|
|
21
|
-
* */
|
|
22
|
-
remove(key: any): void;
|
|
23
|
-
}
|
|
1
|
+
export declare class LambdaCache {
|
|
2
|
+
private collectionName;
|
|
3
|
+
/**
|
|
4
|
+
* @param {String} collectionName (not required) - The collection key used to store the cache values.
|
|
5
|
+
* If not provide default collection name uses :
|
|
6
|
+
* ${process.env.AWS_LAMBDA_FUNCTION_NAME}-${process.env.AWS_LAMBDA_FUNCTION_VERSION}
|
|
7
|
+
* */
|
|
8
|
+
constructor(collectionName?: string);
|
|
9
|
+
/**
|
|
10
|
+
* @param {String} key (required) - cache key
|
|
11
|
+
* @param {Object} value (required) - cache value
|
|
12
|
+
* @param {Number} expire (required) - cache expiration time (seconds)
|
|
13
|
+
* */
|
|
14
|
+
set(key: string, value: unknown, ttl: number): void;
|
|
15
|
+
/**
|
|
16
|
+
* @param {String} key (required) - cache key to get
|
|
17
|
+
* */
|
|
18
|
+
get(key: string): unknown;
|
|
19
|
+
/**
|
|
20
|
+
* @param {String} key (required) - cache key to remove
|
|
21
|
+
* */
|
|
22
|
+
remove(key: any): void;
|
|
23
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { LambdaCache } from './cache';
|
|
2
|
-
export declare const promiseWithCache: <T>(promise: () => Promise<T>, cacheInstance: LambdaCache, cacheKey: string, ttl: number) => Promise<T>;
|
|
1
|
+
import { LambdaCache } from './cache';
|
|
2
|
+
export declare const promiseWithCache: <T>(promise: () => Promise<T>, cacheInstance: LambdaCache, cacheKey: string, ttl: number) => Promise<T>;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LambdaCache } from './cache';
|
|
2
|
-
export * from './cacheWrapper';
|
|
3
|
-
export * from './timeOut';
|
|
4
|
-
export { LambdaCache };
|
|
1
|
+
import { LambdaCache } from './cache';
|
|
2
|
+
export * from './cacheWrapper';
|
|
3
|
+
export * from './timeOut';
|
|
4
|
+
export { LambdaCache };
|
package/dist/utils/timeOut.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const promiseWithTimeout: <T>(promise: Promise<T>, ms: number, timeoutError?: Error) => Promise<T>;
|
|
1
|
+
export declare const promiseWithTimeout: <T>(promise: Promise<T>, ms: number, timeoutError?: Error) => Promise<T>;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import * as Joi from 'joi';
|
|
2
|
-
import { ArraySchema, ObjectSchema, SchemaMap, StringSchema } from 'joi';
|
|
3
|
-
export declare const json: any;
|
|
4
|
-
export declare const urlEncoded: any;
|
|
5
|
-
export declare const imeiSchema: Joi.StringSchema<string>;
|
|
6
|
-
export declare const iccidSchema: Joi.StringSchema<string>;
|
|
7
|
-
interface SpytecJoi extends Joi.Root {
|
|
8
|
-
urlEncodedObject<TSchema = any, T = TSchema>(schema?: SchemaMap<T>): ObjectSchema<TSchema>;
|
|
9
|
-
jsonObject<TSchema = any, T = TSchema>(schema?: SchemaMap<T>): ObjectSchema<TSchema>;
|
|
10
|
-
imei(): StringSchema;
|
|
11
|
-
iccid(): StringSchema;
|
|
12
|
-
delimitedArray(): ArraySchema;
|
|
13
|
-
dateString(): StringSchema;
|
|
14
|
-
jsonArray<TSchema = any, T = TSchema>(schema?: Joi.SchemaMap<T>): ArraySchema<TSchema>;
|
|
15
|
-
base64ThenUriEncodedObject<TSchema = any, T = TSchema>(schema?: SchemaMap<T>): ObjectSchema<TSchema>;
|
|
16
|
-
}
|
|
17
|
-
export declare const SpytecJoi: SpytecJoi;
|
|
18
|
-
export {};
|
|
1
|
+
import * as Joi from 'joi';
|
|
2
|
+
import { ArraySchema, ObjectSchema, SchemaMap, StringSchema } from 'joi';
|
|
3
|
+
export declare const json: any;
|
|
4
|
+
export declare const urlEncoded: any;
|
|
5
|
+
export declare const imeiSchema: Joi.StringSchema<string>;
|
|
6
|
+
export declare const iccidSchema: Joi.StringSchema<string>;
|
|
7
|
+
interface SpytecJoi extends Joi.Root {
|
|
8
|
+
urlEncodedObject<TSchema = any, T = TSchema>(schema?: SchemaMap<T>): ObjectSchema<TSchema>;
|
|
9
|
+
jsonObject<TSchema = any, T = TSchema>(schema?: SchemaMap<T>): ObjectSchema<TSchema>;
|
|
10
|
+
imei(): StringSchema;
|
|
11
|
+
iccid(): StringSchema;
|
|
12
|
+
delimitedArray(): ArraySchema;
|
|
13
|
+
dateString(): StringSchema;
|
|
14
|
+
jsonArray<TSchema = any, T = TSchema>(schema?: Joi.SchemaMap<T>): ArraySchema<TSchema>;
|
|
15
|
+
base64ThenUriEncodedObject<TSchema = any, T = TSchema>(schema?: SchemaMap<T>): ObjectSchema<TSchema>;
|
|
16
|
+
}
|
|
17
|
+
export declare const SpytecJoi: SpytecJoi;
|
|
18
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseAPIGatewayEvent } from '../types';
|
|
2
|
-
import validateEvent from './validateEvent';
|
|
3
|
-
export { validateEvent };
|
|
4
|
-
export * from './custom';
|
|
5
|
-
export * from './requestContext';
|
|
6
|
-
export declare const defaultApiSchema: import("joi").ObjectSchema<BaseAPIGatewayEvent>;
|
|
1
|
+
import { BaseAPIGatewayEvent } from '../types';
|
|
2
|
+
import validateEvent from './validateEvent';
|
|
3
|
+
export { validateEvent };
|
|
4
|
+
export * from './custom';
|
|
5
|
+
export * from './requestContext';
|
|
6
|
+
export declare const defaultApiSchema: import("joi").ObjectSchema<BaseAPIGatewayEvent>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { APIGatewayEventRequestContextWithAuthorizer } from 'aws-lambda/common/api-gateway';
|
|
2
|
-
import * as Joi from 'joi';
|
|
3
|
-
import { AuthClass, SpytecAuthContext } from '../types';
|
|
4
|
-
interface GetAuthorizerValidatorParams {
|
|
5
|
-
scope?: string;
|
|
6
|
-
type?: AuthClass;
|
|
7
|
-
}
|
|
8
|
-
export declare const getAuthorizerValidator: ({ scope, type }?: GetAuthorizerValidatorParams) => Joi.ObjectSchema<SpytecAuthContext>;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated
|
|
11
|
-
*/
|
|
12
|
-
export declare const requestContextValidator: Joi.ObjectSchema<any>;
|
|
13
|
-
export declare const getRequestContextValidator: (params?: GetAuthorizerValidatorParams) => Joi.ObjectSchema<APIGatewayEventRequestContextWithAuthorizer<SpytecAuthContext>>;
|
|
14
|
-
export {};
|
|
1
|
+
import { APIGatewayEventRequestContextWithAuthorizer } from 'aws-lambda/common/api-gateway';
|
|
2
|
+
import * as Joi from 'joi';
|
|
3
|
+
import { AuthClass, SpytecAuthContext } from '../types';
|
|
4
|
+
interface GetAuthorizerValidatorParams {
|
|
5
|
+
scope?: string;
|
|
6
|
+
type?: AuthClass;
|
|
7
|
+
}
|
|
8
|
+
export declare const getAuthorizerValidator: ({ scope, type }?: GetAuthorizerValidatorParams) => Joi.ObjectSchema<SpytecAuthContext>;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
12
|
+
export declare const requestContextValidator: Joi.ObjectSchema<any>;
|
|
13
|
+
export declare const getRequestContextValidator: (params?: GetAuthorizerValidatorParams) => Joi.ObjectSchema<APIGatewayEventRequestContextWithAuthorizer<SpytecAuthContext>>;
|
|
14
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ObjectSchema, ValidationOptions } from 'joi';
|
|
2
|
-
declare const validateEvent: <T>(event: any, schema?: ObjectSchema<T>, validateOptions?: ValidationOptions) => T;
|
|
3
|
-
export default validateEvent;
|
|
1
|
+
import { ObjectSchema, ValidationOptions } from 'joi';
|
|
2
|
+
declare const validateEvent: <T>(event: any, schema?: ObjectSchema<T>, validateOptions?: ValidationOptions) => T;
|
|
3
|
+
export default validateEvent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APIGatewayProxyResult } from 'aws-lambda';
|
|
2
|
-
import { WrapperArgs } from '../types';
|
|
3
|
-
declare const apiGatewayEventWrapper: <E, R>({ event, context, schema, handler, }: WrapperArgs<E, R>) => Promise<APIGatewayProxyResult>;
|
|
4
|
-
export default apiGatewayEventWrapper;
|
|
1
|
+
import { APIGatewayProxyResult } from 'aws-lambda';
|
|
2
|
+
import { WrapperArgs } from '../types';
|
|
3
|
+
declare const apiGatewayEventWrapper: <E, R>({ event, context, schema, handler, }: WrapperArgs<E, R>) => Promise<APIGatewayProxyResult>;
|
|
4
|
+
export default apiGatewayEventWrapper;
|
package/dist/wrappers/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import apiGatewayEventWrapper from './apiGatewayEventWrapper';
|
|
2
|
-
import sqsEventWrapper from './sqsEventWrapper';
|
|
3
|
-
export { apiGatewayEventWrapper, sqsEventWrapper };
|
|
4
|
-
export * from './response';
|
|
1
|
+
import apiGatewayEventWrapper from './apiGatewayEventWrapper';
|
|
2
|
+
import sqsEventWrapper from './sqsEventWrapper';
|
|
3
|
+
export { apiGatewayEventWrapper, sqsEventWrapper };
|
|
4
|
+
export * from './response';
|
|
@@ -1,8 +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, rawResult, stringifyBody, }: HandlerResponse<R>) => APIGatewayProxyResult;
|
|
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, rawResult, stringifyBody, }: HandlerResponse<R>) => APIGatewayProxyResult;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { BaseRecord, SQSWrapperArgs } from '../types';
|
|
2
|
-
declare const sqsEventWrapper: <RecordType extends BaseRecord>({ event, context, schema, handler, singleHandler, mode, }: SQSWrapperArgs<RecordType>) => Promise<void>;
|
|
3
|
-
export default sqsEventWrapper;
|
|
1
|
+
import { BaseRecord, SQSWrapperArgs } from '../types';
|
|
2
|
+
declare const sqsEventWrapper: <RecordType extends BaseRecord>({ event, context, schema, handler, singleHandler, mode, }: SQSWrapperArgs<RecordType>) => Promise<void>;
|
|
3
|
+
export default sqsEventWrapper;
|