Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | const express = require("express");
const router = express.Router();
const apiKeyController = require("../controllers/apiKeyController");
const { authMiddleware } = require("../middleware/authMiddleware");
const apiKeyMiddleware = require("../middleware/apiKeyMiddleware");
// Corrected routes
router.post("/", authMiddleware, apiKeyController.createApiKey);
router.get("/", authMiddleware, apiKeyController.getApiKeys);
router.delete(
"/:id",
authMiddleware,
apiKeyMiddleware,
apiKeyController.deleteApiKey,
);
router.get(
"/:id/usage",
authMiddleware,
apiKeyMiddleware,
apiKeyController.getApiKeyUsage,
);
router.get(
"/protected-resource",
authMiddleware,
apiKeyMiddleware,
(req, res) => {
res.json({ message: "You accessed this with a valid API key!" });
},
);
module.exports = router;
|