const express = require("express");

// create an instance of our router
const router = express.Router();

// GET /todos
router.get("/todos", (req, res) => {
    res.status(200).json({ mssg: "GET REQUEST TO /api/todos" });
});

// POST /todos
router.post("/todos", (req, res) => {
    res.status(201).json({ mssg: "POST REQUEST TO /api/todos" });
});

// DELETE /todos/:id
router.delete("/todos/:id", (req, res) => {
    res.status(200).json({ mssg: "DELETE REQUEST TO /api/todos" });
});

// PUT /todos/:id
router.put("/todos/:id", (req, res) => {
    res.status(200).json({ mssg: "PUT REQUEST TO /api/todos" });
});

module.exports = router;




<aside> 💡 Remark: the status codes we are using here are in a way arbitrary but these are standard status codes that are used with these respective CRUD operations

</aside>

const express = require("express");
const app = express();

// import our todos router
const router = require("./routes");

// use /api to prefix our endpoints
app.use("/api", router);

const port = 5000;
app.listen(port, () => {
    console.log(`Server is listening on <http://localhost>:${port}`);
})