16 lines
360 B
JavaScript
16 lines
360 B
JavaScript
const pool = global.db_pool
|
|
|
|
module.exports = (req, res, next) => {
|
|
next();
|
|
const { path, method } = req;
|
|
|
|
pool.query(
|
|
'INSERT INTO analytics (method, endpoint, count) VALUES (?, ?, 1) ON DUPLICATE KEY UPDATE count = count + 1',
|
|
[method, path],
|
|
(error, results) => {
|
|
if (error) {
|
|
console.error('Error logging analytics:', error);
|
|
}
|
|
}
|
|
);
|
|
} |