created delete connections

master
varun 3 years ago
parent 85c3f75ede
commit ec04441bb2

@ -61,6 +61,26 @@ exports.getConnections = async (req, reply) => {
throw boom.boomify(err); throw boom.boomify(err);
} }
}; };
exports.deleteTankConnections = async (req, reply) => {
try {
const customerId = req.params.customerId;
const tankname = req.query.tankName;
const tankInfo = await Tank.findOne({ customerId: customerId.toString(),tankName:tankname })
console.log(tankInfo)
tankInfo.connections.source = tankInfo.tankName;
tankInfo.connections.inputConnections = [];
tankInfo.connections.outputConnections = [];
const tank_connections = await tankInfo.save();
return tank_connections;
} catch (err) {
throw boom.boomify(err);
}
};

@ -145,6 +145,35 @@ module.exports = function (fastify, opts, next) {
handler: createConnectionController.getConnections, handler: createConnectionController.getConnections,
}); });
fastify.route({
method: "PUT",
url: "/api/deleteTankConnections/:customerId",
schema: {
tags: ["Tank"],
summary: "This is for delete tank connections",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
querystring: {
tankName: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: createConnectionController.deleteTankConnections,
});

Loading…
Cancel
Save