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.

694 lines
17 KiB

const fastify = require("fastify");
const storeController = require('../controllers/storeController')
const customJwtAuth = require('../customAuthJwt');
const fastifyJwt = require('fastify-jwt');
module.exports = function (fastify, opts, next) {
fastify.route({
method: 'POST',
url: '/api/installSignup',
schema: {
tags: ['Install'],
description: 'This is for creating a New Install Account',
summary: 'This is for creating a New Install Account',
body: {
type: 'object',
properties: {
phone: { type: 'string' },
password: { type: 'string' },
emails: {
type: 'array',
maxItems: 2,
items: {
type: 'object',
properties: {
email: { type: 'string', default: null },
},
},
},
//name: { type: 'string' },
team: { type: 'string', default: null },
manager: { type: 'string', default: null },
1 year ago
address: { type: 'string', default: null },
address1: { type: 'string', default: null },
address2: { type: 'string', default: null },
city: { type: 'string', default: null },
state: { type: 'string', default: null },
zip: { type: 'string', default: null },
country: { type: 'string', default: null },
notes: { type: 'string', default: null },
latitude: { type: 'number', default: 0.0 },
longitude: { type: 'number', default: 0.0 },
fcmId: { type: 'string', default: null },
alternativeNumber : { type: 'string', default: null },
firstName :{ type: 'string', default: null },
lastName : { type: 'string', default: null },
},
},
security: [
{
basicAuth: [],
},
],
},
handler: storeController.installSignUp,
});
// fastify.post("/api/insatllLogin", {
// schema: {
// description: "This is for Login Install",
// tags: ["Install"],
// summary: "This is for Login Install",
// body: {
// type: "object",
// required: ["phone", "password"],
// properties: {
// phone: { type: "string" },
// password: { type: "string" },
// },
// },
// },
// handler: storeController.installLogin,
// });
// fastify.post("/api/installotplogin", {
// schema: {
// description: "This is for Login Otp Boy",
// tags: ["Install"],
// summary: "This is for Login Otp Boy",
// body: {
// type: "object",
// required: ["phone"],
// properties: {
// phoneVerificationCode: { type: "string" },
// phone: { type: "string" },
// },
// },
// },
// handler: storeController.installationVerifyPhone,
// });
fastify.post('/api/stores', {
schema: {
description: "This is for Create New Store",
tags: ["Store-Data"],
summary: "This is for Create New Store.",
body: {
type: "object",
required: ["storename", "phone", "emails", "password"],
properties: {
storename: { type: "string" },
phone: { type: "string" },
alternativeContactNumber: { type: "string" },
password: { type: "string" },
emails: { type: "string" },
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 },
latitude: { type: 'number', default: 0.0 },
longitude: { type: 'number', default: 0.0 },
fcmId: { type: "string", default: null },
description: { type: "string", default: null },
},
},
security: [{ basicAuth: [] }],
},
handler: storeController.addStore,
});
fastify.post("/api/createwaterlevelSensor/:storeId", {
schema: {
description: "This is for creating waterlevel Sensor",
tags: ["Store-Data"],
summary: "This is for creating waterlevel Sensor",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
body: {
type: "object",
properties: {
hardwareId: { type: "string" },
type: { type: "string" },
indate: { type: "string" },
hardwareId_company: { type: "string" }
},
},
},
handler: storeController.createwaterlevelSensor,
})
fastify.put("/api/editwaterlevelSensor/:storeId", {
schema: {
description: "This is for editing a water level sensor",
tags: ["Store-Data"],
summary: "This is for editing a water level sensor",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
body: {
type: "object",
properties: {
hardwareId: { type: "string" },
type: { type: "string" },
indate: { type: "string" },
hardwareId_company: { type: "string" }
},
},
},
handler: storeController.editWaterLevelSensor,
});
fastify.delete("/api/deletewaterlevelSensor/:storeId", {
schema: {
description: "This is for deleting a water level sensor",
tags: ["Store-Data"],
summary: "This is for deleting a water level sensor",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
body: {
type: "object",
properties: {
hardwareId: { type: "string" },
},
},
},
handler: storeController.deleteWaterLevelSensor,
});
fastify.get("/api/getHardware/:storeId", {
schema: {
tags: ["Store-Data"],
description: "This is to Get Waterlevel sensor Data",
summary: "This is to Get Waterlevel sensor Data",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: fastify.auth([fastify.authenticate]),
handler: storeController.getHardware,
});
fastify.post("/api/qccheckwaterlevelSensor/:hardwareId", {
schema: {
description: "This is for checking waterlevel Sensor",
tags: ["Store-Data"],
summary: "This is for checking waterlevel Sensor",
params: {
required: ["hardwareId"],
type: "object",
properties: {
hardwareId: {
type: "string",
description: "hardwareId",
},
},
},
body: {
type: "object",
properties: {
qccheck: { type: "string" },
qccheckdate: { type: "string" },
qcby: { type: "string" },
comment: { type: "string" },
outforrepairdate: { type: "string" },
sendto: { type: "string" },
repairfeedback: { type: "string" },
},
},
},
handler: storeController.qccheckwaterlevelSensor,
})
fastify.put("/api/getHardwareqc/:storeId", {
schema: {
tags: ["Store-Data"],
description: "This is to Get Quality Check Details Of Waterlevel Sensor",
summary: "This is to Get Quality Details Of Waterlevel Sensor",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
body: {
type: "object",
properties: {
hardwareId: { type: "string" },
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: fastify.auth([fastify.authenticate]),
handler: storeController.getHardwareqc,
});
fastify.post("/api/installwaterlevelSensor/:storeId", {
schema: {
description: "This is for installing waterlevel Sensor",
tags: ["Store-Data"],
summary: "This is for installing waterlevel Sensor",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
body: {
type: "object",
properties: {
hardwareId: { type: "string" },
dateofinstallation: { type: "string" },
customerId: { type: "string" },
installedby: { type: "string" }
},
},
},
handler: storeController.installwaterlevelSensor,
})
1 year ago
fastify.post("/api/addSlave/:hardwareId", {
schema: {
description: "This is for adding slaves to waterlevel Sensor(Slave)",
1 year ago
tags: ["Store-Data"],
summary: "This is for adding slaves to waterlevel Sensor(Slave)",
1 year ago
params: {
required: ["hardwareId"],
type: "object",
properties: {
hardwareId: {
type: "string",
description: "Main hardware ID",
},
},
},
body: {
type: "object",
properties: {
tankhardwareId: { type: "string" },
type: { type: "string" },
indate: { type: "string" },
hardwareId_company: { type: "string" }
},
},
},
handler: storeController.addSlave,
});
fastify.put("/api/editSlave/:hardwareId", {
schema: {
description: "This is for editing a slave of a water level sensor",
tags: ["Store-Data"],
summary: "This is for editing a slave of a water level sensor",
params: {
required: ["hardwareId"],
type: "object",
properties: {
hardwareId: {
type: "string",
description: "Main hardware ID",
},
},
},
body: {
type: "object",
properties: {
tankhardwareId: { type: "string" },
type: { type: "string" },
indate: { type: "string" },
hardwareId_company: { type: "string" },
qccheck: { type: "string", default: null },
qccheckdate: { type: "string", default: null },
qcby: { type: "string", default: null },
comment: { type: "string", default: "0" },
outforrepairdate: { type: "string", default: "0" },
sendto: { type: "string", default: null },
repairfeedback: { type: "string", default: "0" },
dateofinstallation: { type: "string", default: null },
installedby: { type: "string", default: "0" },
customerId: { type: "string", default: "0" },
comments: { type: "string", default: "0" },
},
},
},
handler: storeController.editSlave,
});
fastify.delete("/api/deleteSlave/:hardwareId", {
schema: {
description: "This is for deleting a slave of a water level sensor",
tags: ["Store-Data"],
summary: "This is for deleting a slave of a water level sensor",
params: {
required: ["hardwareId"],
type: "object",
properties: {
hardwareId: {
type: "string",
description: "Main hardware ID",
},
},
},
body: {
type: "object",
properties: {
tankhardwareId: { type: "string" },
},
},
},
handler: storeController.deleteSlave,
});
fastify.post("/api/qccheckwaterlevelslaveSensor/:storeId", {
schema: {
description: "This is for checking slaves (Slave)",
tags: ["Store-Data"],
summary: "This is for checking slaves (Slave)",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "Store ID",
},
},
},
body: {
type: "object",
properties: {
hardwareId: { type: "string" },
tankhardwareId: { type: "string" },
qccheck: { type: "string" },
qccheckdate: { type: "string" },
qcby: { type: "string" },
comment: { type: "string" },
outforrepairdate: { type: "string" },
sendto: { type: "string" },
repairfeedback: { type: "string" },
},
},
},
handler: storeController.qccheckwaterlevelSensorSlave,
});
fastify.put("/api/getHardwareqcslave/:storeId", {
schema: {
tags: ["Store-Data"],
description: "This is to Get Quality Check Data Of Slave (Slave)",
summary: "This is to Get Quality Check Data Of Slave (Slave)",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "Store ID",
},
},
},
body: {
type: "object",
properties: {
hardwareId: { type: "string" },
tankhardwareId: { type: "string" }, // Optional field for tank hardware
},
},
security: [
{
basicAuth: [],
},
],
},
handler: storeController.getHardwareqcslave,
});
fastify.post("/api/installwaterlevelSensorSlave/:storeId", {
schema: {
description: "This is for installing Slaves (Slave)",
tags: ["Store-Data"],
summary: "This is for installing Slaves (Slave)",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "Store ID",
},
},
},
body: {
type: "object",
properties: {
hardwareId: { type: "string" },
tankhardwareId: { type: "string" }, // Add tankhardwareId in body
dateofinstallation: { type: "string" },
customerId: { type: "string" },
installedby: { type: "string" }
},
},
},
handler: storeController.installwaterlevelSensorSlave,
});
fastify.post("/api/createmotorswitchSensor/:storeId", {
schema: {
description: "This is for creating motor switch",
tags: ["Store-Data"],
summary: "This is for creating motor switch",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
body: {
type: "object",
properties: {
motorId: { type: "string" },
type: { type: "string" },
indate: { type: "string" },
},
},
},
handler: storeController.createmotorswitchSensor,
})
fastify.get("/api/getHardwaremotorswitch/:storeId", {
schema: {
tags: ["Store-Data"],
description: "This is to Get Motor Switches",
summary: "This is to Get Motor Switches",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: fastify.auth([fastify.authenticate]),
handler: storeController.getHardwaremotorswitch,
});
fastify.post("/api/qccheckpumpswitch/:motorId", {
schema: {
description: "This is for checking Motor Switch",
tags: ["Store-Data"],
summary: "This is for checking Motor Switch",
params: {
required: ["motorId"],
type: "object",
properties: {
motorId: {
type: "string",
description: "motorId",
},
},
},
body: {
type: "object",
properties: {
qccheck: { type: "string" },
qccheckdate: { type: "string" },
qcby: { type: "string" },
comment: { type: "string" },
outforrepairdate: { type: "string" },
sendto: { type: "string" },
repairfeedback: { type: "string" },
},
},
},
handler: storeController.qccheckmotorswitch,
})
fastify.put("/api/getpumpswitchqc/:storeId", {
schema: {
tags: ["Store-Data"],
description: "This is to Get Quality Check Details Of Motor Switch",
summary: "This is to Get Quality Details Of Motor Switch",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
body: {
type: "object",
properties: {
motorId: { type: "string" },
},
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: fastify.auth([fastify.authenticate]),
handler: storeController.getpumpswitchqc,
});
fastify.post("/api/installmotorswitch/:storeId", {
schema: {
description: "This is for installing Motor Switch",
tags: ["Store-Data"],
summary: "This is for installing Motor Switch",
params: {
required: ["storeId"],
type: "object",
properties: {
storeId: {
type: "string",
description: "storeId",
},
},
},
body: {
type: "object",
properties: {
motorId: { type: "string" },
dateofinstallation: { type: "string" },
customerId: { type: "string" },
installedby: { type: "string" }
},
},
},
handler: storeController.installmotorswitch,
})
next();
};