From 9711c0a40982353fd9e79bdaf7960cf8ef65fe7a Mon Sep 17 00:00:00 2001 From: Varun Date: Thu, 10 Jul 2025 14:34:10 +0530 Subject: [PATCH] get all suppliers --- src/controllers/userController.js | 17 +++++++++++++++++ src/routes/usersRoute.js | 11 ++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/controllers/userController.js b/src/controllers/userController.js index 6e940856..2baa3d23 100644 --- a/src/controllers/userController.js +++ b/src/controllers/userController.js @@ -1484,3 +1484,20 @@ exports.getordersofcustomer = async (req, reply) => { throw boom.boomify(err); } }; + + + +exports.getallsuppliers = async (req, reply) => { + try { + // Find the specific tank + const suppliers = await Supplier.find({ + }); + if (!suppliers) { + return reply.send({ status_code: 404, error: "suppliers not found" }); + } + // Send the found tank within a list + reply.send({ status_code: 200, data: [suppliers] }); + } catch (err) { + throw boom.boomify(err); + } +}; \ No newline at end of file diff --git a/src/routes/usersRoute.js b/src/routes/usersRoute.js index cd8970a3..354728d1 100644 --- a/src/routes/usersRoute.js +++ b/src/routes/usersRoute.js @@ -1231,7 +1231,16 @@ fastify.route({ handler: userController.getordersofcustomer }); - +fastify.route({ + method: "GET", + url: "/api/getallsuppliers", + schema: { + tags: ["User"], + description: "Get all suppliers for showing", + summary: "Get all suppliers for showing", + }, + handler: userController.getallsuppliers + });