diff --git a/src/controllers/storeController.js b/src/controllers/storeController.js new file mode 100644 index 00000000..a626373f --- /dev/null +++ b/src/controllers/storeController.js @@ -0,0 +1,318 @@ +const boom = require("boom"); +const bcrypt = require('bcrypt'); +const jwt = require('jsonwebtoken'); + +const fastify = require("fastify")({ + logger: true, + //disableRequestLogging: true, + genReqId(req) { + // you get access to the req here if you need it - must be a synchronous function + return uuidv4(); + }, +});const { Install, ProfilePictureInstall, generateinstallationId } = require("../models/store"); + +const supplierController = require("../controllers/supplierController") + + + + +exports.installSignUp = async (request, reply) => { + try { + const i_id = await generateinstallationId(); + const installationId = `AWIN${i_id}`; + + const { + // name, + phone, + address, + address1, + address2, + emails, + password, + profile, + team, + manager, + longitude, + latitude, + fcmId, + alternativeNumber, + firstName, + lastName, + city, + createdBy, + updatedBy, + } = request.body; + + // Check if a user with the same phone number already exists + const existingInstall = await Install.findOne({ phone }); + if (existingInstall) { + return reply.status(400).send({ message: 'Phone is already registered' }); + } + + // Hash the password using bcrypt + const hashedPassword = await bcrypt.hash(password, 10); + + // Create a new install object with the hashed password and other details + const install = new Install({ + // name, + installationId, + phone, + address, + address1, + address2, + emails, + services: { password: { bcrypt: hashedPassword } }, + profile, + team, + manager, + longitude, + latitude, + fcmId, + alternativeNumber, + firstName, + lastName, + city, + createdBy, + updatedBy, + }); + + // Save the new install to the database + await install.save(); + + reply.send({ message: 'Install Account Created Successfully' }); + } catch (err) { + reply.status(500).send({ message: err.message }); + } +}; + + + + + + +// exports.installLogin = async (request, reply) => { +// try { +// const { phone, password } = request.body; + +// // Check if an install with the phone number exists +// const install = await Install.findOne({ phone }); + +// if (!install) { +// return reply.status(401).send({ +// simplydata: { +// error: true, +// message: 'Invalid Phone or password' +// } +// }); +// } + +// // Compare the password entered by the user with the hashed password stored in the database +// const isPasswordValid = await bcrypt.compare(password, install.services.password.bcrypt); + +// if (!isPasswordValid) { +// return reply.status(401).send({ +// simplydata: { +// error: true, +// message: 'Invalid phone or password' +// } +// }); +// } + +// // Generate a JWT token for the authenticated install +// const token = fastify.jwt.sign({ phone: install.phone }, 'your_jwt_secret', { expiresIn: '30d' }); + +// // Fetch the profile picture if it exists +// const profilePicture = await ProfilePictureInstall.findOne({ customerId: install._id }); + +// const responsePayload = { +// simplydata: { +// error: false, +// apiversion: fastify.config.APIVERSION, +// access_token: token, +// email: install.emails, +// installationId: install.installationId, +// phone: install.phone, +// address1: install.address1, +// address2: install.address2, +// phoneVerified: install.phoneVerified, +// oneTimePasswordSetFlag: install.oneTimePasswordSetFlag, +// type: install.profile.role, +// fcmId: install.fcmId, +// team: install.team, +// city: install.city, +// manager: install.manager, +// firstName: install.firstName, +// lastName: install.lastName, +// address: install.address, +// alternativeNumber: install.alternativeNumber, +// } +// }; + +// if (profilePicture) { +// responsePayload.simplydata.picture = profilePicture.picture; +// } + +// // Return the token and user details to the client +// return reply.send(responsePayload); +// } catch (err) { +// reply.status(500).send({ +// simplydata: { +// error: true, +// message: err.message +// } +// }); +// } +// }; + + + + + exports.installationVerifyPhone = async (req, reply) => { + console.log("-------------------------------------------------"); + try { + phone = req.body.phone; + phoneVerificationCode = req.body.phoneVerificationCode; + + // check if user exists in the system. If user exists , display message that + // username is not available + console.log( + "this is the phone and verification code", + phone, + phoneVerificationCode + ); + deliveryBoyExists = await Install.findOne({ + phone: phone, + //phoneVerified: false, + phoneVerificationCode: phoneVerificationCode, + }); + console.log(deliveryBoyExists); + if (deliveryBoyExists) { + // update the phoneVerified flag to true. + const filter = { + phone: phone, + phoneVerificationCode: phoneVerificationCode, + }; + const update = { phoneVerified: true }; + const doc = await Install.findOneAndUpdate(filter, update); + updatedDeliveryBoy = await Install.findOne({ phone: phone }); + + if (updatedDeliveryBoy.phoneVerified) { + loginObject = await supplierController.loginInstallation(req); + console.log("loginObject...", loginObject); + if (loginObject.same) { + const phoneVerified = loginObject.delivery.phoneVerified; + const oneTimePasswordSetFlag = + loginObject.delivery.oneTimePasswordSetFlag; + console.log( + "oneTimePasswordSetFlag is ......", + oneTimePasswordSetFlag, + typeof oneTimePasswordSetFlag, + typeof phoneVerified + ); + if (!phoneVerified) { + reply.send({ + simplydata: { + error: false, + phoneVerified: false, + + phone: loginObject.delivery.phone, + oneTimePasswordSetFlag: oneTimePasswordSetFlag, + message: "Please Verify your phone number", + }, + }); + } else if (oneTimePasswordSetFlag) { + reply.send({ + simplydata: { + error: false, + phoneVerified: phoneVerified, + phone: loginObject.delivery.phone, + oneTimePasswordSetFlag: true, + message: "Password must be reset", + }, + }); + } else { + const token = fastify.jwt.sign( + { + name: loginObject.delivery.name, + }, + //expiresIn: expressed in seconds or a string describing a time span zeit/ms. Eg: 60, "2 days", "10h", "7d". + //A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc), + //otherwise milliseconds unit is used by default ("120" is equal to "120ms"). + { expiresIn: "30d" } + ); + console.log(token, "..token"); + + var d_id = loginObject.delivery._id; + + console.log(d_id, "deliveryId"); + var profilePicture = await ProfilePictureInstall.findOne({ + installationId: d_id, + }); + + // request.session.set('supplierId', loginObject.supplier._id) + + if (!profilePicture) { + reply.send({ + simplydata: { + error: false, + apiversion: fastify.config.APIVERSION, + access_token: token, + + phone: loginObject.delivery.phone, + installationId: loginObject.delivery.installationId, + name: loginObject.delivery.name, + address: loginObject.delivery.address, + phoneVerified: loginObject.delivery.phoneVerified, + oneTimePasswordSetFlag: + loginObject.delivery.oneTimePasswordSetFlag, + + + }, + }); + } + if (profilePicture) { + reply.send({ + simplydata: { + error: false, + apiversion: fastify.config.APIVERSION, + access_token: token, + picture: profilePicture.picture, + phone: loginObject.delivery.phone, + installationId: loginObject.delivery.installationId, + + name: loginObject.delivery.name, + address: loginObject.delivery.address, + phoneVerified: loginObject.delivery.phoneVerified, + oneTimePasswordSetFlag: + loginObject.delivery.oneTimePasswordSetFlag, + + }, + }); + } + } + } else { + error = { + simplydata: { + error: true, + code: 400, + message: "Invalid Details", + }, + }; + reply.send(error); + } + } + }else { + error = { + armintatankdata: { + error: true, + code: 10005, + message: "10005 - Verification code entered cannot be validated.", + }, + }; + req.body.regError = error; + reply.send(error); + } + } catch (err) { + throw boom.boomify(err); + } + }; diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index d0a7d56b..9e96cc4a 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -91,8 +91,8 @@ exports.addTanks = async (req, reply) => { - const customerId = req.params.customerId; - const { hardwareId, tankhardwareId,tankName,tankLocation } = req.body; + const InstallerId = req.params.InstallerId; + const { customerId,hardwareId, tankhardwareId,tankName,tankLocation } = req.body; // Check if the combination of hardwareId and tankhardwareId already exists @@ -109,6 +109,7 @@ exports.addTanks = async (req, reply) => { } const tankData = { + InstallerId:InstallerId, customerId: customerId, hardwareId: hardwareId, tankhardwareId: tankhardwareId, @@ -300,6 +301,8 @@ exports.updateTanklevels = async (req, reply) => { } }; + + exports.getTanklevels = async (req, reply) => { try { const customerId = req.params.customerId; @@ -316,23 +319,27 @@ exports.getTanklevels = async (req, reply) => { console.log("updated_data", updated_data); updated_data.forEach((tank) => { - const capacity = parseInt(tank.capacity.replace(/,/g, '')); + const waterlevel = parseInt(tank.waterlevel.replace(/,/g, ''), 10); + const capacity = parseInt(tank.capacity.replace(/,/g, ''), 10); + console.log(`Processing tank: ${tank.tankName}`); + console.log(`Type of Water: ${tank.typeOfWater}, Location: ${tank.tankLocation}, Waterlevel: ${waterlevel}, Capacity: ${capacity}`); + if (tank.tankLocation === 'sump' && tank.typeOfWater === 'Drinking Water') { - sumSumpDrinkingWater += parseInt(tank.waterlevel); + sumSumpDrinkingWater += waterlevel; sumSumpDrinkingWaterCapacity += capacity; } else if (tank.tankLocation === 'overhead' && tank.typeOfWater === 'Drinking Water') { - sumOverheadDrinkingWater += parseInt(tank.waterlevel); + sumOverheadDrinkingWater += waterlevel; sumOverheadDrinkingWaterCapacity += capacity; } else if (tank.tankLocation === 'sump' && tank.typeOfWater === 'Bore Water') { - sumSumpBoreWater += parseInt(tank.waterlevel); + sumSumpBoreWater += waterlevel; sumSumpBoreWaterCapacity += capacity; } else if (tank.tankLocation === 'overhead' && tank.typeOfWater === 'Bore Water') { - sumOverheadBoreWater += parseInt(tank.waterlevel); + sumOverheadBoreWater += waterlevel; sumOverheadBoreWaterCapacity += capacity; } }); - reply.send({ + const responseData = { status_code: 200, data: updated_data, totalDrinkingWaterInSump: sumSumpDrinkingWater, @@ -343,14 +350,21 @@ exports.getTanklevels = async (req, reply) => { totalDrinkingWaterInOverheadCapacity: sumOverheadDrinkingWaterCapacity, totalBoreWaterInSumpCapacity: sumSumpBoreWaterCapacity, totalBoreWaterInOverheadCapacity: sumOverheadBoreWaterCapacity, - }); + }; + + if (!reply.sent) { + reply.send(responseData); + } - return { message: 'success' }; } catch (err) { + if (!reply.sent) { + reply.code(500).send({ error: 'Internal Server Error' }); + } throw boom.boomify(err); } }; + const intervals = {}; let sump_water_levels=[]; let supplier_tanks = []; diff --git a/src/controllers/userController.js b/src/controllers/userController.js index 013960e8..3ebae2ad 100644 --- a/src/controllers/userController.js +++ b/src/controllers/userController.js @@ -300,6 +300,38 @@ exports.loginUser = async (req) => { throw boom.boomify(err); } }; +exports.loginUserWithOTP = async (req) => { + try { + const phone = req.body.phone; + const phoneVerificationCode = req.body.phoneVerificationCode; + + const userDetails = await User.findOne({ phone: phone }); + const supplier = await Supplier.findOne({phone: phone}) + const deliveryBoy = await DeliveryBoy.findOne( { phone : phone}) + const installation = await Install.findOne( { phone : phone}) + + let user; + if(userDetails){ + user = await User.findOne({ phone: phone, 'phoneVerificationCode': phoneVerificationCode }); + } + if(supplier){ + user = await Supplier.findOne({ phone: phone, 'phoneVerificationCode': phoneVerificationCode }); + } + if(deliveryBoy){ + user = await DeliveryBoy.findOne({ phone: phone, 'phoneVerificationCode': phoneVerificationCode }); + } + if(installation){ + user = await Install.findOne({ phone: phone, 'phoneVerificationCode': phoneVerificationCode }); + } + if (user) { + return { same: true, user: user }; + } else { + return { same: false }; + } + } catch (err) { + throw boom.boomify(err); + } +}; // Update an existing user exports.updateUser = async (req, reply) => { @@ -451,6 +483,7 @@ exports.logout = async (request, reply) => { // controller.js const http = require('https'); +const { Install } = require("../models/store"); exports.sendSms = async (request, reply) => { const code = Math.floor(100000 + Math.random() * 900000); @@ -463,6 +496,9 @@ exports.sendSms = async (request, reply) => { const user = await User.findOne({phone: mobile}) const supplier = await Supplier.findOne({phone: mobile}) const deliveryBoy = await DeliveryBoy.findOne( { phone : mobile}) + const installation = await Install.findOne( { phone : mobile}) + + if(user){ await User.findOneAndUpdate({phone: mobile}, { $set: {'phoneVerificationCode': code } }) } @@ -472,6 +508,10 @@ exports.sendSms = async (request, reply) => { if(deliveryBoy){ await DeliveryBoy.findOneAndUpdate({phone: mobile}, { $set: {'phoneVerificationCode': code } }) } + if(installation){ + await Install.findOneAndUpdate({phone: mobile}, { $set: {'phoneVerificationCode': code } }) + } + const apiUrl = `https://smslogin.co/v3/api.php?username=${username}&apikey=${apiKey}&senderid=${senderId}&mobile=${mobile}&message=${encodeURIComponent(message)}`; diff --git a/src/index.js b/src/index.js index e9df1586..caf1bf82 100644 --- a/src/index.js +++ b/src/index.js @@ -4,6 +4,11 @@ const { User,Counter, generateBookingId,resetCounter,generateCustomerId,ProfileP //const tanksController = require("./controllers/tanksController"); const tankersController = require("./controllers/tankersController.js"); const createConnectionController = require("./controllers/createConnectionController"); +const storeController = require("./controllers/storeController.js") +const boom = require("boom"); +const bcrypt = require('bcrypt'); + + const cors = require("cors"); const swagger = require("./config/swagger"); const rawBody = require('raw-body') @@ -274,6 +279,143 @@ fastify.post("/api/login", { }, }); +fastify.post("/api/installotplogin", { + schema: { + description: "This is for Login Otp Installation", + tags: ["Install"], + summary: "This is for Login Otp Installation", + body: { + type: "object", + required: ["phone", "phoneVerificationCode"], + properties: { + phoneVerificationCode: { type: "string" }, + phone: { type: "string" }, + }, + }, + }, + async handler(req, reply) { + try { + const phone = req.body.phone; + const phoneVerificationCode = req.body.phoneVerificationCode; + + const installationExists = await Install.findOne({ + phone: phone, + phoneVerificationCode: phoneVerificationCode, + }); + + if (installationExists) { + const filter = { + phone: phone, + phoneVerificationCode: phoneVerificationCode, + }; + const update = { phoneVerified: true }; + await Install.findOneAndUpdate(filter, update); + + const loginObject = await userController.loginUserWithOTP(req); + + if (loginObject.same) { + if (loginObject.user) { + const { user } = loginObject; + const phoneVerified = user.phoneVerified; + const oneTimePasswordSetFlag = user.oneTimePasswordSetFlag; + + if (!phoneVerified) { + reply.send({ + simplydata: { + error: false, + phoneVerified: false, + phone: user.phone, + oneTimePasswordSetFlag: oneTimePasswordSetFlag, + message: "Please Verify your phone number", + }, + }); + } else if (oneTimePasswordSetFlag) { + reply.send({ + simplydata: { + error: false, + phoneVerified: phoneVerified, + phone: user.phone, + oneTimePasswordSetFlag: true, + message: "Password must be reset", + }, + }); + } else { + const token = fastify.jwt.sign( + { + firstName: user.firstName, + }, + { expiresIn: "30d" } + ); + + const profilePicture = await ProfilePictureInstall.findOne({ + customerId: user._id, + }); +console.log(user) + const responsePayload = { + simplydata: { + error: false, + apiversion: fastify.config.APIVERSION, + access_token: token, + email: user.emails, + installationId: user.installationId, + phone: user.phone, + //name: user.name, + address1: user.address1, + address2: user.address2, + phoneVerified: user.phoneVerified, + oneTimePasswordSetFlag: user.oneTimePasswordSetFlag, + type: user.profile.role, + fcmId: user.fcmId, + team: user.team, + city: user.city, + manager: user.manager, + firstName: user.firstName, + lastName: user.lastName, + address: user.address, + alternativeNumber: user.alternativeNumber, + }, + }; + + if (profilePicture) { + responsePayload.simplydata.picture = profilePicture.picture; + } + + reply.send(responsePayload); + } + } else { + reply.send({ + simplydata: { + error: true, + code: 400, + message: "Invalid Details", + }, + }); + } + } else { + reply.send({ + simplydata: { + error: true, + code: 400, + message: "Invalid phone or phoneVerificationCode supplied", + }, + }); + } + } else { + reply.send({ + armintatankdata: { + error: true, + code: 10005, + message: "10005 - Verification code entered cannot be validated.", + }, + }); + } + } catch (err) { + throw boom.boomify(err); + } + }, +}); + + fastify.get("/api/reset_token/:customerId", { schema: { @@ -346,6 +488,7 @@ fastify.register(require("./routes/supplierRoute")); fastify.register(require("./routes/supplierOrdersRoutes")); fastify.register(require("./routes/friendRequestRoute")); fastify.register(require("./routes/adminRoute")); +fastify.register(require("./routes/storeRoute")); // Testing route allows for retrieving a user by phone so one can see what is the phone verification code sent for a given user's phone // Also allows deletion of a user with a given phone number @@ -358,6 +501,7 @@ fastify.register(require("./routes/forTestingRoute")); const {Storage} = require('@google-cloud/storage'); const { Supplier, profilePictureSupplier } = require("./models/supplier"); const multer = require('fastify-multer'); +const { ProfilePictureInstall, Install } = require("./models/store.js"); fastify.register(require('fastify-formbody')); // fastify.register(multer.contentParser); // const multipart = require('fastify-multipart'); @@ -591,6 +735,94 @@ fastify.post('/api/uploads-user/:customerId', async (request, reply) => { } }); +fastify.post("/api/insatllLogin", { + schema: { + description: "This is for Login Install", + tags: ["Install"], + summary: "This is for Login Install", + body: { + type: "object", + required: ["phone", "password"], + properties: { + phone: { type: "string" }, + password: { type: "string" }, + }, + }, + }, + async handler(req, reply) { + try { + const { phone, password } = req.body; + + // Check if an install with the phone number exists + const install = await Install.findOne({ phone }); + + if (!install) { + return reply.status(401).send({ + simplydata: { + error: true, + message: 'Invalid Phone or password' + } + }); + } + + // Compare the password entered by the user with the hashed password stored in the database + const isPasswordValid = await bcrypt.compare(password, install.services.password.bcrypt); + + if (!isPasswordValid) { + return reply.status(401).send({ + simplydata: { + error: true, + message: 'Invalid phone or password' + } + }); + } + + // Generate a JWT token for the authenticated install + const token = fastify.jwt.sign({ phone: install.phone }, 'your_jwt_secret', { expiresIn: '30d' }); + + // Fetch the profile picture if it exists + const profilePicture = await ProfilePictureInstall.findOne({ customerId: install._id }); + + const responsePayload = { + simplydata: { + error: false, + apiversion: fastify.config.APIVERSION, + access_token: token, + email: install.emails, + installationId: install.installationId, + phone: install.phone, + address1: install.address1, + address2: install.address2, + phoneVerified: install.phoneVerified, + oneTimePasswordSetFlag: install.oneTimePasswordSetFlag, + type: install.profile.role, + fcmId: install.fcmId, + team: install.team, + city: install.city, + manager: install.manager, + firstName: install.firstName, + lastName: install.lastName, + address: install.address, + alternativeNumber: install.alternativeNumber, + } + }; + + if (profilePicture) { + responsePayload.simplydata.picture = profilePicture.picture; + } + + // Return the token and user details to the client + return reply.send(responsePayload); + } catch (err) { + reply.status(500).send({ + simplydata: { + error: true, + message: err.message + } + }); + } + },}); + // Run the server! const start = async () => { diff --git a/src/models/store.js b/src/models/store.js new file mode 100644 index 00000000..f0e5c692 --- /dev/null +++ b/src/models/store.js @@ -0,0 +1,88 @@ +const mongoose = require('mongoose') +const Schema = mongoose.Schema; +const ObjectId = Schema.Types.ObjectId; +const { Counter} = require('../models/User') + + +const generateinstallationId = async () => { + var result = await Counter.findOneAndUpdate( + { _id: 'installation_id' }, + { $inc: { seq: 1 } }, + { upsert: true, new: true } + ); + + return result.seq; + }; + +const installationschema = new mongoose.Schema({ + // name: { type: String }, + phone: { type: String, unique: true, trim: true }, + address: String, + installationId: { type: String }, + phoneVerified: { type: Boolean, default: false }, + phoneVerificationCode: { type: Number, default: 11111 }, + passwordResetCode: { type: Number}, + oneTimePasswordSetFlag: { type: Boolean, default: false }, + emails: [{ email: String, verified: { type: Boolean, default: false } }], + services: { password: { bcrypt: String } }, + alternativeNumber: { type: String, default: null }, + firstName: { type: String, default: null }, + lastName: { type: String, default: null }, + address1: { type: String, default: null }, + address2: { type: String, default: null }, + city: { type: String, default: null }, + profile: { + + state: { type: String, default: null }, + country: { type: String, default: null }, + }, + team : { type: String, default: null}, + manager : { type: String, default: null}, + + longitude: { type : Number,default: 0.0}, + latitude: {type: Number,default: 0.0}, + + fcmId: { type: String, default: null }, + createdAt: { + type: Date, + default: function () { + return Date.now(); + }, + }, + createdBy: ObjectId, + updatedAt: { + type: Date, + default: function () { + return Date.now(); + }, + }, + updatedBy: ObjectId, + + }); + + const profilePictureInstallSchema = new Schema({ + installationId: { + type: String, + unique: true, + required: true + }, + picture: { + type: String, // Change the type to String + required: true, + validate: { + validator: function (value) { + const supportedFormats = ['jpg', 'jpeg', 'png']; + const fileExtension = value.split('.').pop().toLowerCase(); + return supportedFormats.includes(fileExtension); + }, + message: 'Picture must be a JPEG, PNG, or JPG image' + } + } + }); + + const ProfilePictureInstall = mongoose.model('ProfilePictureInstall', profilePictureInstallSchema); + + const Install = mongoose.model("Install", installationschema); + + + module.exports = { Install, ProfilePictureInstall, generateinstallationId}; diff --git a/src/models/tanks.js b/src/models/tanks.js index 4c4dae84..d5dc5b16 100644 --- a/src/models/tanks.js +++ b/src/models/tanks.js @@ -33,7 +33,7 @@ const RoleSchema = new Schema({ name: String }); const tanksSchema = new mongoose.Schema({ hardwareId: { type: String }, - + InstallerId: { type: String, default: null }, tankhardwareId: { type: String }, hardwareId_type: { type: String }, hardwareId_company: { type: String }, @@ -42,6 +42,7 @@ const tanksSchema = new mongoose.Schema({ blockName: { type: String, default: null }, capacity: { type: String, default: "0" }, height: { type: String, default: "0" }, + tankLocation: { type: String, default: null }, waterCapacityPerCm:{ type: String, default: "0" }, typeOfWater: { type: String, default: null }, waterlevel: { type: String, default: "0" }, diff --git a/src/routes/storeRoute.js b/src/routes/storeRoute.js new file mode 100644 index 00000000..6fc5a910 --- /dev/null +++ b/src/routes/storeRoute.js @@ -0,0 +1,92 @@ +const fastify = require("fastify"); +const storeController = require('../controllers/storeController') + + +module.exports = function (fastify, opts, next) { + fastify.route({ + method: 'POST', + url: '/api/installSignup', + schema: { + tags: ['Install'], + description: 'This is for creating a New Install Account', + summary: 'This is for creating a New Install Account', + body: { + type: 'object', + properties: { + phone: { type: 'string' }, + password: { type: 'string' }, + emails: { + type: 'array', + maxItems: 2, + items: { + type: 'object', + properties: { + email: { type: 'string', default: null }, + }, + }, + }, + //name: { type: 'string' }, + + team: { type: 'string', default: null }, + manager: { type: 'string', default: null }, + address: { type: 'string', default: null }, + address1: { type: 'string', default: null }, + address2: { type: 'string', default: null }, + city: { type: 'string', default: null }, + state: { type: 'string', default: null }, + zip: { type: 'string', default: null }, + country: { type: 'string', default: null }, + notes: { type: 'string', default: null }, + latitude: { type: 'number', default: 0.0 }, + longitude: { type: 'number', default: 0.0 }, + fcmId: { type: 'string', default: null }, + alternativeNumber : { type: 'string', default: null }, + firstName :{ type: 'string', default: null }, + lastName : { type: 'string', default: null }, + }, + }, + security: [ + { + basicAuth: [], + }, + ], + }, + handler: storeController.installSignUp, + }); +// fastify.post("/api/insatllLogin", { +// schema: { +// description: "This is for Login Install", +// tags: ["Install"], +// summary: "This is for Login Install", +// body: { +// type: "object", +// required: ["phone", "password"], +// properties: { +// phone: { type: "string" }, +// password: { type: "string" }, +// }, +// }, +// }, +// handler: storeController.installLogin, +// }); + +// fastify.post("/api/installotplogin", { +// schema: { +// description: "This is for Login Otp Boy", +// tags: ["Install"], +// summary: "This is for Login Otp Boy", +// body: { +// type: "object", +// required: ["phone"], +// properties: { +// phoneVerificationCode: { type: "string" }, +// phone: { type: "string" }, +// }, +// }, +// }, +// handler: storeController.installationVerifyPhone, +// }); + + +next(); +}; diff --git a/src/routes/tanksRoute.js b/src/routes/tanksRoute.js index 7cf084b2..8d2acfdb 100644 --- a/src/routes/tanksRoute.js +++ b/src/routes/tanksRoute.js @@ -6,18 +6,18 @@ module.exports = function (fastify, opts, next) { fastify.route({ method: "POST", - url: "/api/addTanks/:customerId", + url: "/api/addTanks/:InstallerId", schema: { tags: ["Tank"], description: "This is for cretae New Tank", summary: "This is for Create New Tank.", params: { - required: ["customerId"], + required: ["InstallerId"], type: "object", properties: { - customerId: { + InstallerId: { type: "string", - description: "customerId", + description: "InstallerId", }, }, }, @@ -29,7 +29,7 @@ module.exports = function (fastify, opts, next) { tankName: { type: "string" }, blockName: { type: "string"}, capacity: { type: "string" }, - + customerId: { type: "string" }, typeOfWater: { type: "string" }, waterCapacityPerCm:{ type: "string" }, tankLocation: { type: "string" }, @@ -251,7 +251,7 @@ module.exports = function (fastify, opts, next) { }, ], }, - preHandler: fastify.auth([fastify.authenticate]), + // preHandler: fastify.auth([fastify.authenticate]), handler: tanksController.getTanklevels, });