Skip to content

Commit

Permalink
fix: Fixed jdoc in controllers and routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nino van Galen committed Apr 21, 2020
1 parent a8134fd commit ca86375
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 84 deletions.
11 changes: 6 additions & 5 deletions backend/lib/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ const User = require('./user');
const Tag = require('./tag');

/**
*
* @param {Object} req
* @param {Object} res
* Basic api information controller
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const Api = (req, res) => {
res.status(200).json({
const Api = (_request, response) => {
response.status(200).json({
name: 'Jiskefet Backend',
version: '0.0.0',
});
Expand Down
98 changes: 53 additions & 45 deletions backend/lib/controllers/tag.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,82 @@
/**
*
* @param {Object} req
* @param {Object} res
* Create tag
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const create = (req, res) => {
res.send('TAG CREATE not defined');
}
const create = (_request, response) => {
response.send('TAG CREATE not defined');
};

/**
*
* @param {Object} req
* @param {Object} res
* Delete tag
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const deleteTag = (req, res) => {
res.send('TAG DELETE not defined');
}
const deleteTag = (_request, response) => {
response.send('TAG DELETE not defined');
};

/**
*
* @param {Object} req
* @param {Object} res
* Get all logs with tag
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const getLogs = (req, res) => {
res.send('TAG GET_LOGS not defined');
const getLogs = (_request, response) => {
response.send('TAG GET_LOGS not defined');
};

/**
*
* @param {Object} req
* @param {Object} res
* Get all Runs with tag
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const getRuns = (req, res) => {
res.send('TAG GET_RUNS not defined');
}
const getRuns = (_request, response) => {
response.send('TAG GET_RUNS not defined');
};

/**
*
* @param {Object} req
* @param {Object} res
* Get all tags
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const index = (req, res) => {
res.send('TAG INDEX not defined');
const index = (_request, response) => {
response.send('TAG INDEX not defined');
};

/**
*
* @param {Object} req
* @param {Object} res
* Patch tag on log
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const patchLog = (req, res) => {
res.send('TAG PATCH_LOG not defined');
const patchLog = (_request, response) => {
response.send('TAG PATCH_LOG not defined');
};

/**
*
* @param {Object} req
* @param {Object} res
* Patch tag on run
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const patchRun = (req, res) => {
res.send('TAG PATCH_RUN not defined');
const patchRun = (_request, response) => {
response.send('TAG PATCH_RUN not defined');
};

/**
*
* @param {Object} req
* @param {Object} res
* Get tag
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const read = (req, res) => {
res.send('TAG READ not defined');
}
const read = (_request, response) => {
response.send('TAG READ not defined');
};

module.exports = {
create,
Expand All @@ -79,4 +87,4 @@ module.exports = {
patchLog,
patchRun,
read,
}
};
55 changes: 30 additions & 25 deletions backend/lib/controllers/user.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
/**
*
* @param {Object} req
* @param {Object} res
* Get all users
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const index = (req, res) => {
res.send('USER INDEX not defined');
const index = (_request, response) => {
response.send('USER INDEX not defined');
};

/**
*
* @param {Object} req
* @param {Object} res
* Get all logs of User
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const getLogs = (req, res) => {
res.send('USER GET_LOGS not defined');
const getLogs = (_request, response) => {
response.send('USER GET_LOGS not defined');
};

/**
*
* @param {Object} req
* @param {Object} res
* Get Tokens of user
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const getTokens = (req, res) => {
res.send('USER GET_TOKENS not defined');
const getTokens = (_request, response) => {
response.send('USER GET_TOKENS not defined');
};

/**
*
* @param {Object} req
* @param {Object} res
* Get user
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const read = (req, res) => {
res.send('USER READ not defined');
const read = (_request, response) => {
response.send('USER READ not defined');
};

/**
*
* @param {Object} req
* @param {Object} res
* Post token for user
* @param {Object} _request response object
* @param {Object} response response object
* @returns {undefined}
*/
const postTokens = (req, res) => {
res.send('USER POST_TOKENS not defined');
const postTokens = (_request, response) => {
response.send('USER POST_TOKENS not defined');
};

module.exports = {
Expand Down
20 changes: 11 additions & 9 deletions backend/lib/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ const routes = [
];

/**
*
* @param {Object} parent
* @param {Object} child
* Makes the child object inherit the args of the parent object, but keeps the overwrites
* @param {Object} parent parent who's args will be inherited
* @param {Object} child child who will inherit the args
* @returns {undefined}
*/
const inheritArgs = (parent, child) => {
child.args = deepmerge(parent.args||{}, child.args||{});
}
};

/**
* Route binder, used to bind routes to the httpServer
* @param {Object} http httpServer that the routes should be bound on
* @param {Object} route the route that should be bound
* @param {String} [path=''] the base path of the route
* @param {String} [parentPath=''] the base path of the route
* @returns {undefined}
*/
const bindRoute = (http, route, parentPath = '') => {
const localPath = parentPath.concat(route.path);
Expand All @@ -37,15 +39,15 @@ const bindRoute = (http, route, parentPath = '') => {
}

if (route.children) {
route.children.forEach(child => {
route.children.forEach((child) => {
inheritArgs(route, child);
bindRoute(http, child, localPath);
});
}
}
};

module.exports = (http) => {
routes.forEach(route => {
routes.forEach((route) => {
bindRoute(http, route);
});
}
};

0 comments on commit ca86375

Please sign in to comment.