-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
6,596 additions
and
4 deletions.
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,103 @@ | ||
import { Router } from 'express'; | ||
import getRandomAngry from '../../../controllers/v4/interactions/angry.js'; | ||
import createRateLimiter from '../../../middlewares/rateLimit.js'; | ||
import authorize from '../../../middlewares/authorize.js'; | ||
import incrementData from '../../../middlewares/database/add.js'; | ||
import updateData from '../../../middlewares/database/update.js'; | ||
import deleteData from '../../../middlewares/database/delete.js'; | ||
|
||
const router = Router(); | ||
|
||
router | ||
.route('/') | ||
/** | ||
* @api {get} v4/angry Get a Random Angry | ||
* @apiDescription Retrieve a random angry. | ||
* @apiName GetRandomAngry | ||
* @apiGroup Angry | ||
* @apiPermission user | ||
* | ||
* @apiHeader {String} Authorization User's access token. | ||
* | ||
* @apiSuccess {Object[]} users List of users. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated users can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
* | ||
*/ | ||
.get(authorize(config.roles.USER), createRateLimiter(), getRandomAngry) | ||
/** | ||
* @api {post} v4/angry Increment Angry Data | ||
* @apiDescription Increment data related to angrys (only accessible by database moderators). | ||
* @apiName IncrementAngryData | ||
* @apiGroup Angry | ||
* @apiPermission database_moderator | ||
* | ||
* @apiHeader {String} Authorization Database Moderator's access token. | ||
* | ||
* @apiSuccess {Object} result Result of the data incrementation. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated database moderator can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
* | ||
*/ | ||
.post(authorize(config.roles.DB_MOD), createRateLimiter(), incrementData('Angry')); | ||
|
||
router | ||
.route('/:id') | ||
/** | ||
* @api {patch} v4/angry/:id Update Angry Data | ||
* @apiDescription Update data related to angrys with a specific ID (only accessible by database moderators). | ||
* @apiName UpdateAngryData | ||
* @apiGroup Angry | ||
* @apiPermission database_moderator | ||
* | ||
* @apiHeader {String} Authorization database moderator access token. | ||
* | ||
* @apiSuccess {Object} result Result of the data update. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated database moderator can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
*/ | ||
.patch(authorize(config.roles.DB_MOD), createRateLimiter(), updateData('Angry')) | ||
/** | ||
* @api {delete} v4/angry/:id Delete Angry Data | ||
* @apiDescription Delete data related to angry with a specific ID (only accessible by admins). | ||
* @apiName DeleteAngryData | ||
* @apiGroup Angry | ||
* @apiPermission admin | ||
* | ||
* @apiHeader {String} Authorization Admin's access token. | ||
* | ||
* @apiSuccess {Object} result Result of the data deletion. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated admins can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
*/ | ||
.delete(authorize(config.roles.ADMIN), createRateLimiter(), deleteData('Angry')); | ||
// Export the router | ||
export default router; |
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,103 @@ | ||
import { Router } from 'express'; | ||
import getRandomBaka from '../../../controllers/v4/interactions/baka.js'; | ||
import createRateLimiter from '../../../middlewares/rateLimit.js'; | ||
import authorize from '../../../middlewares/authorize.js'; | ||
import incrementData from '../../../middlewares/database/add.js'; | ||
import updateData from '../../../middlewares/database/update.js'; | ||
import deleteData from '../../../middlewares/database/delete.js'; | ||
|
||
const router = Router(); | ||
|
||
router | ||
.route('/') | ||
/** | ||
* @api {get} v4/baka Get a Random Baka | ||
* @apiDescription Retrieve a random baka. | ||
* @apiName GetRandomBaka | ||
* @apiGroup Baka | ||
* @apiPermission user | ||
* | ||
* @apiHeader {String} Authorization User's access token. | ||
* | ||
* @apiSuccess {Object[]} users List of users. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated users can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
* | ||
*/ | ||
.get(authorize(config.roles.USER), createRateLimiter(), getRandomBaka) | ||
/** | ||
* @api {post} v4/baka Increment Baka Data | ||
* @apiDescription Increment data related to bakas (only accessible by database moderators). | ||
* @apiName IncrementBakaData | ||
* @apiGroup Baka | ||
* @apiPermission database_moderator | ||
* | ||
* @apiHeader {String} Authorization Database Moderator's access token. | ||
* | ||
* @apiSuccess {Object} result Result of the data incrementation. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated database moderator can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
* | ||
*/ | ||
.post(authorize(config.roles.DB_MOD), createRateLimiter(), incrementData('Baka')); | ||
|
||
router | ||
.route('/:id') | ||
/** | ||
* @api {patch} v4/baka/:id Update Baka Data | ||
* @apiDescription Update data related to bakas with a specific ID (only accessible by database moderators). | ||
* @apiName UpdateBakaData | ||
* @apiGroup Baka | ||
* @apiPermission database_moderator | ||
* | ||
* @apiHeader {String} Authorization database moderator access token. | ||
* | ||
* @apiSuccess {Object} result Result of the data update. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated database moderator can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
*/ | ||
.patch(authorize(config.roles.DB_MOD), createRateLimiter(), updateData('Baka')) | ||
/** | ||
* @api {delete} v4/baka/:id Delete Baka Data | ||
* @apiDescription Delete data related to baka with a specific ID (only accessible by admins). | ||
* @apiName DeleteBakaData | ||
* @apiGroup Baka | ||
* @apiPermission admin | ||
* | ||
* @apiHeader {String} Authorization Admin's access token. | ||
* | ||
* @apiSuccess {Object} result Result of the data deletion. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated admins can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
*/ | ||
.delete(authorize(config.roles.ADMIN), createRateLimiter(), deleteData('Baka')); | ||
// Export the router | ||
export default router; |
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,103 @@ | ||
import { Router } from 'express'; | ||
import getRandomBite from '../../../controllers/v4/interactions/bite.js'; | ||
import createRateLimiter from '../../../middlewares/rateLimit.js'; | ||
import authorize from '../../../middlewares/authorize.js'; | ||
import incrementData from '../../../middlewares/database/add.js'; | ||
import updateData from '../../../middlewares/database/update.js'; | ||
import deleteData from '../../../middlewares/database/delete.js'; | ||
|
||
const router = Router(); | ||
|
||
router | ||
.route('/') | ||
/** | ||
* @api {get} v4/bite Get a Random Bite | ||
* @apiDescription Retrieve a random bite. | ||
* @apiName GetRandomBite | ||
* @apiGroup Bite | ||
* @apiPermission user | ||
* | ||
* @apiHeader {String} Authorization User's access token. | ||
* | ||
* @apiSuccess {Object[]} users List of users. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated users can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
* | ||
*/ | ||
.get(authorize(config.roles.USER), createRateLimiter(), getRandomBite) | ||
/** | ||
* @api {post} v4/bite Increment Bite Data | ||
* @apiDescription Increment data related to bites (only accessible by database moderators). | ||
* @apiName IncrementBiteData | ||
* @apiGroup Bite | ||
* @apiPermission database_moderator | ||
* | ||
* @apiHeader {String} Authorization Database Moderator's access token. | ||
* | ||
* @apiSuccess {Object} result Result of the data incrementation. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated database moderator can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
* | ||
*/ | ||
.post(authorize(config.roles.DB_MOD), createRateLimiter(), incrementData('Bite')); | ||
|
||
router | ||
.route('/:id') | ||
/** | ||
* @api {patch} v4/bite/:id Update Bite Data | ||
* @apiDescription Update data related to bites with a specific ID (only accessible by database moderators). | ||
* @apiName UpdateBiteData | ||
* @apiGroup Bite | ||
* @apiPermission database_moderator | ||
* | ||
* @apiHeader {String} Authorization database moderator access token. | ||
* | ||
* @apiSuccess {Object} result Result of the data update. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated database moderator can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
*/ | ||
.patch(authorize(config.roles.DB_MOD), createRateLimiter(), updateData('Bite')) | ||
/** | ||
* @api {delete} v4/bite/:id Delete Bite Data | ||
* @apiDescription Delete data related to bite with a specific ID (only accessible by admins). | ||
* @apiName DeleteBiteData | ||
* @apiGroup Bite | ||
* @apiPermission admin | ||
* | ||
* @apiHeader {String} Authorization Admin's access token. | ||
* | ||
* @apiSuccess {Object} result Result of the data deletion. | ||
* | ||
* @apiError (Unauthorized 401) Unauthorized Only authenticated admins can access the data. | ||
* @apiError (Forbidden 403) Forbidden Only users can access the data. | ||
* @apiError (Too Many Requests 429) TooManyRequests The client has exceeded the allowed number of requests within the time window. | ||
* @apiError (Internal Server Error 500) InternalServerError An error occurred while processing the rate limit. | ||
* | ||
* @function createRateLimit | ||
* @description Creates a rate limiter middleware to control the frequency of requests. | ||
* @returns {function} Express middleware function that handles rate limiting. | ||
*/ | ||
.delete(authorize(config.roles.ADMIN), createRateLimiter(), deleteData('Bite')); | ||
// Export the router | ||
export default router; |
Oops, something went wrong.