const express = require("express");
const router = express.Router();

const {
  tradeOption,
  getOptionChain,
  getOptionPositions,
  getOptionOrders,
  closeOptionPosition,
  cancelOptionOrder,
  getOptionsIndex,
} = require("../controllers/optionsController");

const { authenticate } = require("../middleware/auth");

router.get("/index", authenticate, getOptionsIndex);
router.get("/chain/:symbol", authenticate, getOptionChain);
router.get("/positions", authenticate, getOptionPositions);
router.get("/orders", authenticate, getOptionOrders);

router.post("/trade", authenticate, tradeOption);
router.post("/positions/:positionId/close", authenticate, closeOptionPosition);
router.delete("/orders/:orderId/cancel", authenticate, cancelOptionOrder);

module.exports = router;