|
|
|
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 },
|
|
|
|
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.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,
|
|
|
|
})
|
|
|
|
|
|
|
|
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.get("/api/getHardware/:storeId", {
|
|
|
|
schema: {
|
|
|
|
tags: ["Store-Data"],
|
|
|
|
description: "This is to Get Hardware Data",
|
|
|
|
summary: "This is to Get Hardware Tank Data",
|
|
|
|
params: {
|
|
|
|
required: ["storeId"],
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
storeId: {
|
|
|
|
type: "string",
|
|
|
|
description: "storeId",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
security: [
|
|
|
|
{
|
|
|
|
basicAuth: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
// preHandler: fastify.auth([fastify.authenticate]),
|
|
|
|
handler: storeController.getHardware,
|
|
|
|
});
|
|
|
|
|
|
|
|
fastify.put("/api/getHardwareqc/:storeId", {
|
|
|
|
schema: {
|
|
|
|
tags: ["Store-Data"],
|
|
|
|
description: "This is to Get Quality Check Hardware Data",
|
|
|
|
summary: "This is to Get Quality Check Hardware Data",
|
|
|
|
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/addSlave/:hardwareId", {
|
|
|
|
schema: {
|
|
|
|
description: "This is for adding a slave to the water level sensor",
|
|
|
|
tags: ["Store-Data"],
|
|
|
|
summary: "Add a slave to the 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" }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handler: storeController.addSlave,
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
next();
|
|
|
|
};
|