Skip to content

Commit dc85779

Browse files
author
Nino van Galen
committed
feat: Added logs endpoint
1 parent 57b64bb commit dc85779

5 files changed

Lines changed: 246 additions & 6 deletions

File tree

backend/lib/controllers/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@
1717
*/
1818

1919
const HomeController = require('./home.controller');
20+
const LogsController = require('./logs.controller');
2021
const OverviewsController = require('./overviews.controller');
21-
const UsersController = require('./users.controller');
22-
const TagsController = require('./tags.controller');
22+
const RunsController = require('./runs.controller');
2323
const SettingsController = require('./settings.controller');
2424
const SubsystemsController = require('./subsystems.controller');
25-
const RunsController = require('./runs.controller');
25+
const TagsController = require('./tags.controller');
26+
const UsersController = require('./users.controller');
2627

2728
module.exports = {
2829
HomeController,
30+
LogsController,
2931
OverviewsController,
3032
RunsController,
3133
SettingsController,
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
/**
2+
* This file is part of the ALICE Electronic Logbook v2, also known as Jiskefet.
3+
* Copyright (C) 2020 Stichting Hogeschool van Amsterdam
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published
7+
* by the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
/**
20+
* Create a new log
21+
*
22+
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
23+
* string, parameters, body, HTTP headers, and so on.
24+
* @param {Object} response The *response* object represents the HTTP response that an Express app sends when it gets an
25+
* HTTP request.
26+
* @param {Function} next The *next* object represents the next middleware function which is used to pass control to the
27+
* next middleware function.
28+
* @returns {undefined}
29+
*/
30+
const create = (request, response, next) => {
31+
response.status(501).json({
32+
errors: [
33+
{
34+
status: '501',
35+
title: 'Not implemented',
36+
},
37+
],
38+
});
39+
};
40+
41+
/**
42+
* create attachment on log
43+
*
44+
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
45+
* string, parameters, body, HTTP headers, and so on.
46+
* @param {Object} response The *response* object represents the HTTP response that an Express app sends when it gets an
47+
* HTTP request.
48+
* @param {Function} next The *next* object represents the next middleware function which is used to pass control to the
49+
* next middleware function.
50+
* @returns {undefined}
51+
*/
52+
const createAttachment = (request, response, next) => {
53+
response.status(501).json({
54+
errors: [
55+
{
56+
status: '501',
57+
title: 'Not implemented',
58+
},
59+
],
60+
});
61+
};
62+
63+
/**
64+
* get attachment from log
65+
*
66+
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
67+
* string, parameters, body, HTTP headers, and so on.
68+
* @param {Object} response The *response* object represents the HTTP response that an Express app sends when it gets an
69+
* HTTP request.
70+
* @param {Function} next The *next* object represents the next middleware function which is used to pass control to the
71+
* next middleware function.
72+
* @returns {undefined}
73+
*/
74+
const getAttachment = (request, response, next) => {
75+
response.status(501).json({
76+
errors: [
77+
{
78+
status: '501',
79+
title: 'Not implemented',
80+
},
81+
],
82+
});
83+
};
84+
85+
/**
86+
* Get all logs.
87+
*
88+
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
89+
* string, parameters, body, HTTP headers, and so on.
90+
* @param {Object} response The *response* object represents the HTTP response that an Express app sends when it gets an
91+
* HTTP request.
92+
* @param {Function} next The *next* object represents the next middleware function which is used to pass control to the
93+
* next middleware function.
94+
* @returns {undefined}
95+
*/
96+
const index = (request, response, next) => {
97+
response.status(501).json({
98+
errors: [
99+
{
100+
status: '501',
101+
title: 'Not implemented',
102+
},
103+
],
104+
});
105+
};
106+
107+
/**
108+
* Patch run on log.
109+
*
110+
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
111+
* string, parameters, body, HTTP headers, and so on.
112+
* @param {Object} response The *response* object represents the HTTP response that an Express app sends when it gets an
113+
* HTTP request.
114+
* @param {Function} next The *next* object represents the next middleware function which is used to pass control to the
115+
* next middleware function.
116+
* @returns {undefined}
117+
*/
118+
const patchRun = (request, response, next) => {
119+
response.status(501).json({
120+
errors: [
121+
{
122+
status: '501',
123+
title: 'Not implemented',
124+
},
125+
],
126+
});
127+
};
128+
129+
/**
130+
* Get log.
131+
*
132+
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
133+
* string, parameters, body, HTTP headers, and so on.
134+
* @param {Object} response The *response* object represents the HTTP response that an Express app sends when it gets an
135+
* HTTP request.
136+
* @param {Function} next The *next* object represents the next middleware function which is used to pass control to the
137+
* next middleware function.
138+
* @returns {undefined}
139+
*/
140+
const read = (request, response, next) => {
141+
response.status(501).json({
142+
errors: [
143+
{
144+
status: '501',
145+
title: 'Not implemented',
146+
},
147+
],
148+
});
149+
};
150+
151+
/**
152+
* Patch attachment on log.
153+
*
154+
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
155+
* string, parameters, body, HTTP headers, and so on.
156+
* @param {Object} response The *response* object represents the HTTP response that an Express app sends when it gets an
157+
* HTTP request.
158+
* @param {Function} next The *next* object represents the next middleware function which is used to pass control to the
159+
* next middleware function.
160+
* @returns {undefined}
161+
*/
162+
const patchAttachment = (request, response, next) => {
163+
response.status(501).json({
164+
errors: [
165+
{
166+
status: '501',
167+
title: 'Not implemented',
168+
},
169+
],
170+
});
171+
};
172+
173+
module.exports = {
174+
create,
175+
createAttachment,
176+
getAttachment,
177+
index,
178+
read,
179+
patchAttachment,
180+
patchRun,
181+
};

backend/lib/controllers/runs.controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
/**
20-
* Create tag.
20+
* Create run.
2121
*
2222
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
2323
* string, parameters, body, HTTP headers, and so on.
@@ -83,7 +83,7 @@ const patch = (request, response, next) => {
8383
};
8484

8585
/**
86-
* Patch tag on log.
86+
* Patch run on log.
8787
*
8888
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
8989
* string, parameters, body, HTTP headers, and so on.
@@ -105,7 +105,7 @@ const patchLog = (request, response, next) => {
105105
};
106106

107107
/**
108-
* Get tag.
108+
* Get run.
109109
*
110110
* @param {Object} request The *request* object represents the HTTP request and has properties for the request query
111111
* string, parameters, body, HTTP headers, and so on.

backend/lib/routers/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
const homeRoute = require('./home.router');
20+
const logRoute = require('./logs.router');
2021
const overviewRoute = require('./overviews.router');
2122
const runsRoute = require('./runs.router');
2223
const settingsRoute = require('./settings.router');
@@ -27,6 +28,7 @@ const { appendPath, deepmerge } = require('../utils');
2728

2829
const routes = [
2930
homeRoute,
31+
logRoute,
3032
overviewRoute,
3133
runsRoute,
3234
settingsRoute,

backend/lib/routers/logs.router.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* This file is part of the ALICE Electronic Logbook v2, also known as Jiskefet.
3+
* Copyright (C) 2020 Stichting Hogeschool van Amsterdam
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published
7+
* by the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
const { LogsController } = require('../controllers');
20+
21+
module.exports = {
22+
method: 'get',
23+
path: '/logs',
24+
controller: LogsController.index,
25+
args: { public: true },
26+
children: [
27+
{
28+
method: 'post',
29+
controller: LogsController.create,
30+
},
31+
{
32+
method: 'get',
33+
path: ':id',
34+
controller: LogsController.read,
35+
children: [
36+
{
37+
method: 'get',
38+
path: 'attachments',
39+
controller: LogsController.getAttachment,
40+
children: [
41+
{
42+
method: 'post',
43+
controller: LogsController.createAttachment,
44+
},
45+
],
46+
},
47+
{
48+
method: 'patch',
49+
path: 'runs',
50+
controller: LogsController.patchRun,
51+
},
52+
],
53+
},
54+
],
55+
};

0 commit comments

Comments
 (0)