Skip to content

Commit 8e1c15a

Browse files
author
Nino van Galen
committed
feat: Added runs endpoint
1 parent 1b03bf7 commit 8e1c15a

4 files changed

Lines changed: 187 additions & 0 deletions

File tree

backend/lib/controllers/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ const UsersController = require('./users.controller');
2121
const TagsController = require('./tags.controller');
2222
const SettingsController = require('./settings.controller');
2323
const SubsystemsController = require('./subsystems.controller');
24+
const RunsController = require('./runs.controller');
2425

2526
module.exports = {
2627
HomeController,
28+
RunsController,
2729
SettingsController,
2830
SubsystemsController,
2931
TagsController,
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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 tag.
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+
* Get all runs.
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 index = (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+
* Patch run.
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 patch = (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+
* Patch tag on log.
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 patchLog = (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+
* Get tag.
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 read = (request, response, next) => {
119+
response.status(501).json({
120+
errors: [
121+
{
122+
status: '501',
123+
title: 'Not implemented',
124+
},
125+
],
126+
});
127+
};
128+
129+
module.exports = {
130+
index,
131+
create,
132+
patch,
133+
patchLog,
134+
read,
135+
};

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 runsRoute = require('./runs.router');
2021
const settingsRoute = require('./settings.router');
2122
const subsystemsRoute = require('./subsystems.router');
2223
const tagsRoute = require('./tags.router');
@@ -25,6 +26,7 @@ const { appendPath, deepmerge } = require('../utils');
2526

2627
const routes = [
2728
homeRoute,
29+
runsRoute,
2830
settingsRoute,
2931
subsystemsRoute,
3032
tagsRoute,

backend/lib/routers/runs.router.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 { RunsController } = require('../controllers');
20+
21+
module.exports = {
22+
method: 'get',
23+
path: '/runs',
24+
controller: RunsController.index,
25+
args: { public: true },
26+
children: [
27+
{
28+
method: 'post',
29+
controller: RunsController.create,
30+
},
31+
{
32+
method: 'get',
33+
path: '/:id',
34+
controller: RunsController.read,
35+
children: [
36+
{
37+
method: 'patch',
38+
controller: RunsController.patch,
39+
},
40+
{
41+
method: 'patch',
42+
path: 'logs',
43+
controller: RunsController.patchLog,
44+
},
45+
],
46+
},
47+
],
48+
};

0 commit comments

Comments
 (0)