Skip to content

Instantly share code, notes, and snippets.

@sochix
sochix / app.js
Last active August 9, 2024 07:01
Counting requests in your Node.js+Express application
const app = require('express')()
const getRoute = (req) => {
const route = req.route ? req.route.path : '' // check if the handler exist
const baseUrl = req.baseUrl ? req.baseUrl : '' // adding the base url if the handler is child of other handler
return route ? `${baseUrl === '/' ? '' : baseUrl}${route}` : 'unknown route'
}
const fs = require('fs')