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

ULL-ESIT-INF-DSI-2526 / prct10-express-videogames-app-alu0101646299 / 24627307324

19 Apr 2026 10:48AM UTC coverage: 90.698%. First build
24627307324

push

github

alu0101646299
Tests aƱadidos

21 of 21 branches covered (100.0%)

Branch coverage included in aggregate %.

1 of 3 new or added lines in 1 file covered. (33.33%)

96 of 108 relevant lines covered (88.89%)

1.67 hits per line

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

86.79
/src/server.ts
1
import express from 'express';
2
import { GameCollection } from './gameCollection.js';
3
import { Videogame } from './videogame.js';
4

5
export const app = express();
1✔
6

7
app.use(express.json());
1✔
8

9
app.get('/videogames', (req, res) => {
1✔
10
  const user = req.query.user as string;
4✔
11
  const id = req.query.id ? Number(req.query.id) : undefined;
4✔
12

13
  if (!user) {
4✔
14
    res.send({ error: 'A user must be provided' });
1✔
15
  } else {
16
    const collection = new GameCollection(user);
3✔
17

18
    if (id !== undefined) {
3✔
19
      collection.readGame(id)
1✔
20
        .then((data) => res.send(data))
1✔
21
        .catch((err) => res.send({ error: err }));
×
22
    } else {
23
      collection.listGames()
2✔
24
        .then((data) => res.send(data))
2✔
25
        .catch((err) => res.send({ error: err }));
×
26
    }
27
  }
28
});
29

30
app.post('/videogames', (req, res) => {
1✔
31
  const user = req.body.user as string;
3✔
32
  const videogame = req.body.videogame as Videogame;
3✔
33

34
  if (!user || !videogame) {
3✔
35
    res.send({ error: 'A user and a videogame must be provided' });
1✔
36
  } else {
37
    const collection = new GameCollection(user);
2✔
38

39
    collection.addGame(videogame)
2✔
40
      .then((data) => res.send(data))
2✔
41
      .catch((err) => res.send({ error: err}));
×
42
  }
43
});
44

45
app.patch('/videogames', (req, res) => {
1✔
46
  const user = req.body.user as string;
3✔
47
  const videogame = req.body.videogame as Videogame;
3✔
48

49
  if (!user || !videogame) {
3✔
50
    res.send({ error: 'A user and a videogame must be provided' });
1✔
51
  } else {
52
    const collection = new GameCollection(user);
2✔
53

54
    collection.updateGame(videogame)
2✔
55
      .then((data) => res.send(data))
2✔
56
      .catch((err) => res.send({ error: err}));
×
57
  }
58
});
59

60
app.delete('/videogames', (req, res) => {
1✔
61
  const user = req.query.user as string;
3✔
62
  const id = req.query.id ? Number(req.query.id) : undefined;
3✔
63

64
  if (!user || id === undefined) {
3✔
65
    res.send({ error: 'A user and an id must be provided' });
1✔
66
  } else {
67
    const collection = new GameCollection(user);
2✔
68

69
    collection.removeGame(id)
2✔
70
      .then((data) => res.send(data))
2✔
71
      .catch((err) => res.send({ error: err }));
×
72
  }
73
});
74

75
if (process.env.NODE_ENV !== 'test') {
1✔
NEW
76
  app.listen(3000, () => {
×
NEW
77
    console.log('Server is up on port 3000');
×
78
  });
79
}
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