varun 2 years ago
commit 9dabeb5f4e

@ -7,11 +7,49 @@ const fastify = require("fastify");
const { Tank, MotorData, IotData } = require('../models/tanks')
// exports.adminSignUp = async (request, reply) => {
// try {
// const { email, password } = request.body
// // Check if an admin with the same email address already exists
// const existingAdmin = await Admin.findOne({ email })
// if (existingAdmin) {
// return reply.status(400).send({ message: 'Email already registered' })
// }
// // Hash the password using bcrypt
// const hashedPassword = await bcrypt.hash(password, 10)
// // Create a new admin object with the hashed password
// const admin = new Admin({ email, password: hashedPassword })
// // Save the new admin to the database
// await admin.save()
// // Generate a JWT token for the new admin
// // const token = jwt.sign({ email: admin.email }, 'secret')
// // // Return the token to the client
// // return { token }
// reply.send({message : "Admin Account Created Sucessfully"})
// } catch (err) {
// reply.status(500).send({ message: err.message })
// }
// }
exports.adminSignUp = async (request, reply) => {
try {
const { email, password } = request.body
// Check if the email address is valid
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
if (!emailRegex.test(email)) {
return reply.status(400).send({ message: 'Invalid email address' })
}
// Check if an admin with the same email address already exists
const existingAdmin = await Admin.findOne({ email })
@ -41,7 +79,6 @@ exports.adminSignUp = async (request, reply) => {
exports.adminLogin = async (request, reply) => {
try {
const { email, password } = request.body

@ -211,6 +211,8 @@ exports.tankerBooking = async (req, reply) => {
supplierId:req.body.supplierId,
tankName:req.body.tankName,
tankLocation:req.body.tankLocation,
latitude: req.body.latitude,
longitude: req.body.longitude,
//date: req.body.date,
// time: req.body.time,
customerPhone : customer_mobile,
@ -243,6 +245,8 @@ exports.tankerBooking = async (req, reply) => {
tankersBookingData.supplierPhone = supplier_mobile;
tankersBookingData.customerName = customer_name;
tankersBookingData.supplierName = supplier_name;
tankersBookingData.latitude =usertobeInserted.latitude
tankersBookingData.longitude=usertobeInserted.longitude
}
}

@ -15,149 +15,7 @@ const schedule = require('node-schedule');
// Handle friend request creation
// exports.friendRequest = async (request, reply) => {
// try {
// // const { senderId, receiverId } = request.body;
// const customerId = request.body.customerId;
// const supplierId = request.body.supplierId;
// // Check if the sender and receiver exist in the database
// // const sender = await User.findById(senderId);
// // const receiver = await Supplier.findById(receiverId);
// // console.log("sender" , sender)
// // console.log("receiver" , receiver)
// const sender = await User.findOne({ customerId : customerId});
// const receiver = await Supplier.findOne({ supplierId : supplierId});
// console.log("sender" , sender.customerId)
// console.log("receiver" , receiver.supplierId)
// if (!sender || !receiver) {
// throw new Error('Sender or receiver not found');
// }
// // Check if a friend request already exists between the two users
// // const existingRequest = await FriendRequest.findOne({ sender: senderId, receiver: receiverId });
// const existingRequest = await FriendRequest.findOne({ customerId: sender.customerId, supplierId: receiver.supplierId});
// console.log(existingRequest, " .. exist")
// if (existingRequest) {
// throw new Error('Friend request already sent');
// }
// const friendRequest = new FriendRequest({ customerId: sender.customerId, supplierId: receiver.supplierId});
// // // Create a new friend request
// // const friendRequest = new FriendRequest({
// // sender: senderId,
// // receiver: receiverId
// // });
// await friendRequest.save();
// console.log("friendRequest", friendRequest)
// reply.send({ timestamp: friendRequest.timestamp, message: 'Friend request sent' });
// } catch (err) {
// reply.status(400).send({ error: err.message });
// }
// };
// exports.friendRequest = async (request, reply) => {
// try {
// const customerId = request.body.customerId;
// const supplierId = request.body.supplierId;
// const sender = await User.findOne({ customerId: customerId });
// const receiver = await Supplier.findOne({ supplierId: supplierId });
// if (!sender || !receiver) {
// throw new Error('Sender or receiver not found');
// }
// const existingRequest = await FriendRequest.findOne({ customerId: sender.customerId, supplierId: receiver.supplierId});
// if (existingRequest) {
// throw new Error('Friend request already sent');
// }
// const timestamp = moment().format('MM/DD/YYYY, hh:mm:ss A');
// const friendRequest = new FriendRequest({
// customerId: sender.customerId,
// supplierId: receiver.supplierId,
// timestamp: timestamp
// });
// await friendRequest.save();
// // Schedule the request to be sent again in 5 hours
// const rule = new schedule.RecurrenceRule();
// rule.hour = new schedule.Range(0, 23, 5); // Run every 5 hours
// schedule.scheduleJob(rule, async function() {
// const newTimestamp = moment().format('MM/DD/YYYY, hh:mm:ss A');
// const newFriendRequest = new FriendRequest({
// customerId: sender.customerId,
// supplierId: receiver.supplierId,
// timestamp: newTimestamp
// });
// await newFriendRequest.save();
// });
// reply.send({ timestamp: friendRequest.timestamp, message: 'Friend request sent' });
// } catch (err) {
// reply.status(400).send({ error: err.message });
// }
// };
// exports.friendRequest = async (request, reply) => {
// try {
// const customerId = request.body.customerId;
// const supplierId = request.body.supplierId;
// const sender = await User.findOne({ customerId: customerId });
// const receiver = await Supplier.findOne({ supplierId: supplierId });
// if (!sender || !receiver) {
// throw new Error('Sender or receiver not found');
// }
// const existingRequest = await FriendRequest.findOne({ customerId: sender.customerId, supplierId: receiver.supplierId});
// if (existingRequest) {
// existingRequest.timestamp = moment().format("DD-MM-YYYY hh:mm:ss")
// await existingRequest.save();
// reply.send({ timestamp: existingRequest.timestamp, message: 'Friend request sent again' });
// } else {
// const timestamp = moment().format("DD-MM-YYYY hh:mm:ss")
// const friendRequest = new FriendRequest({
// customerId: sender.customerId,
// supplierId: receiver.supplierId,
// timestamp: timestamp
// });
// await friendRequest.save();
// // Schedule the request to be sent again in 5 hours
// const rule = new schedule.RecurrenceRule();
// rule.hour = new schedule.Range(0, 23, 5); // Run every 5 hours
// schedule.scheduleJob(rule, async function() {
// const newTimestamp = moment().format("DD-MM-YYYY hh:mm:ss")
// const newFriendRequest = new FriendRequest({
// customerId: sender.customerId,
// supplierId: receiver.supplierId,
// timestamp: newTimestamp
// });
// await newFriendRequest.save();
// });
// reply.send({ timestamp: friendRequest.timestamp, message: 'Friend request sent' });
// }
// } catch (err) {
// reply.status(400).send({ error: err.message });
// }
// };
exports.friendRequest = async (request, reply) => {
try {
const customerId = request.body.customerId;

@ -63,6 +63,8 @@ const tankersbookingSchema = new mongoose.Schema({
customerName : { type: String, default: null },
supplierName : { type: String, default: null },
tankerRunningStatus: { type: String, default: "0" },
longitude: { type : Number},
latitude: {type: Number},
});

@ -61,7 +61,7 @@ module.exports = function (fastify, opts, next) {
method: "POST",
url: "/api/addDeliveryboys/:supplierId",
schema: {
tags: ["Supplier-Data"],
tags: ["Delivery"],
description: "This is for adding delivery boys",
summary: "This is for adding delivery boys",
params: {
@ -135,7 +135,7 @@ module.exports = function (fastify, opts, next) {
fastify.get("/api/getdeliveryboybookings/:agent_mobile", {
schema: {
tags: ["Supplier"],
tags: ["Delivery"],
description: "This is for Get delivery bookings Data",
summary: "This is for to Get delivery bookings Data",
params: {
@ -161,7 +161,7 @@ module.exports = function (fastify, opts, next) {
fastify.get("/api/getalldeliveryboys/:supplierId", {
schema: {
tags: ["Supplier"],
tags: ["Delivery"],
description: "This is for Get all delivery boys under supplier",
summary: "This is for to Get all delivery boys under supplier",
params: {
@ -187,7 +187,7 @@ module.exports = function (fastify, opts, next) {
fastify.get("/api/getactivedeliveryboys/:supplierId", {
schema: {
tags: ["Supplier"],
tags: ["Delivery"],
description: "This is for Get all active delivery boys under supplier",
summary: "This is for to Get all active delivery boys under supplier",
params: {
@ -215,7 +215,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/deliveryboystartandstop/:bookingId",
schema: {
tags: ["Supplier"],
tags: ["Delivery"],
summary: "This is for delivery boy start and stop",
params: {
required: ["bookingId"],
@ -260,7 +260,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/amountpaidByCustomer/:bookingId",
schema: {
tags: ["Supplier"],
tags: ["Delivery"],
summary: "This is for delivery boy to update the amount paid by customer after start and stop",
params: {
required: ["bookingId"],
@ -299,7 +299,7 @@ module.exports = function (fastify, opts, next) {
fastify.get("/api/userAccounts/:customerId", {
schema: {
tags: ["Supplier"],
tags: ["User"],
description: "This is for Get accounts of user",
summary: "This is for to Get accounts of user",
params: {
@ -354,7 +354,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/tankerAccounts/:supplierId",
schema: {
tags: ["Supplier"],
tags: ["Tanker-Data"],
summary: "This is for tanker accounts",
params: {
required: ["supplierId"],

@ -204,7 +204,7 @@ module.exports = function (fastify, opts, next) {
fastify.post("/api/deliveryboylogin", {
schema: {
description: "This is for Login Delivery Boy",
tags: ["Supplier-Data"],
tags: ["Delivery"],
summary: "This is for Login Delivery Boy",
body: {
type: "object",
@ -322,7 +322,7 @@ module.exports = function (fastify, opts, next) {
method: "POST",
url: "/api/deliveryboyphone",
schema: {
tags: ["Supplier-Data"],
tags: ["Delivery"],
description: "This is for verify Delivery Boy Phone",
summary: "This is to Verify Delivery Boy Phone.",
body: {
@ -347,7 +347,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/deletedeliveryboy/:supplierId",
schema: {
tags: ["Supplier-Data"],
tags: ["Delivery"],
summary: "This is for delete delivery boy",
description: "This is for delete delivery boy",
params: {
@ -378,7 +378,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/updatedeliveryboy/:supplierId",
schema: {
tags: ["Supplier-Data"],
tags: ["Delivery"],
summary: "This is for update deliveryboy details",
params: {
required: ["supplierId"],

@ -10,7 +10,7 @@ module.exports = function (fastify, opts, next) {
method: "POST",
url: "/api/addTankers/:supplierId",
schema: {
tags: ["Supplier"],
tags: ["Tanker-Data"],
description: "This is to cretae New Tanker",
summary: "This is to Create New Tanker.",
params: {
@ -81,7 +81,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/updateTankers/:supplierId",
schema: {
tags: ["Supplier"],
tags: ["Tanker-Data"],
summary: "This is to update tanker",
params: {
required: ["supplierId"],
@ -149,7 +149,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/deleteTanker/:supplierId",
schema: {
tags: ["Supplier"],
tags: ["Tanker-Data"],
summary: "This is to delete tanker",
params: {
required: ["supplierId"],
@ -182,7 +182,7 @@ module.exports = function (fastify, opts, next) {
method: "POST",
url: "/api/bookingData/:customerId",
schema: {
tags: ["Supplier"],
tags: ["Tanker-Data"],
description: "This is for storing booking data of a Tanker",
summary: "This is for storing booking data of a Tanker",
params: {
@ -208,7 +208,8 @@ module.exports = function (fastify, opts, next) {
dateOfOrder: { type: "string"},
price: { type: "string"},
supplierId: { type: "string"},
latitude: { type: 'number' },
longitude: { type: 'number'}
},
@ -230,7 +231,7 @@ module.exports = function (fastify, opts, next) {
fastify.get("/api/getTankers", {
schema: {
tags: ["Supplier"],
tags: ["Tanker-Data"],
description: "This is for Get Tanker Data",
summary: "This is for to Get Tanker Data",
querystring: {
@ -248,7 +249,7 @@ module.exports = function (fastify, opts, next) {
fastify.get("/api/getallTankers", {
schema: {
tags: ["Supplier"],
tags: ["Tanker-Data"],
description: "This is for Get all Tanker Data",
summary: "This is for to Get all Tanker Data",
@ -266,7 +267,7 @@ module.exports = function (fastify, opts, next) {
method: "POST",
url: "/api/addBores/:customerId",
schema: {
tags: ["Supplier"],
tags: ["Tank"],
description: "This is to cretae New Bore",
summary: "This is to Create New Bore.",
params: {
@ -305,7 +306,7 @@ module.exports = function (fastify, opts, next) {
fastify.get("/api/getTankersBookingdetails/:customerId", {
schema: {
tags: ["Supplier"],
tags: ["Tanker-Data"],
description: "This is for Get Tanker Booking Data",
summary: "This is for to Get Tanker Booking Data",
params: {
@ -334,7 +335,7 @@ module.exports = function (fastify, opts, next) {
fastify.get("/api/getAllTankersBookingdetails/:supplierId", {
schema: {
tags: ["Supplier"],
tags: ["Tanker-Data"],
description: "This is for Get All Tanker Booking Data",
summary: "This is for to Get All Tanker Booking Data",
params: {
@ -362,7 +363,7 @@ module.exports = function (fastify, opts, next) {
fastify.get("/api/getBores", {
schema: {
tags: ["Supplier"],
tags: ["Tank"],
description: "This is for Get Bore Data",
summary: "This is for to Get Bore Data",
querystring: {
@ -382,7 +383,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/deleteBore/:customerId",
schema: {
tags: ["Supplier"],
tags: ["Tank"],
summary: "This is for delete bore",
params: {
required: ["customerId"],
@ -413,7 +414,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/updateBores/:customerId",
schema: {
tags: ["Supplier"],
tags: ["Tank"],
summary: "This is for update bore",
params: {
required: ["customerId"],
@ -461,7 +462,7 @@ module.exports = function (fastify, opts, next) {
method: "POST",
url: "/api/addGovtPIpeline/:customerId",
schema: {
tags: ["Supplier"],
tags: ["Tank"],
description: "This is to cretae New addGovtPIpeline",
summary: "This is to Create New addGovtPIpeline.",
params: {
@ -500,7 +501,7 @@ module.exports = function (fastify, opts, next) {
fastify.get("/api/getPipelines", {
schema: {
tags: ["Supplier"],
tags: ["Tank"],
description: "This is for Get Pipeline Data",
summary: "This is for to Get Pipeline Data",
querystring: {
@ -520,7 +521,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/deletePipeline/:customerId",
schema: {
tags: ["Supplier"],
tags: ["Tank"],
summary: "This is for delete Pipeline",
params: {
required: ["customerId"],
@ -551,7 +552,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/updatePipeline/:customerId",
schema: {
tags: ["Supplier"],
tags: ["Tank"],
summary: "This is for update Pipeline",
params: {
required: ["customerId"],
@ -597,7 +598,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/deleteTanker1/:supplierId",
schema: {
tags: ["Supplier"],
tags: ["Tanker-Data"],
summary: "This is to delete tanker",
params: {
required: ["supplierId"],
@ -627,7 +628,7 @@ module.exports = function (fastify, opts, next) {
method: 'GET',
url: '/connection-status',
schema: {
tags: ["Supplier"],
tags: ["Tanker-Data"],
description: "This is for Get Tankers Data for status connected or not",
summary: "This is for to Get Tankers Data for status connected or not",
querystring: {
@ -708,7 +709,7 @@ module.exports = function (fastify, opts, next) {
method: "PUT",
url: "/api/deleteBookingInfo/:bookingid",
schema: {
tags: ["Supplier-Order"],
tags: ["Tanker-Data"],
summary: "This is for delete Booking Info",
params: {
required: ["bookingid"],

@ -234,7 +234,7 @@ module.exports = function (fastify, opts, next) {
method: "POST",
url: "/api/forgotpasswordsupplier",
schema: {
tags: ["Supplier"],
tags: ["Supplier-Data"],
description: "This is for forgot password for the Supplier.",
summary: "This is for forgot password for the Supplier.",
body: {
@ -288,7 +288,7 @@ module.exports = function (fastify, opts, next) {
method: "POST",
url: "/api/resetpasswordsupplier",
schema: {
tags: ["Supplier"],
tags: ["Supplier-Data"],
description: "This is for Supplier Reset Password.",
summary: "This is for Supplier Reset Password.",
body: {

Loading…
Cancel
Save