import apm from 'elastic-apm-node' ; import Koa from 'koa' ; import { Middleware } from 'koa-compose' ; async function errorMiddleware ( ctx , next ) { try { await next ( ) ; } catch ( error ) { apm . captureError ( error ) ; throw error ; } } export const apmErrorMiddleware = errorMiddleware ;