From 6306ca991735fddaabd034f5d48483233bcf18ca Mon Sep 17 00:00:00 2001 From: varun Date: Mon, 8 Jul 2024 06:20:34 -0400 Subject: [PATCH] waterlevel sensors --- src/config/swagger.js | 4 ++-- src/controllers/storeController.js | 3 ++- src/models/store.js | 2 +- src/routes/storeRoute.js | 14 ++++++++++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/config/swagger.js b/src/config/swagger.js index 04ebf510..db907611 100644 --- a/src/config/swagger.js +++ b/src/config/swagger.js @@ -14,9 +14,9 @@ exports.options = { }, // We have to change this beacause this is running on local // we have to run on this on swagger - //host: "localhost:3000", //Devlopemnt host on lcoal + host: "localhost:3000", //Devlopemnt host on lcoal - host: "35.207.198.4:3000", //Production for swagger + //host: "35.207.198.4:3000", //Production for swagger schemes: ["http"], consumes: ["application/json"], produces: ["application/json"], diff --git a/src/controllers/storeController.js b/src/controllers/storeController.js index 5566714d..3b89aca9 100644 --- a/src/controllers/storeController.js +++ b/src/controllers/storeController.js @@ -500,7 +500,8 @@ exports.addStore = async (request, reply) => { const moment = require('moment'); exports.createwaterlevelSensor = async (req, reply) => { try { - const { hardwareId,hardwareId_company, type, indate,storeId } = req.body; + const storeId = req.params.storeId + const { hardwareId,hardwareId_company, type, indate } = req.body; var mater_seq_id = await generatewaterlevelsensorId(); const date = moment().format('MM-DD'); const prefix = 'AS-' + date + '--MALOV1-'; diff --git a/src/models/store.js b/src/models/store.js index 49708428..d0be8415 100644 --- a/src/models/store.js +++ b/src/models/store.js @@ -165,7 +165,7 @@ const installationschema = new mongoose.Schema({ const waterLeverSensorInSchema = new mongoose.Schema({ - storeeId:{ type: String }, + storeId:{ type: String }, hardwareId: { type: String }, masterId: { type: String, default: null }, type: { type: String }, diff --git a/src/routes/storeRoute.js b/src/routes/storeRoute.js index d43bb7d5..f96619bc 100644 --- a/src/routes/storeRoute.js +++ b/src/routes/storeRoute.js @@ -123,17 +123,27 @@ fastify.post('/api/stores', { -fastify.post("/api/createwaterlevelSensor", { +fastify.post("/api/createwaterlevelSensor/:storeId", { schema: { description: "This is for creating waterlevel Sensor", tags: ["Store-Data"], summary: "This is for creating waterlevel Sensor", + params: { + required: ["storeId"], + type: "object", + properties: { + storeId: { + type: "string", + description: "storeId", + }, + }, + }, body: { type: "object", properties: { - storeId: { type: "string" }, + hardwareId: { type: "string" }, type: { type: "string" }, indate: { type: "string" },