@spytecgps/lambda-utils
v3.1.12
Published
Lambda Utils
Keywords
Readme
Lambda Utils
Utility functions for serverless packages
Error codes
Throw an HttpError subclass with a stable errorCode when a client needs to tell one failure from another. message stays human-readable and can change; clients branch on errorCode.
throw new ConflictError('This email already has a Hapn account', { errorCode: 'HAS_ACCOUNT' })
throw new ConflictError('Already invited', 'ALREADY_INVITED') // shorthand
throw new BadRequestError('Alert type not supported', {
errorCode: 'ALERT_TYPE_UNSUPPORTED',
details: { imeis: ['123'] },
})The response body gets errorCode (and details) only when they are set:
{ "success": false, "message": "This email already has a Hapn account", "errorCode": "HAS_ACCOUNT" }Handlers that return an error response instead of throwing can pass the same errorCode and details alongside statusCode and message. Codes are SCREAMING_SNAKE_CASE with no ERROR_ prefix. Joi validation failures carry VALIDATION_FAILED with details.fields.
Lambda Utils breaking changes
If you need to use this package on Node 14 last available version is 1.0.20
If you need to use this package on Node 16 first available version is 2.0.0
Copy Distribution folder to local project ((local testing))
when making changes and would like to avoid commiting and publishing changes.
- Run
npm run buildto build all the content into the distribution folder - Run
npm run copydistfolder -- {destPath}to copy distribution folder to local project ex:npm run copydistfolder -- ../api-reportscopies dist folder to folder ->api-reports/node_modules/@spytecgps/lambda-utils/dist - In order for VSCode to reload and get udpated api-core copied to node_modules dist folder -> On PC you can do Ctrl + Shift + P (mac: Cmd + Shift + P) then type "Reload Window"git
