{"size": 728, "ext": "js", "max_stars_repo_path": "app/routes/fund.js", "max_stars_repo_name": "Tyav/Fintrack-backend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/routes/fund.js", "max_issues_repo_name": "Tyav/Fintrack-backend", "max_issues_repo_issues_event_min_datetime": "2020-11-27T16:23:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-02T05:54:52.000Z", "max_forks_repo_path": "app/routes/fund.js", "max_forks_repo_name": "Tyav/Fintrack-backend", "max_forks_repo_forks_event_min_datetime": "2020-02-04T07:11:22.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-04T07:11:22.000Z"}
{"max_stars_count": null, "max_issues_count": 4, "max_forks_count": 1, "avg_line_length": 25.1034482759, "max_line_length": 80, "alphanum_fraction": 0.6991758242}
const express = require('express');
const { celebrate: validate } = require('celebrate');
const decode = require('../middlewares/decode');
const validateParams = require('../validations/fund');
const fundCtrl = require('../controllers/fund');

const router = express.Router();

// decode user
router.use(decode);

//load funds by id
router.param('id', validate(validateParams.getOne, { abortEarly: false }));
router.param('id', fundCtrl.load);

router
  .route('/')
  // create user fund request
  .post(validate(validateParams.create, { abortEarly: false }), fundCtrl.create)
  // get all funds
  .get(fundCtrl.getAll);

router
  .route('/:id')
  // get funding request by id
  .get(fundCtrl.getOne);

module.exports = router;
