Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
+24
-6
@@ -13,7 +13,7 @@ let rejectionLoggerRegistered = false;
|
||||
function boot(): void {
|
||||
if (booted) return;
|
||||
if (!rejectionLoggerRegistered) {
|
||||
process.on('unhandledRejection', reason => {
|
||||
process.on('unhandledRejection', (reason) => {
|
||||
console.error('[process] unhandled rejection:', reason);
|
||||
});
|
||||
rejectionLoggerRegistered = true;
|
||||
@@ -30,13 +30,31 @@ function boot(): void {
|
||||
export const handle: Handle = async (input) => {
|
||||
boot();
|
||||
const started = performance.now();
|
||||
const response = await withHostRequestContext(() => withOperationSource(`${input.event.request.method} ${input.event.route.id ?? 'Web request'}`,
|
||||
() => authenticationHandle(input)));
|
||||
const response = await withHostRequestContext(() =>
|
||||
withOperationSource(
|
||||
`${input.event.request.method} ${input.event.route.id ?? 'Web request'}`,
|
||||
() => authenticationHandle(input)
|
||||
)
|
||||
);
|
||||
const elapsed = performance.now() - started;
|
||||
response.headers.append('Server-Timing', `app;dur=${elapsed.toFixed(1)}`);
|
||||
if (process.env.EC_PERF_LOG === 'true' && elapsed > 250 && !input.event.route.id?.startsWith('/api/agent/')) {
|
||||
console.info('[request]', { route: input.event.route.id, method: input.event.request.method, status: response.status, elapsedMs: Math.round(elapsed) });
|
||||
if (
|
||||
process.env.EC_PERF_LOG === 'true' &&
|
||||
elapsed > 250 &&
|
||||
!input.event.route.id?.startsWith('/api/agent/')
|
||||
) {
|
||||
console.info('[request]', {
|
||||
route: input.event.route.id,
|
||||
method: input.event.request.method,
|
||||
status: response.status,
|
||||
elapsedMs: Math.round(elapsed)
|
||||
});
|
||||
}
|
||||
if (input.event.locals.user && !['GET','HEAD','OPTIONS'].includes(input.event.request.method) && response.status < 400) invalidateFleet();
|
||||
if (
|
||||
input.event.locals.user &&
|
||||
!['GET', 'HEAD', 'OPTIONS'].includes(input.event.request.method) &&
|
||||
response.status < 400
|
||||
)
|
||||
invalidateFleet();
|
||||
return response;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user