week5-node-express-knex-pg/routes/subscribers.js

32 lines
597 B
JavaScript
Raw Permalink Normal View History

2024-10-21 17:09:40 +01:00
import express from "express";
import {
getSubscribers,
addSubscriber,
getSubscriber,
deleteSubscriber
} from "../controllers/subscribers.js";
const router = express.Router();
/* GET a single subscriber request */
router.get("/:id", (req, res) => {
getSubscriber(req, res);
});
/* default path GET request */
router.get("/", (req, res) => {
getSubscribers(req, res);
});
/* add a subscriber */
router.post("/add", (req, res) => {
addSubscriber(req, res);
});
/* delete a subscriber */
router.delete("/", (req, res) => {
deleteSubscriber(req, res);
});
export default router;