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

GrottoCenter / grottocenter-api / 10511865220

22 Aug 2024 04:19PM UTC coverage: 47.822% (-1.1%) from 48.96%
10511865220

push

github

vmarseguerra
feat(entities): adds delete / restore for entrance sub entities

711 of 2020 branches covered (35.2%)

Branch coverage included in aggregate %.

193 of 432 new or added lines in 35 files covered. (44.68%)

4 existing lines in 4 files now uncovered.

2528 of 4753 relevant lines covered (53.19%)

4.41 hits per line

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

31.58
/api/controllers/v1/location/create.js
1
const ControllerService = require('../../../services/ControllerService');
1✔
2
const NotificationService = require('../../../services/NotificationService');
1✔
3
const ParametersValidatorService = require('../../../services/ParametersValidatorService');
1✔
4
const LocationService = require('../../../services/LocationService');
1✔
5
const { toSimpleLocation } = require('../../../services/mapping/converters');
1✔
6

7
module.exports = async (req, res) => {
1✔
NEW
8
  const mandatoryParams = ParametersValidatorService.checkAllExist(req, res, [
×
9
    'entrance',
10
    'body',
11
    'language',
12
  ]);
NEW
13
  if (!mandatoryParams) return null;
×
NEW
14
  const [entranceId, body, languageId] = mandatoryParams;
×
15

NEW
16
  const linkedEntity = await ParametersValidatorService.checkOneOfEntityExist(
×
17
    req,
18
    res,
19
    ['entrance']
20
  );
NEW
21
  if (!linkedEntity) return null;
×
22

NEW
23
  const newLocation = await TLocation.create({
×
24
    author: req.token.id,
25
    body,
26
    dateInscription: new Date(),
27
    entrance: entranceId,
28
    language: languageId,
29
    title: req.param('title', null),
30
    // TODO compute relevance
31
  }).fetch();
32

NEW
33
  const locationPopulated = await LocationService.getLocation(newLocation.id);
×
NEW
34
  await NotificationService.notifySubscribers(
×
35
    req,
36
    locationPopulated,
37
    req.token.id,
38
    NotificationService.NOTIFICATION_TYPES.CREATE,
39
    NotificationService.NOTIFICATION_ENTITIES.LOCATION
40
  );
41

NEW
42
  return ControllerService.treatAndConvert(
×
43
    req,
44
    null,
45
    locationPopulated,
46
    { controllerMethod: 'LocationController.create' },
47
    res,
48
    toSimpleLocation
49
  );
50
};
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