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.

174 lines
4.4 KiB

const fastify = require("fastify");
const tankersController = require("../controllers/tankersController.js");
module.exports = function (fastify, opts, next) {
fastify.route({
method: "POST",
url: "/api/addTankers",
schema: {
tags: ["Tanker"],
description: "This is for cretae New Tanker",
summary: "This is for Create New Tanker.",
body: {
type: "object",
properties: {
tankerName: { type: "string" },
phoneNumber: { type: "string"},
typeofwater: { type: "string" },
capacity: { type: "string" },
},
},
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/:tankerName",
schema: {
tags: ["Tanker"],
summary: "This is for update tanker",
params: {
required: ["tankerName"],
type: "object",
properties: {
tankerName: {
type: "string",
description: "tankerName",
},
},
},
body: {
type: "object",
// required: ['phone'],
properties: {
tankerName: { type: "string", default: null },
phoneNumber: { type: "string", default: null },
capacity: { type: "number" },
typeofwater: { 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/:tankerName",
schema: {
tags: ["Tanker"],
summary: "This is for delete tanker",
params: {
required: ["tankerName"],
type: "object",
properties: {
tankerName: {
type: "string",
description: "tankerName",
},
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.deleteTankerInfo,
});
fastify.route({
method: "POST",
url: "/api/bookingData",
schema: {
tags: ["Tanker"],
description: "This is for storing booking data of a Tanker",
summary: "This is for storing booking data of a Tanker",
body: {
type: "object",
properties: {
typeofwater: { type: "string" },
capacity: { type: "string" },
address: { type: "string" },
dateOfOrder: { 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: ["Tanker"],
description: "This is for Get Tanker Data",
summary: "This is for to Get Tanker Data",
querystring: {
tankerName: {type: 'string'}
},
security: [
{
basicAuth: [],
},
],
},
preHandler: fastify.auth([fastify.authenticate]),
handler: tankersController.getTanker,
});
next();
}