From 8c4947c7b06f30a7012c601afa0de71e1d9a6f99 Mon Sep 17 00:00:00 2001 From: gungunfebrianza Date: Wed, 18 Aug 2021 05:40:10 +0700 Subject: [PATCH] add routes --- Example-1/routes/tutorial.routes.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Example-1/routes/tutorial.routes.js diff --git a/Example-1/routes/tutorial.routes.js b/Example-1/routes/tutorial.routes.js new file mode 100644 index 0000000..955d9a2 --- /dev/null +++ b/Example-1/routes/tutorial.routes.js @@ -0,0 +1,28 @@ +module.exports = app => { + const tutorials = require("../controllers/tutorial.controller.js"); + + var router = require("express").Router(); + + // Create a new Tutorial + router.post("/", tutorials.create); + + // Retrieve all Tutorials + router.get("/", tutorials.findAll); + + // Retrieve all published Tutorials + router.get("/published", tutorials.findAllPublished); + + // Retrieve a single Tutorial with id + router.get("/:id", tutorials.findOne); + + // Update a Tutorial with id + router.put("/:id", tutorials.update); + + // Delete a Tutorial with id + router.delete("/:id", tutorials.delete); + + // Delete all Tutorials + router.delete("/", tutorials.deleteAll); + + app.use('/api/tutorials', router); +}; \ No newline at end of file