const fastify = require("fastify"); const tanksController = require("../controllers/tanksController"); module.exports = function (fastify, opts, next) { fastify.route({ method: "POST", url: "/api/addTanks/:customerId", schema: { tags: ["Tank"], description: "This is for cretae New Tank", summary: "This is for Create New Tank.", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, body: { type: "object", properties: { tankName: { type: "string" }, blockName: { type: "string"}, capacity: { type: "string" }, typeOfWater: { type: "string" }, tankLocation: { type: "string" }, }, }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: tanksController.addTanks, // onResponse: (request, reply) => { // validationHandler.sendPhoneVerificationCode(request, reply); // }, //onResponse: validationHandler.sendPhoneVerificationCode, }); fastify.route({ method: "PUT", url: "/api/updateTanks/:customerId", schema: { tags: ["Tank"], summary: "This is for update tank", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, querystring: { tankName: {type: 'string'} }, body: { type: "object", // required: ['phone'], properties: { tankName: { type: "string", default: null }, blockName: { type: "string", default: null }, capacity: { type: "string" }, typeOfWater: { type: "string", default: null }, type: { type: "string" }, tankLocation: { type: "string", default: null }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: [ // fastify.auth([fastify.operatorAuthenticate]), // validationHandler.validatePhoneFormat, // ], preHandler: fastify.auth([fastify.authenticate]), handler: tanksController.updateTanksInfo, }); fastify.route({ method: "PUT", url: "/api/deleteTank/:customerId", schema: { tags: ["Tank"], summary: "This is for delete tank", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, querystring: { tankName: {type: 'string'} }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: tanksController.deleteTanksInfo, }); fastify.get("/api/getTanks", { schema: { tags: ["Tank"], description: "This is for Get Tank Data", summary: "This is for to Get Tank Data", querystring: { customerId: {type: 'string'} }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: tanksController.getTank, }); fastify.route({ method: "PUT", url: "/api/updateTanklevels/:customerId", schema: { tags: ["Tank"], summary: "This is for updating tank levels", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, // querystring: { // tankName: {type: 'string'} // }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: tanksController.updateTanklevels, }); fastify.route({ method: "GET", url: "/api/getTanklevels/:customerId", schema: { tags: ["Tank"], summary: "This is for getting tank levels", params: { required: ["customerId"], type: "object", properties: { customerId: { type: "string", description: "customerId", }, }, }, // querystring: { // tankName: {type: 'string'} // }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: tanksController.getTanklevels, }); next(); }