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

HernanEstribou / take-home-hernan / cfda3a93-04ac-4b4f-91bb-e057db8cf33f

16 Feb 2026 07:39PM UTC coverage: 82.474% (-2.2%) from 84.656%
cfda3a93-04ac-4b4f-91bb-e057db8cf33f

push

circleci

HernanEstribou
feat: update swagger.json to prioritize http over https in schemes and refactor swagger setup in app.js for dynamic scheme detection

41 of 51 branches covered (80.39%)

Branch coverage included in aggregate %.

1 of 5 new or added lines in 1 file covered. (20.0%)

1 existing line in 1 file now uncovered.

119 of 143 relevant lines covered (83.22%)

3.06 hits per line

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

60.0
/src/app.js
1
import cors from 'cors';
2
import 'dotenv/config';
3
import express from 'express';
4
import usersRouter from './users/users.controller.js';
5
import swaggerUi from 'swagger-ui-express';
6
import swaggerDocumentation from './swagger/swagger.json' with { type: 'json' };
7
import './config/database.js';
8

9
const app = express();
2✔
10
const port = process.env.PORT || 3000;
2✔
11

12
app.use(express.json());
2✔
13
app.use(cors());
2✔
14

15
// Swagger setup with dynamic scheme detection
16
app.use('/api-docs', swaggerUi.serve, (req, res, next) => {
2✔
NEW
17
  const protocol = req.protocol; // 'http' or 'https'
×
NEW
18
  const swaggerDoc = { ...swaggerDocumentation };
×
19

20
  // Set schemes based on protocol: current protocol first
NEW
21
  swaggerDoc.schemes =
×
22
    protocol === 'https' ? ['https', 'http'] : ['http', 'https'];
×
23

NEW
24
  swaggerUi.setup(swaggerDoc)(req, res, next);
×
25
});
26

27
app.use('/users', usersRouter);
2✔
28

29
if (process.env.NODE_ENV !== 'test') {
2✔
UNCOV
30
  app.listen(port, () => {
×
31
    console.log(`App listening on port ${port}`);
×
32
  });
33
}
34

35
export default app;
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