Serverless Kit for fast development.
npm install --save @dustfoundation/serverless-kit// User must have at least one of specified groups (moderator OR admin)hasAnyGroup(event.requestContext.authorizer!.groups.split(';'),['moderator','admin']);// => boolean// User must have all specified groups (moderator AND admin)hasAllGroups(event.requestContext.authorizer!.groups.split(';'),['moderator','admin']);// => booleanconstbody=parseRequestBody<{name: 'Elon'}>(event.body,event.headers);// Check Content-Type=application/jsonconstbody=parseRequestBody<{name: 'Elon'}>(event.body,false);// Skip Content-Type=application/jsonif(!body){returnBadRequest();}// => { name: 'Elon' } | null// Success responsereturnSuccess();// 200// Success response with body (authomatic JSON.stringify())returnSuccess().withBody({name: 'Elon'});// Success response with body and headersreturnSuccess().withBody({name: 'Elon'}).withHeaders({'test-header': 1});returnSuccess().withBody({name: 'Elon'}).withMultiValueHeaders({'test-header': [1]});// Success response with base64Encoded enabled (for files)returnSuccess().withBase64Encoded();// Other responses (withBody and other props can also be applied)returnCreated();// 201returnAccepted();// 202returnNoContent();// 204returnBadRequest();// 400returnUnauthorized();// 401returnForbidden();// 403returnNotFound();// 404returnConflict();// 409returnTooManyRequests();// 429returnInternalServerError();// 500returnBadGateway();// 502returnGatewayTimeout();// 504// Custom status codesreturnResponseBuilder(000).withBody(...);// 000