fastify-overview
Version:
Get a complete overview of your fastify application
32 lines (27 loc) • 822 B
JavaScript
const basePath = process.cwd()
module.exports = function callee () {
const _prepareStackTrace = Error.prepareStackTrace
Error.prepareStackTrace = (_, stack) => stack
const stack = new Error().stack.slice(2)
Error.prepareStackTrace = _prepareStackTrace
return stack
.filter(noNodeModules)
.map(toCodeItem)
}
function noNodeModules (call) {
const file = call.getFileName()
return file && file.indexOf('node_modules') === -1
}
function toCodeItem (call, i) {
return {
stackIndex: i,
fileName: call.getFileName(),
relativeFileName: call.getFileName().replace(basePath, ''),
lineNumber: call.getLineNumber(),
columnNumber: call.getColumnNumber(),
functionName: call.getFunctionName(),
typeName: call.getTypeName(),
methodName: call.getMethodName()
}
}