-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: topic/k1ch/introduce API - GET/permissions
- Loading branch information
Showing
3 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const createError = require('http-errors') | ||
const dbAdminPermission = require('database/layer/admin-permission') | ||
|
||
/** | ||
* HTTP Request handler | ||
* Returns a list of permissions | ||
* | ||
* @param {Object} req - The request object | ||
* @param {Object} res - The response object to send 200 statusCode and a list of permissions | ||
* @param {Function} next - The next middleware function | ||
* @returns {Promise<void>} - A promise that resolves to void when permissions are retrieved | ||
*/ | ||
const getPermissions = async (req, res, next) => { | ||
try { | ||
const { name, client_id: clientId, client_key: clientKey } = req.query | ||
const permissions = await dbAdminPermission.getPermissions({ name, clientId, clientKey }) | ||
res.status(200).send(permissions) | ||
} catch ({ httpStatusCode = 500, message }) { | ||
return next(createError(httpStatusCode, { message })) | ||
} | ||
} | ||
|
||
module.exports = { getPermissions } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters