-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy patheosReport.controller.js
More file actions
42 lines (38 loc) · 1.51 KB
/
eosReport.controller.js
File metadata and controls
42 lines (38 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* @license
* Copyright CERN and copyright holders of ALICE O2. This software is
* distributed under the terms of the GNU General Public License v3 (GPL
* Version 3), copied verbatim in the file "COPYING".
*
* See http://alice-o2.web.cern.ch/license for full licensing information.
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/
const { dtoValidator } = require('../utilities/index.js');
const { CreateEosReportDto } = require('../../domain/dtos/eosReport/CreateEosReportDto.js');
const { eosReportService } = require('../services/eosReport/EosReportService.js');
const { shiftService } = require('../services/shift/ShiftService.js');
// eslint-disable-next-line jsdoc/require-param
/**
* Route handler to create an EOS report log entry
*/
const createEosReportHandler = async (request, response) => {
const value = await dtoValidator(CreateEosReportDto, request, response);
const userIdentifier = { externalUserId: value?.session?.externalId };
if (value) {
const content = await eosReportService.createLogEntry(
value.query.reportType,
{
shiftStart: shiftService.getUserPendingShiftOrFail().start,
...value.body,
},
userIdentifier,
);
response.status(201).json({ data: content });
}
};
exports.EosReportController = {
createEosReportHandler,
};