const fastify = require("fastify"); const tankersController = require("../controllers/tankersController.js"); module.exports = function (fastify, opts, next) { fastify.route({ method: "POST", url: "/api/addTankers", schema: { tags: ["Tanker"], description: "This is for cretae New Tanker", summary: "This is for Create New Tanker.", body: { type: "object", properties: { tankerName: { type: "string" }, phoneNumber: { type: "string"}, typeofwater: { type: "string" }, capacity: { type: "string" }, }, }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: tankersController.addTankers, // onResponse: (request, reply) => { // validationHandler.sendPhoneVerificationCode(request, reply); // }, //onResponse: validationHandler.sendPhoneVerificationCode, }); //update tankers fastify.route({ method: "PUT", url: "/api/updateTankers/:tankerName", schema: { tags: ["Tanker"], summary: "This is for update tanker", params: { required: ["tankerName"], type: "object", properties: { tankerName: { type: "string", description: "tankerName", }, }, }, body: { type: "object", // required: ['phone'], properties: { tankerName: { type: "string", default: null }, phoneNumber: { type: "string", default: null }, capacity: { type: "number" }, typeofwater: { type: "string", default: null }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: [ // fastify.auth([fastify.operatorAuthenticate]), // validationHandler.validatePhoneFormat, // ], preHandler: fastify.auth([fastify.authenticate]), handler: tankersController.updateTankersInfo, }); fastify.route({ method: "PUT", url: "/api/deleteTanker/:tankerName", schema: { tags: ["Tanker"], summary: "This is for delete tanker", params: { required: ["tankerName"], type: "object", properties: { tankerName: { type: "string", description: "tankerName", }, }, }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: tankersController.deleteTankerInfo, }); fastify.route({ method: "POST", url: "/api/bookingData", schema: { tags: ["Tanker"], description: "This is for storing booking data of a Tanker", summary: "This is for storing booking data of a Tanker", body: { type: "object", properties: { typeofwater: { type: "string" }, capacity: { type: "string" }, address: { type: "string" }, dateTime: { type: "string"}, amount : { type: "string" }, }, }, security: [ { basicAuth: [], }, ], }, preHandler: fastify.auth([fastify.authenticate]), handler: tankersController.tankerBooking, // onResponse: (request, reply) => { // validationHandler.sendPhoneVerificationCode(request, reply); // }, //onResponse: validationHandler.sendPhoneVerificationCode, }); next(); }