{"size": 3655, "ext": "js", "max_stars_repo_path": "routes/vendors.js", "max_stars_repo_name": "SoftwareBrothers/forfeater", "max_stars_repo_stars_event_min_datetime": "2018-11-13T19:54:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-02T19:09:10.000Z", "max_issues_repo_path": "routes/vendors.js", "max_issues_repo_name": "SoftwareBrothers/forfeater", "max_issues_repo_issues_event_min_datetime": "2019-01-14T23:15:23.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-07T18:11:05.000Z", "max_forks_repo_path": "routes/vendors.js", "max_forks_repo_name": "SoftwareBrothers/forfeater", "max_forks_repo_forks_event_min_datetime": "2019-02-17T11:08:09.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-05T10:05:04.000Z"}
{"max_stars_count": 12, "max_issues_count": 2, "max_forks_count": 3, "avg_line_length": 28.3333333333, "max_line_length": 112, "alphanum_fraction": 0.6402188782}
var express = require('express');
var router = express.Router();

var vendor_controller = require('../controllers/vendorController');
var product_controller = require('../controllers/productController');
var choice_controller = require('../controllers/choiceController');

module.exports = function (app) {
  /**
   * @api {get} /vendors list
   *
   * @apiDescription Get all vendors
   *
   * @apiName list
   * @apiGroup Vendor
   *
   * @apiHeader {string} Authorization Bearer
   *
   * @apiSuccess {Number} id Id
   * @apiSuccess {String} name  Name
   * @apiSuccess {String} url URL
   * @apiSuccess {DateTime} createdAt  Created At
   * @apiSuccess {DateTime} updatedAt UpdatedAt
   */
  router.get('/', app.oauth.authorise(), vendor_controller.list);

  /**
   * @api {get} /vendors/:id show
   *
   * @apiDescription Get vendor
   *
   * @apiName show
   * @apiGroup Vendor
   *
   * @apiHeader {string} Authorization Bearer
   *
   * @apiSuccess {Number} id Id
   * @apiSuccess {String} name  Name
   * @apiSuccess {String} url URL
   * @apiSuccess {DateTime} createdAt  Created At
   * @apiSuccess {DateTime} updatedAt UpdatedAt
   */
  router.get('/:id', app.oauth.authorise(), vendor_controller.show);

  /**
   * @api {post} /vendors store
   *
   * @apiDescription Create vendor
   *
   * @apiName store
   * @apiGroup Vendor
   *
   * @apiHeader {string} Authorization Bearer
   *
   * @apiParam {String} name Name
   * @apiParam {String} [url]  URL
   */
  router.post('/', app.oauth.authorise(), vendor_controller.store);

  /**
   * @api {patch} /vendors/:vendorId update
   *
   * @apiDescription Update vendor
   *
   * @apiName update
   * @apiGroup Vendor
   *
   * @apiHeader {string} Authorization Bearer
   *
   * @apiParam {String} name Name
   * @apiParam {String} [url]  URL
   */
  router.patch('/:vendorId', app.oauth.authorise(), vendor_controller.update);

  /**
   * @api {delete} /vendors/:vendorId delete
   *
   * @apiDescription Delete vendor
   *
   * @apiName delete
   * @apiGroup Vendor
   *
   * @apiHeader {string} Authorization Bearer
   */
  router.delete('/:vendorId', app.oauth.authorise(), vendor_controller.delete);

  /**
   * @api {get} /vendors/:vendorId/products list
   *
   * @apiDescription Get all products of vendor
   *
   * @apiName list
   * @apiGroup Product
   *
   * @apiHeader {string} Authorization Bearer
   */
  router.get('/:vendorId/products', app.oauth.authorise(), product_controller.list);

  /**
   * @api {get} /vendors/:vendorId/products/:productId show
   *
   * @apiDescription Get product
   *
   * @apiName show
   * @apiGroup Product
   *
   * @apiHeader {string} Authorization Bearer
   */
  router.get('/:vendorId/products/:productId', app.oauth.authorise(), product_controller.show);
  router.post('/:vendorId/products', app.oauth.authorise(), product_controller.store);
  router.post('/:vendorId/products/many', app.oauth.authorise(), product_controller.storeMany);
  router.patch('/:vendorId/products/:productId', app.oauth.authorise(), product_controller.update);
  router.delete('/:vendorId/products/:productId', app.oauth.authorise(), product_controller.delete);

  /**
   * @api {get} /vendors/:vendorId/products/:productId/choices list
   *
   * @apiDescription Get all choices of product
   *
   * @apiName listOfProduct
   * @apiGroup Choice
   *
   * @apiHeader {string} Authorization Bearer
   */
  router.get('/:vendorId/products/:productId/choices', app.oauth.authorise(), choice_controller.listOfProduct);

  return router;
};
