Bhaskara Kishore 3 years ago
commit fb2da04f9a

2
.gitignore vendored

@ -0,0 +1,2 @@
src/api-docs/api.html
src/config/swagger.js

@ -13,6 +13,7 @@ const fastify = require("fastify")({
exports.addTankers = async (req, reply) => {
try {
@ -75,6 +76,71 @@ console.log(req.params);
}
};
exports.deleteTankerInfo1 = async (req, reply) => {
try {
//const username = req.params.username;
console.log(req.params);
const supplierId = req.params.supplierId;
//console.log(loginObject.user.username)
// const userInfo = await User.findOne({ username: username.toString() });
// const updateData = req.body;
// console.log("This is the reply in the handler after the validations", reply);
tankersData = {
supplierId:supplierId,
supplier_name:req.body.supplier_name,
supplier_address : req.body.supplier_address,
tankerName: req.body.tankerName,
phoneNumber: req.body.phoneNumber,
alternative_phoneNumber: req.body.alternative_phoneNumber,
typeofwater: req.body.typeofwater,
capacity: req.body.capacity,
price: req.body.price,
status: req.body.status
};
console.log(req.body.typeofwater,req.body.capacity)
var tanker_Name = req.body.tankerName
var i_tank = await Tanker.findOne({ tankerName: tanker_Name,supplierId:supplierId})
if(i_tank){
throw new Error('tankername already exists');
}
else {
var tankers = new Tanker(tankersData);
checkFormEncoding = isUserFormUrlEncoded(req);
if (checkFormEncoding.isUserFormUrlEncoded) {
usertobeInserted = checkFormEncoding.tankers;
console.log("thsi true url string");
tankers.supplier_name = usertobeInserted.supplier_name;
tankers.supplier_address = usertobeInserted.supplier_address;
tankers.tankerName = usertobeInserted.tankerName;
tankers.phoneNumber = usertobeInserted.phoneNumber;
tankers.alternative_phoneNumber = usertobeInserted.alternative_phoneNumber;
tankers.capacity = usertobeInserted.capacity;
tankers.typeofwater = usertobeInserted.typeofwater;
tankers.price = usertobeInserted.price;
tankers.status = usertobeInserted.status;
}
}
const insertedTanker = await tankers.save();
return insertedTanker;
} catch (err) {
throw boom.boomify(err);
}
};
//update selected tanker
exports.updateTankersInfo = async (req, reply) => {

@ -398,8 +398,9 @@ exports.sendSms = async (request, reply) => {
const apiKey = '2068323bea61494d315b';
const senderId = 'ARMNTA';
const mobile = request.body.mobileNumbers//'8341426949';
const message = `Welcome to Arminta !!! your OTP is ${code} please use it for login.`//`Welcome to Arminta !!! your OTP is ${code} please use it for login.`;
const message = `Welcome to Arminta !!! your OTP is ${code} please use it for login.`//`Welcome to Arminta !!! your OTP is ${code} please use it for login.`;
await User.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)}`;
const options = {

@ -16,15 +16,16 @@ const tankersSchema = new mongoose.Schema({
phoneNumber: { type: String, default: null },
alternative_phoneNumber: { type: String, default: null },
typeofwater: [{ typeofwater: String}],
price:[{ typeofwater: String}],
capacity: { capacity: String},
price:[{ price: String}],
capacity: { type: String},
supplier_address: { type: String, default: null },
supplier_name : { type: String, default: null },
price: {
type: [String],
default: []
},
status: { type: String, default: 'disconnected'}
status: { type: String},
});

@ -56,6 +56,8 @@ module.exports = function (fastify, opts, next) {
price: {type : "string"},
// status: {type: "string"}
},
},
security: [
@ -171,6 +173,7 @@ module.exports = function (fastify, opts, next) {
fastify.route({
method: "POST",
url: "/api/bookingData/:customerId",
@ -544,20 +547,33 @@ module.exports = function (fastify, opts, next) {
},
],
},
// preHandler: [
// fastify.auth([fastify.operatorAuthenticate]),
// validationHandler.validatePhoneFormat,
// ],
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.updatePipelineInfo,
});
fastify.get("/api/getTanks/status", {
fastify.route({
method: "PUT",
url: "/api/deleteTanker1/:supplierId",
schema: {
tags: ["Supplier"],
description: "This is for Get Tank Data for status connected",
summary: "This is for to Get Tank Data for status connected ",
summary: "This is to delete tanker",
params: {
required: ["supplierId"],
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
querystring: {
status: {type: 'string'}
tankerName: {type: 'string'}
},
security: [
{
@ -566,7 +582,7 @@ module.exports = function (fastify, opts, next) {
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.status,
handler: tankersController.deleteTankerInfo1,
});
@ -608,8 +624,6 @@ module.exports = function (fastify, opts, next) {
handler: tankersController.connectionStatus
});
next();
}

@ -0,0 +1 @@
Subproject commit 0f11d82f3692b53f67a15af4ad516bf0a1240d70
Loading…
Cancel
Save