BIGBOY rewrite.
All endpoints have been re-worked to be more clear on what they do. They also all have their own controller now.
This commit is contained in:
		
							
								
								
									
										117
									
								
								api/router.js
									
									
									
									
									
								
							
							
						
						
									
										117
									
								
								api/router.js
									
									
									
									
									
								
							| @@ -4,69 +4,84 @@ const path = require("path"); | |||||||
| const mustBeAuthenticated = require(path.join(__dirname, "/middleware/mustBeAuthenticated")); | const mustBeAuthenticated = require(path.join(__dirname, "/middleware/mustBeAuthenticated")); | ||||||
| const setAdminHeaderIfAuthenticated = require(path.join(__dirname, "/middleware/setAdminHeaderIfAuthenticated")); | const setAdminHeaderIfAuthenticated = require(path.join(__dirname, "/middleware/setAdminHeaderIfAuthenticated")); | ||||||
|  |  | ||||||
| const update = require(path.join(__dirname, "/update")); |  | ||||||
| const retrieve = require(path.join(__dirname, "/retrieve")); |  | ||||||
| const request = require(path.join(__dirname, "/request")); |  | ||||||
| const subscriptionApi = require(path.join(__dirname, "/subscriptions")); |  | ||||||
| const userApi = require(path.join(__dirname, "/user")); |  | ||||||
| const wineinfo = require(path.join(__dirname, "/wineinfo")); |  | ||||||
| const virtualApi = require(path.join(__dirname, "/virtualLottery")); |  | ||||||
| const virtualRegistrationApi = require(path.join( |  | ||||||
|   __dirname, "/virtualRegistration" |  | ||||||
| )); |  | ||||||
| const lottery = require(path.join(__dirname, "/lottery")); |  | ||||||
| const chatHistoryApi = require(path.join(__dirname, "/chatHistory")); |  | ||||||
|  |  | ||||||
| const requestController = require(path.join(__dirname, "/controllers/requestController")); | const requestController = require(path.join(__dirname, "/controllers/requestController")); | ||||||
|  | const vinmonopoletController = require(path.join(__dirname, "/controllers/vinmonopoletController")); | ||||||
|  | const chatController = require(path.join(__dirname, "/controllers/chatController")); | ||||||
|  | const userController = require(path.join(__dirname, "/controllers/userController")); | ||||||
|  | const historyController = require(path.join(__dirname, "/controllers/historyController")); | ||||||
|  | const attendeeController = require(path.join(__dirname, "/controllers/lotteryAttendeeController")); | ||||||
|  | const prelotteryWineController = require(path.join(__dirname, "/controllers/lotteryWineController")); | ||||||
|  | const winnerController = require(path.join(__dirname, "/controllers/lotteryWinnerController")); | ||||||
|  | const lotteryController = require(path.join(__dirname, "/controllers/lotteryController")); | ||||||
|  | const prizeDistributionController = require(path.join(__dirname, "/controllers/prizeDistributionController")); | ||||||
|  |  | ||||||
| const router = express.Router(); | const router = express.Router(); | ||||||
|  |  | ||||||
| router.get("/wineinfo/search", wineinfo.wineSearch); | router.get("/vinmonopolet/wine/search", vinmonopoletController.searchWines); | ||||||
|  | router.get("/vinmonopolet/wine/by-ean/:ean", vinmonopoletController.wineByEAN); | ||||||
|  | router.get("/vinmonopolet/wine/by-id/:id", vinmonopoletController.wineById); | ||||||
|  | router.get("/vinmonopolet/stores/", vinmonopoletController.allStores); | ||||||
|  | router.get("/vinmonopolet/stores/search", vinmonopoletController.searchStores); | ||||||
|  |  | ||||||
| router.get("/request/all", setAdminHeaderIfAuthenticated, requestController.getAllRequests); | router.get("/requests", setAdminHeaderIfAuthenticated, requestController.allRequests); | ||||||
| router.post("/request/new-wine", requestController.addRequest); | router.post("/request", requestController.addRequest); | ||||||
| router.delete("/request/:id", requestController.deleteRequest); | router.delete("/request/:id", mustBeAuthenticated, requestController.deleteRequest); | ||||||
|  |  | ||||||
| router.get("/wineinfo/schema", mustBeAuthenticated, update.schema); | // router.get("/wines", wineController.all); // sort = by-date, by-name, by-occurences | ||||||
| router.get("/wineinfo/:ean", wineinfo.byEAN); | // router.update("/wine/:id", mustBeAuthenticated, wineController.update); | ||||||
|  |  | ||||||
| router.post("/log/wines", mustBeAuthenticated, update.submitWines); | router.get("/history", historyController.all); | ||||||
| router.post("/lottery", update.submitLottery); | router.get("/history/latest", historyController.latest); | ||||||
| router.post("/lottery/wines", update.submitWinesToLottery); | router.get("/history/by-wins/", historyController.orderByWins); | ||||||
| // router.delete("/lottery/wine/:id", update.deleteWineFromLottery); | router.get("/history/by-color/", historyController.groupByColor); | ||||||
| router.post("/lottery/winners", update.submitWinnersToLottery); | router.get("/history/by-date/:date", historyController.byDate); | ||||||
|  | router.get("/history/by-name/:name", historyController.byName); | ||||||
|  | router.get("/history/by-date/", historyController.groupByDate); | ||||||
|  | // router.delete("/highscore/:id", highscoreController.deletePersonById); | ||||||
|  |  | ||||||
| router.get("/wines/prelottery", retrieve.prelotteryWines); | router.get("/lottery/wines", prelotteryWineController.allWines); | ||||||
| router.get("/purchase/statistics", retrieve.allPurchase); | router.get("/lottery/wine/:id", mustBeAuthenticated, prelotteryWineController.wineById); | ||||||
| router.get("/purchase/statistics/color", retrieve.purchaseByColor); | router.post("/lottery/wines", mustBeAuthenticated, prelotteryWineController.addWines); | ||||||
| router.get("/highscore/statistics", retrieve.highscore) | router.delete("/lottery/wines", mustBeAuthenticated, prelotteryWineController.deleteWines); | ||||||
| router.get("/wines/statistics", retrieve.allWines); | router.put("/lottery/wine/:id", mustBeAuthenticated, prelotteryWineController.updateWineById); | ||||||
| router.get("/wines/statistics/overall", retrieve.allWinesSummary); | router.delete("/lottery/wine/:id", mustBeAuthenticated, prelotteryWineController.deleteWineById); | ||||||
|  |  | ||||||
| router.get("/lottery/all", lottery.all); | router.get("/lottery/attendees", attendeeController.allAttendees); | ||||||
| router.get("/lottery/latest", lottery.latest); | router.delete("/lottery/attendees", mustBeAuthenticated, attendeeController.deleteAttendees); | ||||||
| router.get("/lottery/by-date/:date", lottery.byEpochDate); | router.post("/lottery/attendee", mustBeAuthenticated, attendeeController.addAttendee); | ||||||
| router.get("/lottery/by-name/:name", lottery.byName); | router.put("/lottery/attendee/:id", mustBeAuthenticated, attendeeController.updateAttendeeById); | ||||||
|  | router.delete("/lottery/attendee/:id", mustBeAuthenticated, attendeeController.deleteAttendeeById); | ||||||
|  |  | ||||||
| router.delete('/virtual/winner/all', mustBeAuthenticated, virtualApi.deleteWinners); | router.get("/lottery/winners", winnerController.allWinners); | ||||||
| router.delete('/virtual/attendee/all', mustBeAuthenticated, virtualApi.deleteAttendees); | router.get("/lottery/winner/:id", winnerController.winnerById); | ||||||
| router.get('/virtual/winner/draw', virtualApi.drawWinner); | router.post("/lottery/winners", mustBeAuthenticated, winnerController.addWinners); | ||||||
| router.get('/virtual/winner/all', virtualApi.winners); | router.delete("/lottery/winners", mustBeAuthenticated, winnerController.deleteWinners); | ||||||
| router.get('/virtual/winner/all/secure', mustBeAuthenticated, virtualApi.winnersSecure); | router.delete("/lottery/winner/:id", mustBeAuthenticated, winnerController.deleteWinnerById); | ||||||
| router.post('/virtual/finish', mustBeAuthenticated, virtualApi.finish); |  | ||||||
| router.get('/virtual/attendee/all', virtualApi.attendees); |  | ||||||
| router.get('/virtual/attendee/all/secure', mustBeAuthenticated, virtualApi.attendeesSecure); |  | ||||||
| router.post('/virtual/attendee/add', mustBeAuthenticated, virtualApi.addAttendee); |  | ||||||
|  |  | ||||||
| router.post('/winner/notify/:id', virtualRegistrationApi.sendNotificationToWinnerById); | router.get("/lottery/draw", mustBeAuthenticated, lotteryController.drawWinner); | ||||||
| router.get('/winner/:id', virtualRegistrationApi.getWinesToWinnerById); | router.post("/lottery/archive", mustBeAuthenticated, lotteryController.archiveLottery); | ||||||
| router.post('/winner/:id', virtualRegistrationApi.registerWinnerSelection); | router.get("/lottery/:epoch", lotteryController.lotteryByDate); | ||||||
|  | router.get("/lottery/", lotteryController.allLotteries); | ||||||
|  |  | ||||||
| router.get('/chat/history', chatHistoryApi.getAllHistory) | // router.get("/lottery/prize-distribution/status", mustBeAuthenticated, prizeDistributionController.status); | ||||||
| router.delete('/chat/history', mustBeAuthenticated, chatHistoryApi.deleteHistory) | router.post("/lottery/prize-distribution/start", mustBeAuthenticated, prizeDistributionController.start); | ||||||
|  | // router.post("/lottery/prize-distribution/stop", mustBeAuthenticated, prizeDistributionController.stop); | ||||||
|  | router.get("/lottery/prize-distribution/prizes/:id", prizeDistributionController.getPrizesForWinnerById); | ||||||
|  | router.post("/lottery/prize-distribution/prize/:id", prizeDistributionController.submitPrizeForWinnerById); | ||||||
|  |  | ||||||
| router.post('/login', userApi.login); | router.get("/chat/history", chatController.getAllHistory); | ||||||
| router.post('/register', mustBeAuthenticated, userApi.register); | router.delete("/chat/history", mustBeAuthenticated, chatController.deleteHistory); | ||||||
| router.get('/logout', userApi.logout); |  | ||||||
|  | router.post("/login", userController.login); | ||||||
|  | router.post("/register", userController.register); | ||||||
|  | router.get("/logout", userController.logout); | ||||||
|  |  | ||||||
|  | // router.get("/", documentation.apiInfo); | ||||||
|  |  | ||||||
|  | // router.get("/wine/schema", mustBeAuthenticated, update.schema); | ||||||
|  | // router.get("/purchase/statistics", retrieve.allPurchase); | ||||||
|  | // router.get("/highscore/statistics", retrieve.highscore); | ||||||
|  | // router.get("/wines/statistics", retrieve.allWines); | ||||||
|  | // router.get("/wines/statistics/overall", retrieve.allWinesSummary); | ||||||
|  |  | ||||||
| module.exports = router; | module.exports = router; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user