You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
4.7 KiB

const fastify = require("fastify");
const tanksController = require("../controllers/tanksController");
module.exports = function (fastify, opts, next) {
fastify.route({
method: "POST",
url: "/api/addTanks/:customerId",
schema: {
tags: ["Tank"],
description: "This is for cretae New Tank",
summary: "This is for Create New Tank.",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
body: {
type: "object",
properties: {
tankName: { type: "string" },
blockName: { type: "string"},
capacity: { type: "string" },
typeOfWater: { type: "string" },
tankLocation: { type: "string" },
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tanksController.addTanks,
// onResponse: (request, reply) => {
// validationHandler.sendPhoneVerificationCode(request, reply);
// },
//onResponse: validationHandler.sendPhoneVerificationCode,
});
fastify.route({
method: "PUT",
3 years ago
url: "/api/updateTanks/:customerId",
schema: {
tags: ["Tank"],
summary: "This is for update tank",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
querystring: {
tankName: {type: 'string'}
},
body: {
type: "object",
// required: ['phone'],
properties: {
tankName: { type: "string", default: null },
blockName: { type: "string", default: null },
capacity: { type: "string" },
typeOfWater: { type: "string", default: null },
type: { type: "string" },
tankLocation: { type: "string", default: null },
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: [
// fastify.auth([fastify.operatorAuthenticate]),
// validationHandler.validatePhoneFormat,
// ],
preHandler: fastify.auth([fastify.authenticate]),
handler: tanksController.updateTanksInfo,
});
fastify.route({
method: "PUT",
3 years ago
url: "/api/deleteTank/:customerId",
schema: {
tags: ["Tank"],
summary: "This is for delete tank",
params: {
3 years ago
required: ["customerId"],
type: "object",
properties: {
3 years ago
customerId: {
type: "string",
3 years ago
description: "customerId",
},
},
},
3 years ago
querystring: {
tankName: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tanksController.deleteTanksInfo,
});
fastify.get("/api/getTanks", {
schema: {
tags: ["Tank"],
description: "This is for Get Tank Data",
summary: "This is for to Get Tank Data",
querystring: {
3 years ago
customerId: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tanksController.getTank,
});
fastify.route({
method: "GET",
url: "/api/getTanklevels/:customerId",
schema: {
tags: ["Tank"],
summary: "This is for getting 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.getTanklevels,
});
next();
}