1.0.27 • Published 11 months ago
@vtfk/responsehandlers v1.0.27
vtfk-responsehandlers
A node package for handeling Azure function and Express responses for VTFK.
Features
- Parses and returns a property formatted errors
- Handles sending responses for Azure Function Apps or Express
- Uses @vtfk/logger so it can use any features it has. (Papertrail logging, etc.)
Useage example
Azure Function Apps
const { azfResponseHandler, azfErrorHandler } = require('@vtfk/responsehandlers');
module.exports = async function (context, req) {
try {
const data = { message: 'Hello World!' }
return await azfResponseHandler(data, req, context);
} catch (error) {
return await azfErrorHandler(error, req, context);
}
}Express App
const { expressResponseHandler, expressErrorHandler } = require('@vtfk/responsehandlers');
router.get('/', async (req, res, next) => {
try {
const data = { message: 'Hello World!' }
return await expressResponseHandler(data, req, res, next);
} catch (error) {
return await expressErrorHandler(error, req, res, next);
}
})
}Environment variables
| Variable | Description |
|---|---|
| PAPERTRAIL_HOST | Papertrail logging url |
| PAPERTRAIL_TOKEN | Papertrail logging token |
| RESPONSEHANDLER_LOGGER_REMOTE_ONLY_IN_PROD | Should the logger only be able to write to PaperTrails when NODE_ENV = production? |
| RESPONSEHANDLER_LOGGER_REMOTE_DISABLE | Disable all remote logging |
| RESPONSEHANDLER_LOGGER_LOCAL_DISABLE | Disable logging to std out |
1.0.26
11 months ago
1.0.27
11 months ago
1.0.22
4 years ago
1.0.25
4 years ago
1.0.24
4 years ago
1.0.23
4 years ago
1.0.21
4 years ago
1.0.20
4 years ago
1.0.19
4 years ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.11
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.12
4 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago