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.

544 lines
14 KiB

const fastify = require("fastify");
const tankersController = require("../controllers/tankersController.js");
module.exports = function (fastify, opts, next) {
fastify.route({
method: "POST",
url: "/api/addTankers/:customerId",
schema: {
tags: ["Supplier"],
description: "This is to cretae New Tanker",
summary: "This is to Create New Tanker.",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
body: {
type: "object",
properties: {
tankerName: { type: "string" },
phoneNumber: { type: "string"},
alternative_phoneNumber: { type: "string"},
typeofwater: {
type: "array",
maxItems: 2500,
items: {
type: "object",
properties: {
typeofwater: { type: "string", default: null },
},
},
},
capacity: {
type: "array",
maxItems: 2500,
items: {
type: "object",
properties: {
capacity: { type: "string", default: null },
},
},
},
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.addTankers,
// onResponse: (request, reply) => {
// validationHandler.sendPhoneVerificationCode(request, reply);
// },
//onResponse: validationHandler.sendPhoneVerificationCode,
});
//update tankers
fastify.route({
method: "PUT",
url: "/api/updateTankers/:customerId",
schema: {
tags: ["Supplier"],
summary: "This is to update tanker",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
querystring: {
tankerName: {type: 'string'}
},
body: {
type: "object",
// required: ['phone'],
properties: {
tankerName: { type: "string", default: null },
phoneNumber: { type: "string", default: null },
typeofwater: {
type: "array",
maxItems: 2500,
items: {
type: "object",
properties: {
typeofwater: { type: "string", default: null },
},
},
},
capacity: {
type: "array",
maxItems: 2500,
items: {
type: "object",
properties: {
capacity: { type: "string", default: null },
},
},
},
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: [
// fastify.auth([fastify.operatorAuthenticate]),
// validationHandler.validatePhoneFormat,
// ],
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.updateTankersInfo,
});
fastify.route({
method: "PUT",
url: "/api/deleteTanker/:customerId",
schema: {
tags: ["Supplier"],
summary: "This is to delete tanker",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
querystring: {
tankerName: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.deleteTankerInfo,
});
fastify.route({
method: "POST",
url: "/api/bookingData/:customerId",
schema: {
tags: ["Supplier"],
description: "This is for storing booking data of a Tanker",
summary: "This is for storing booking data of a Tanker",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
body: {
type: "object",
properties: {
tankerName: {type: 'string'},
typeofwater: { type: "string" },
capacity: { type: "string" },
address: { type: "string" },
dateOfOrder: { type: "string"},
date: { type: "string"},
time: { type: "string"},
3 years ago
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.tankerBooking,
// onResponse: (request, reply) => {
// validationHandler.sendPhoneVerificationCode(request, reply);
// },
//onResponse: validationHandler.sendPhoneVerificationCode,
});
fastify.get("/api/getTankers", {
schema: {
tags: ["Supplier"],
description: "This is for Get Tanker Data",
summary: "This is for to Get Tanker Data",
querystring: {
customerId: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.getTanker,
});
fastify.route({
method: "POST",
url: "/api/addBores/:customerId",
schema: {
tags: ["Supplier"],
description: "This is to cretae New Bore",
summary: "This is to Create New Bore.",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
body: {
type: "object",
properties: {
boreName: { type: "string" },
capacity: { type: "string" },
typeofwater: { type: "string" },
description: { type: "string" },
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.addBores,
// onResponse: (request, reply) => {
// validationHandler.sendPhoneVerificationCode(request, reply);
// },
//onResponse: validationHandler.sendPhoneVerificationCode,
});
fastify.get("/api/getTankersBookingdetails/:customerId", {
schema: {
tags: ["Supplier"],
description: "This is for Get Tanker Booking Data",
summary: "This is for to Get Tanker Booking Data",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
querystring: {
tankerName: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.getTankersBookingdetails,
});
fastify.get("/api/getBores", {
schema: {
tags: ["Supplier"],
description: "This is for Get Bore Data",
summary: "This is for to Get Bore Data",
querystring: {
customerId: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.getBores,
});
fastify.route({
method: "PUT",
url: "/api/deleteBore/:customerId",
schema: {
tags: ["Supplier"],
summary: "This is for delete bore",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
querystring: {
boreName: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
3 years ago
//preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.deleteBoresInfo,
});
fastify.route({
method: "PUT",
url: "/api/updateBores/:customerId",
schema: {
tags: ["Supplier"],
summary: "This is for update bore",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
querystring: {
boreName: {type: 'string'}
},
body: {
type: "object",
// required: ['phone'],
properties: {
boreName: { type: "string" },
capacity: { type: "string" },
typeofwater: { type: "string" },
description: { type: "string" },
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: [
// fastify.auth([fastify.operatorAuthenticate]),
// validationHandler.validatePhoneFormat,
// ],
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.updateBoresInfo,
});
fastify.route({
method: "POST",
url: "/api/addGovtPIpeline/:customerId",
schema: {
tags: ["Supplier"],
description: "This is to cretae New addGovtPIpeline",
summary: "This is to Create New addGovtPIpeline.",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
body: {
type: "object",
properties: {
Name: { type: "string" },
capacity: { type: "string" },
typeofwater: { type: "string" },
description: { type: "string" },
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.addGovtPIpeline,
// onResponse: (request, reply) => {
// validationHandler.sendPhoneVerificationCode(request, reply);
// },
//onResponse: validationHandler.sendPhoneVerificationCode,
});
fastify.get("/api/getPipelines", {
schema: {
tags: ["Supplier"],
description: "This is for Get Pipeline Data",
summary: "This is for to Get Pipeline Data",
querystring: {
customerId: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.getPipeline,
});
fastify.route({
method: "PUT",
url: "/api/deletePipeline/:customerId",
schema: {
tags: ["Supplier"],
summary: "This is for delete Pipeline",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
querystring: {
Name: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
//preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.deletePipelineInfo,
});
fastify.route({
method: "PUT",
url: "/api/updatePipeline/:customerId",
schema: {
tags: ["Supplier"],
summary: "This is for update Pipeline",
params: {
required: ["customerId"],
type: "object",
properties: {
customerId: {
type: "string",
description: "customerId",
},
},
},
querystring: {
Name: {type: 'string'}
},
body: {
type: "object",
// required: ['phone'],
properties: {
Name: { type: "string" },
capacity: { type: "string" },
typeofwater: { type: "string" },
description: { type: "string" },
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: [
// fastify.auth([fastify.operatorAuthenticate]),
// validationHandler.validatePhoneFormat,
// ],
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.updatePipelineInfo,
});
next();
}