forked from wholespace214/crash-game-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MVP2-6 - Allow non-logged in user to fetch events and latest chat mes…
…sages
- Loading branch information
1 parent
16f570f
commit a28b272
Showing
4 changed files
with
143 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Import the express Router to create routes | ||
const router = require("express").Router(); | ||
|
||
// Imports from express validator to validate user input | ||
const { check } = require("express-validator"); | ||
|
||
// Import controllers | ||
const eventController = require("../../controllers/events-controller"); | ||
const betController = require("../../controllers/bets-controller"); | ||
|
||
//Login does register & login | ||
router.get( | ||
"/list/:type/:category/:count/:page/:sortby", | ||
eventController.filterEvents | ||
); | ||
|
||
router.get( | ||
"/list/:type/:category/:count/:page/:sortby/:searchQuery", | ||
eventController.filterEvents | ||
); | ||
|
||
router.get( | ||
"/get/:id", | ||
[ | ||
check("id").notEmpty() | ||
], | ||
eventController.getEvent | ||
); | ||
|
||
router.post( | ||
"/create", | ||
[ | ||
check("name"), | ||
check("tags"), | ||
check("streamUrl"), | ||
check("previewImageUrl"), | ||
check("date"), | ||
], | ||
eventController.createEvent | ||
); | ||
|
||
router.post( | ||
"/bet/create", | ||
[ | ||
check("eventId").notEmpty(), | ||
check("marketQuestion").notEmpty(), | ||
check("description"), | ||
check("hot"), | ||
check("outcomes").isArray(), | ||
check("endDate") | ||
], | ||
betController.createBet | ||
); | ||
|
||
router.post( | ||
"/bet/:id/place", | ||
[ | ||
check("amount").isNumeric(), | ||
check("outcome").isNumeric(), | ||
check("minOutcomeTokens").isNumeric().default(0).optional() | ||
], | ||
betController.placeBet | ||
); | ||
|
||
router.post( | ||
"/bet/:id/pullout", | ||
[ | ||
check("amount").isNumeric(), | ||
check("outcome").isNumeric(), | ||
check("minReturnAmount").isNumeric().default(Number.MAX_SAFE_INTEGER).optional() | ||
], | ||
betController.pullOutBet | ||
); | ||
|
||
router.post( | ||
"/bet/:id/outcomes/buy", | ||
[ | ||
check("amount").isNumeric() | ||
], | ||
betController.calculateBuyOutcome | ||
); | ||
|
||
router.post( | ||
"/bet/:id/outcomes/sell", | ||
[ | ||
check("amount").isNumeric() | ||
], | ||
betController.calculateSellOutcome | ||
); | ||
|
||
router.get( | ||
"/bet/:id/payout", | ||
betController.payoutBet | ||
); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters