• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CSHeHu / shoppinglist / 20440559699

22 Dec 2025 06:26PM UTC coverage: 23.034% (-24.0%) from 47.036%
20440559699

push

github

CSHeHu
rewrite tests to accomodate new auth and to be more unit test like

16 of 34 branches covered (47.06%)

Branch coverage included in aggregate %.

107 of 500 relevant lines covered (21.4%)

0.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/middleware/errorHandler.js
1
import winston from 'winston';
×
2
import path from 'path';
×
3
import { fileURLToPath } from 'url';
×
4

×
5
// __dirname replacement for ESM
×
6
const __filename = fileURLToPath(import.meta.url);
×
7
const __dirname = path.dirname(__filename);
×
8

×
9
const errorLogger = winston.createLogger({
×
10
    level: 'error',
×
11
    format: winston.format.combine(
×
12
        winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
×
13
        winston.format.json()
×
14
    ),
×
15
    transports: [
×
16
        new winston.transports.File({ filename: path.join(__dirname, '../error.log'), maxsize: 5 * 1024 * 1024, maxFiles: 5 }),
×
17
    ],
×
18
});
×
19

×
20
export default function errorHandler(err, req, res, next) {
×
21
    const status = err.status || 500;
×
22

×
23
    // Always log error details
×
24
    errorLogger.error({
×
25
        message: err.message,
×
26
        stack: err.stack,
×
27
        status,
×
28
        timestamp: new Date().toISOString(),
×
29
    });
×
30

×
31
    // Send response (hide details in production)
×
32
    res.status(status).json({
×
33
        error: {
×
34
            code: status,
×
35
            message:
×
36
                req.app.get('env') === 'development'
×
37
                    ? err.message
×
38
                    : 'Something went wrong. Please try again later.',
×
39
        },
×
40
    });
×
41
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc