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

GrottoCenter / grottocenter-api / 5631056675

pending completion
5631056675

push

github

vmarseguerra
refactor(right): replaces rights with a static groups system

751 of 1944 branches covered (38.63%)

Branch coverage included in aggregate %.

59 of 59 new or added lines in 35 files covered. (100.0%)

2702 of 5007 relevant lines covered (53.96%)

14.64 hits per line

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

34.78
/api/controllers/v1/location/create.js
1
const ControllerService = require('../../../services/ControllerService');
1✔
2
const ErrorService = require('../../../services/ErrorService');
1✔
3
const {
4
  NOTIFICATION_TYPES,
5
  NOTIFICATION_ENTITIES,
6
} = require('../../../services/NotificationService');
1✔
7
const NotificationService = require('../../../services/NotificationService');
1✔
8
const ParametersValidatorService = require('../../../services/ParametersValidatorService');
1✔
9
const LocationService = require('../../../services/LocationService');
1✔
10
const { toSimpleLocation } = require('../../../services/mapping/converters');
1✔
11

12
module.exports = async (req, res) => {
1✔
13
  try {
×
14
    const mandatoryParams = ParametersValidatorService.checkAllExist(req, res, [
×
15
      'entrance',
16
      'body',
17
      'language',
18
    ]);
19
    if (!mandatoryParams) return null;
×
20
    const [entranceId, body, languageId] = mandatoryParams;
×
21

22
    const linkedEntity = await ParametersValidatorService.checkOneOfEntityExist(
×
23
      req,
24
      res,
25
      ['entrance']
26
    );
27
    if (!linkedEntity) return null;
×
28

29
    const newLocation = await TLocation.create({
×
30
      author: req.token.id,
31
      body,
32
      dateInscription: new Date(),
33
      entrance: entranceId,
34
      language: languageId,
35
      title: req.param('title', null),
36
      // TODO compute relevance
37
    }).fetch();
38

39
    const locationPopulated = await LocationService.getLocation(newLocation.id);
×
40
    await NotificationService.notifySubscribers(
×
41
      req,
42
      locationPopulated,
43
      req.token.id,
44
      NOTIFICATION_TYPES.CREATE,
45
      NOTIFICATION_ENTITIES.LOCATION
46
    );
47

48
    return ControllerService.treatAndConvert(
×
49
      req,
50
      null,
51
      locationPopulated,
52
      { controllerMethod: 'LocationController.create' },
53
      res,
54
      toSimpleLocation
55
    );
56
  } catch (e) {
57
    return ErrorService.getDefaultErrorHandler(res)(e);
×
58
  }
59
};
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