-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.js
84 lines (79 loc) · 4.88 KB
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//========================================================================================
/* *
* Import dependencies and configure express router *
* */
//========================================================================================
const express = require("express"),
router = express.Router(),
{ celebrate,Segments } = require("celebrate");
const multer = require('multer')
const {extname} = require('path')
//########################################################################################
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './uploads')
},
filename: function (req, file, cb) {
cb(null, `${Date.now()}${extname(file.originalname)}`)
}
})
const upload = multer({storage})
//========================================================================================
/* *
* Import all the Controllers *
* */
//========================================================================================
const {genrateOtp,verifyOtp} = require(`./Controllers/registration.controller`);
const loginController = require(`./Controllers/login.controller`);
const {registerCrime,getCrimeDetails} = require(`./Controllers/userCrimeRegistration.controller`);
const chatBotRoute = require(`./Controllers/chatbotresponse.controller.js`);
const {getMyCrimes,getUserCrimes,getAllCrimes
,startInvestigation,deleteCrimeData,
finishInvestigation,updateDetails,
transferCase,
registerPolice, getPoliceMen} = require(`./Controllers/policemanActions.controller.js`);
const {webhookController} = require('./Controllers/webhooks.controller');
const {emergencyRegister, deleteEmergency, getEmergency} = require('./Controllers/emergency.controller');
const uploadFile = require('./Controllers/upload.controller')
const {reportSpam} = require('./Controllers/spam.controller');
//########################################################################################
//========================================================================================
/* *
* Import all the models *
* */
//========================================================================================
const registrationModel = require(`./Models/regestration.model`);
const {body} = require(`./Models/login.model`);
const CrimeRegistrationModel = require(`./Models/userCrimeRegistration.model`);
const updateDetailsModel = require('./Models/updateDetails.model');
const verifyOtpModel = require('./Models/verifyOtp.model');
//########################################################################################
//========================================================================================
/* *
* Configure all the routes here *
* */
//========================================================================================
router.post("/register", celebrate(registrationModel), genrateOtp);
router.post("/verify",celebrate(verifyOtpModel), verifyOtp);
router.post("/login", celebrate({[Segments.BODY]:body}), loginController);
router.post('/crime-register',celebrate(CrimeRegistrationModel),registerCrime)
router.get('/crime-register/:id',getCrimeDetails);
router.patch("/crime-register",transferCase)
router.get('/get-crime-register',getAllCrimes);
router.get('/get-my-crimes',getMyCrimes);
router.get('/get-user-crimes',getUserCrimes);
router.get('/getpolicemen',getPoliceMen);
router.post('/bot-reply',chatBotRoute);
router.patch('/investigation',startInvestigation);
router.patch('/finishinvestigation',finishInvestigation);
router.delete('/investigation/:caseNo',deleteCrimeData);
router.post('/webhooks',webhookController);
router.post('/update-details',celebrate(updateDetailsModel),updateDetails);
router.post('/emergency',emergencyRegister);
router.delete('/deleteemergency/:emergencyNo',deleteEmergency);
router.get('/getemergency', getEmergency);
router.post('/image-upload',upload.single('image'),uploadFile);
router.post('/spam',reportSpam);
router.post('/register-police',registerPolice);
//########################################################################################
module.exports = router;