@maeum/plugins
v1.0.0
Published
Maeum server flag plugins
Downloads
81
Readme
Maeum plugins
Plugins of the Maeum boilerplate. ResponseTime, Flag variable plugins includes.
Response-Time Plugin
Response time add on header field.
import fastify from 'fastify';
import { responseTimePlugin } from '@maeum/plugins';
const server = fastify();
server
.register(responseTimePlugin, {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing
headerKey: 'Server-Time',
isExecute: () => config.server.runMode !== 'production',
});
| Name | Desc. | | - | - | | headerKey | header key for add response time. | | isExecute | function execution result decide what response time value add or not |
Request flag Plugin
Varity flags add on request.
import fastify from 'fastify';
import { requestFlagsPlugin } from '@maeum/plugins';
const server = fastify();
server
.register(requestFlagsPlugin);
| function | Desc. | | - | - | | setRequestLogging | that indicate what request is logged or not | | getRequestLogging | get request is logged | | setRequestError | that store what error of request | | getRequestError | get error in request | | setRequestPayload | that store what payload in reply | | getRequestPayload | get payload in reply |
This function need manual works. For example, getRequestError return error before you have to set error variable using setRequestError.