Created
November 24, 2023 12:00
-
-
Save arcesino/a68738a7d7c15757eb961d396859d4b4 to your computer and use it in GitHub Desktop.
Traceable Express route definition
This file contains hidden or 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
const express = require('express'); | |
const { getProfile } = require('../middleware/getProfile'); | |
const validators = require('../middleware/validators'); | |
const { | |
contractsController, | |
jobsController, | |
balancesController, | |
adminController | |
} = require('../controllers') | |
const router = express.Router(); | |
// Contracts routes | |
router.get('/contracts', getProfile, contractsController.getUserContracts); | |
router.get('/contracts/:id', getProfile, contractsController.getUserContractById); | |
// Jobs routes | |
router.get('/jobs/unpaid', getProfile, jobsController.getUserUnpaidJobs); | |
router.post('/jobs/:jobId/pay', jobsController.payJob); | |
// Balances routes | |
router.get( | |
'/balances/deposit/:clientId', | |
validators.validate( | |
validators.amountValidator() | |
), | |
balancesController.depositToClientBalance | |
); | |
// Admin routes | |
router.get( | |
'/admin/best-profession', | |
validators.validate( | |
validators.startValidator(), | |
validators.endValidator() | |
), | |
adminController.bestProfession | |
); | |
router.get( | |
'/admin/best-clients', | |
validators.validate( | |
validators.startValidator(), | |
validators.endValidator(), | |
validators.limitValidator() | |
), | |
adminController.bestClients | |
); | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment