MADE UPDATE AND GET TANK LEVELS

master
varun 3 years ago
parent ff374bd7ea
commit 834cb59c60

@ -5,6 +5,11 @@ const fastify = require("fastify")({
logger: true, logger: true,
}); });
exports.addTanks = async (req, reply) => { exports.addTanks = async (req, reply) => {
try { try {
@ -134,7 +139,7 @@ exports.getTank = async (req, reply) => {
// } // }
//}; //};
exports.getTanklevels = async (req, reply) => { exports.updateTanklevels = async (req, reply) => {
try { try {
const customerId = req.params.customerId; const customerId = req.params.customerId;
const tank = await Tank.find({customerId}); const tank = await Tank.find({customerId});
@ -167,4 +172,24 @@ exports.getTanklevels = async (req, reply) => {
throw boom.boomify(err); throw boom.boomify(err);
} }
}; };
exports.getTanklevels = async (req, reply) => {
try {
const customerId = req.params.customerId;
const updated_data = await Tank.find({ customerId: customerId });
reply.send({ status_code: 200, data: updated_data});
return { message: 'success' };
}
catch (err) {
throw boom.boomify(err);
}
};

@ -142,6 +142,36 @@ module.exports = function (fastify, opts, next) {
handler: tanksController.getTank, handler: tanksController.getTank,
}); });
fastify.route({
method: "GET",
url: "/api/updateTanklevels/:customerId",
schema: {
tags: ["Tank"],
summary: "This is for updating tank levels",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
// querystring: {
// tankName: {type: 'string'}
// },
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tanksController.updateTanklevels,
});
fastify.route({ fastify.route({
method: "GET", method: "GET",
url: "/api/getTanklevels/:customerId", url: "/api/getTanklevels/:customerId",
@ -171,7 +201,6 @@ module.exports = function (fastify, opts, next) {
handler: tanksController.getTanklevels, handler: tanksController.getTanklevels,
}); });
next(); next();

Loading…
Cancel
Save