Search with wine object tries to find wines matching name, year and id. This is used for finding a wine from a prelottery wine where their _id do not match.
		
			
				
	
	
		
			90 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			90 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const express = require("express");
 | |
| const path = require("path");
 | |
| 
 | |
| const mustBeAuthenticated = require(path.join(__dirname, "/middleware/mustBeAuthenticated"));
 | |
| const setAdminHeaderIfAuthenticated = require(path.join(__dirname, "/middleware/setAdminHeaderIfAuthenticated"));
 | |
| 
 | |
| 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();
 | |
| 
 | |
| 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("/requests", setAdminHeaderIfAuthenticated, requestController.allRequests);
 | |
| router.post("/request", requestController.addRequest);
 | |
| router.delete("/request/:id", mustBeAuthenticated, requestController.deleteRequest);
 | |
| 
 | |
| router.get("/wines", wineController.allWines); // sort = by-date, by-name, by-occurences
 | |
| router.get("/wine/:id", wineController.wineById); // sort = by-date, by-name, by-occurences
 | |
| // router.update("/wine/:id", mustBeAuthenticated, wineController.update);
 | |
| 
 | |
| router.get("/history", historyController.all);
 | |
| router.get("/history/latest", historyController.latest);
 | |
| router.get("/history/by-wins/", historyController.orderByWins);
 | |
| router.get("/history/by-color/", historyController.groupByColor);
 | |
| 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("/lottery/wines", prelotteryWineController.allWines);
 | |
| router.get("/lottery/wine/schema", mustBeAuthenticated, prelotteryWineController.wineSchema);
 | |
| router.get("/lottery/wine/:id", mustBeAuthenticated, prelotteryWineController.wineById);
 | |
| router.post("/lottery/wines", mustBeAuthenticated, prelotteryWineController.addWines);
 | |
| router.delete("/lottery/wines", mustBeAuthenticated, prelotteryWineController.deleteWines);
 | |
| router.put("/lottery/wine/:id", mustBeAuthenticated, prelotteryWineController.updateWineById);
 | |
| router.delete("/lottery/wine/:id", mustBeAuthenticated, prelotteryWineController.deleteWineById);
 | |
| 
 | |
| router.get("/lottery/attendees", attendeeController.allAttendees);
 | |
| router.delete("/lottery/attendees", mustBeAuthenticated, attendeeController.deleteAttendees);
 | |
| router.post("/lottery/attendee", mustBeAuthenticated, attendeeController.addAttendee);
 | |
| router.put("/lottery/attendee/:id", mustBeAuthenticated, attendeeController.updateAttendeeById);
 | |
| router.delete("/lottery/attendee/:id", mustBeAuthenticated, attendeeController.deleteAttendeeById);
 | |
| 
 | |
| router.get("/lottery/winners", winnerController.allWinners);
 | |
| router.get("/lottery/winner/:id", winnerController.winnerById);
 | |
| router.post("/lottery/winners", mustBeAuthenticated, winnerController.addWinners);
 | |
| router.delete("/lottery/winners", mustBeAuthenticated, winnerController.deleteWinners);
 | |
| router.delete("/lottery/winner/:id", mustBeAuthenticated, winnerController.deleteWinnerById);
 | |
| 
 | |
| router.get("/lottery/draw", mustBeAuthenticated, lotteryController.drawWinner);
 | |
| router.post("/lottery/archive", mustBeAuthenticated, lotteryController.archiveLottery);
 | |
| router.get("/lottery/:epoch", lotteryController.lotteryByDate);
 | |
| router.get("/lottery/", lotteryController.allLotteries);
 | |
| 
 | |
| // router.get("/lottery/prize-distribution/status", mustBeAuthenticated, prizeDistributionController.status);
 | |
| 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.get("/chat/history", chatController.getAllHistory);
 | |
| router.delete("/chat/history", mustBeAuthenticated, chatController.deleteHistory);
 | |
| 
 | |
| 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;
 |