From 18353efb06a54544be095334a7961fbb6de1bc5c Mon Sep 17 00:00:00 2001 From: varun Date: Thu, 8 Jun 2023 06:08:13 -0400 Subject: [PATCH] iot devices for multiple --- src/routes/tanksRoute.js | 67 ++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/routes/tanksRoute.js b/src/routes/tanksRoute.js index 95ad43f0..90ba02fb 100644 --- a/src/routes/tanksRoute.js +++ b/src/routes/tanksRoute.js @@ -328,42 +328,43 @@ module.exports = function (fastify, opts, next) { - fastify.route({ - method: "POST", - url: "/api/APIWrite", - schema: { - tags: ["Tank"], - description: "This is for cretae IOT Device", - summary: "This is for Create IOT Device.", - - body: { - type: "object", - properties: { - hardwareId: { type: "string" }, - tankHeight: { type: "string"}, - maxLevel: { type: "string" }, - minLevel: { type: "string" }, - tankhardwareId:{ type: "string" }, - mode: { type: "string" }, + fastify.route({ + method: "POST", + url: "/api/APIWrite", + schema: { + tags: ["Tank"], + description: "This is for creating an IOT Device", + summary: "Create IOT Device", + body: { + type: "object", + properties: { + hardwareId: { type: "string" }, + mode: { type: "string" }, + tanks: { + type: "array", + items: { + type: "object", + properties: { + tankhardwareId: { type: "string" }, + tankHeight: { type: "string" }, + maxLevel: { type: "string" }, + minLevel: { type: "string" } + }, + required: ["tankhardwareId", "tankHeight", "maxLevel", "minLevel"] + } + } + }, + required: ["hardwareId", "mode", "tanks"] }, + security: [ + { + basicAuth: [] + } + ] }, - security: [ - { - basicAuth: [], - }, - ], - }, - // preHandler: [ - // fastify.auth([fastify.operatorAuthenticate]), - // validationHandler.validatePhoneFormat, - // ], - - - + handler: tanksController.IotDevice + }); - handler: tanksController.IotDevice, - - }); fastify.get("/api/APIRead", { schema: {