const express = require("express");
const { authenticate } = require("../middleware/login.middleware.js");

const {
  postToken,
  getToken,
  getTokenByID,
  updateToken,
  getTokenByAddress,
  deleteToken,
  getUserTokens,
  checkUserHasToken,
  getUnusedTokensForUser,
} = require("../controllers/token.controller.js");

const router = express.Router();

router.post("/", authenticate, postToken);
router.get("/", getToken);
router.get("/usertokens", authenticate, getUserTokens);
router.get("/check-token", authenticate, checkUserHasToken);
router.get("/unused-token", authenticate, getUnusedTokensForUser);
router.get("/:id", getTokenByID);
router.get("/address/:tokenAddress", getTokenByAddress);
router.put("/:id", updateToken);
router.delete("/:id", deleteToken);

module.exports = router;
