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.

100 lines
2.7 KiB

const fastify = require("fastify");
const supplierController = require("../controllers/supplierController");
const validationHandler = require("../handlers/supplierHandler");
module.exports = function (fastify, opts, next) {
fastify.post("/api/supplierlogin", {
schema: {
description: "This is for Login Supplier",
tags: ["Supplier-Data"],
summary: "This is for Login Supplier",
body: {
type: "object",
required: ["phone", "password"],
properties: {
phone: { type: "string" },
password: { type: "string" },
},
},
},
handler: validationHandler.loginSupplier,
});
fastify.route({
method: "POST",
url: "/api/supplierlogout",
schema: {
description: "This is for Supplier logout",
tags: ["Supplier-Data"],
summary: "This is for Supplier logout",
params: {
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
},
// preHandler: fastify.auth([fastify.authenticate]),
handler: validationHandler.logoutsupplier,
// onResponse: (request,reply) => {validationHandler.resetPassword(request,reply)}
});
fastify.route({
method: "POST",
url: "/api/suppliers",
schema: {
tags: ["Supplier-Data"],
description: "This is for cretae New supplier",
summary: "This is for Create New supplier.",
body: {
type: "object",
properties: {
suppliername: { type: "string" },
phone: { type: "string" },
alternativeContactNumber : { type : "string" },
password: { type: "string" },
emails: {
type: "array",
maxItems: 2,
items: {
type: "object",
properties: {
email: { type: "string", default: null },
},
},
},
office_address: { type: "string", default: null },
city: { type: "string", default: null },
state: { type: "string", default: null },
zip: { type: "string", default: null },
country: { type: "string", default: null },
},
},
security: [
{
basicAuth: [],
},
],
},
preHandler: [
validationHandler.fieldCheck,
validationHandler.verifySupplier,
// validationHandler.validatePhoneFormat,
validationHandler.validateEmailFormat,
],
handler: supplierController.addSupplier,
});
next();
}