200 Commits

Author SHA1 Message Date
168aad21e9 Removed hash route prefix from backend.
Also linting.
2021-05-21 17:06:09 +02:00
127fc6741f Merge pull request #86 from KevinMidboe/feat/vinmonopolet-elastic-cache
Feat/vinmonopolet elastic cache
2021-04-30 09:56:58 +02:00
753e4eb422 Merge branch 'master' into feat/register 2021-04-29 17:37:17 +02:00
d71a3a4c5a Added local elastic vinmonopolet cache for query get by id.
First tries to search local elastic instance, if no results are found a
reject is thrown and we search vinmonopolet api manually.
2021-04-29 17:23:35 +02:00
a700de6e2e GetById should only return single wine object. 2021-04-29 17:22:47 +02:00
c0d98af6e1 Controller gracefully handles errors. 2021-04-29 17:21:55 +02:00
7b406ef432 Merge pull request #79 from KevinMidboe/fix/archive-but-save-if-chosen
fix: Archive but save set winners as winners
2021-03-26 09:18:53 +01:00
Kasper Rynning-Tønnesen
56072ff282 feat: Allow register locally without authentication 2021-03-25 20:48:00 +01:00
Kasper Rynning-Tønnesen
0e3c4d98e6 feat: Add tiny seed for 2 wines, and 2 users 2021-03-25 20:45:08 +01:00
Kasper Rynning-Tønnesen
59b4366ed5 fix: Archive but save set winners as winners
If archiving a lottery, let archive-functionality circumvent SMS-service if the winners have been set on the archive page.
- Also remove unused file
2021-03-25 20:15:38 +01:00
b0424a519c Fixed drawing winner count was +1.
On /lottery frontend page the count of winners that is sent to frontend
over socketIO started one index higher than it should.

This was from updating how winners are saved in the backend. Our winners
array now no longer needs to be incremented with 1 from the backend.
2021-02-20 13:57:39 +01:00
80e6c91045 API endpoint for getting latest lottery. 2021-02-20 13:29:41 +01:00
7402fb7a7c Promise.all needs a list of promises. 2021-02-19 01:18:12 +01:00
60044859eb Query parameters can not be constants. 2021-02-19 01:03:26 +01:00
3388bed400 Disable registering new users. 2021-02-19 01:01:06 +01:00
704ed51db5 Prizedistribution wants winners w/ phone number. 2021-02-19 00:54:12 +01:00
48c1842b8b When env=development use middleware to always auth. 2021-02-19 00:39:59 +01:00
7bd2e9d931 All our new routes 🎉
- GET /history/search
 - GET /purchases
   - /purchases
   - /purchases/summary
   - /purchases/:date
 - PUT /lottery/winner/:id (not currently used)
 - GET /lotteries
 - POST /lottery/messages/winner/:id
2021-02-19 00:29:57 +01:00
83d9b30048 Request wine front & backend talk nicer togheter.
- requestWineController validates wine object and returns helpfull
 error repsonse if anything is missing.
 - requestWine uses new endpoint and calls api from within itself.
 - Linting.
2021-02-19 00:29:05 +01:00
3f77722f4f allLotteries w/ sort & includeWinners query opts. 2021-02-18 23:42:21 +01:00
324ca5d9bc Date defaults to today and return response message. 2021-02-18 23:41:46 +01:00
1e6ec3d4c8 Require attendee name AND number when adding. 2021-02-18 23:39:00 +01:00
1b12453df0 LotteryWinner functionality not yet used.
Can post winners directly with parsing of parameters and error handling.
2021-02-18 23:38:00 +01:00
2eb933f03e Get including winners, filter by year and sort.
Separate function for getting all history including the winners object.
Both have sort parameter that is used within the mongo query instead of
doing it in javascript.
2021-02-18 23:30:09 +01:00
2477f36f96 Get all wines with limit parameter. 2021-02-18 22:07:54 +01:00
9823197a48 Better validation and error resp validating wines. 2021-02-18 21:06:49 +01:00
d0fa89b92b Update lottery winner by id.
Endpoint, controller and repository function for updating lottery winner
by id and json payload.
Keeps previous definition for undefined/null values.
2021-02-18 21:05:40 +01:00
fc029f80df New message & wine controllers!
These interface towards the respective repositories.
Wine:
 - /api/wine/:id - getWineById
 - /api/wines - allWines

Messages:
 - /api/lottery/messages/winner/:id - notifyWinnerById
2021-02-18 21:02:07 +01:00
824bd60c02 Updated internal name of wine schema. 2021-02-18 21:00:32 +01:00
6003151e3b Better error handling for claim prize.
We wrap await function calls with try catch and return the res if any
error occur.
2021-02-18 20:58:57 +01:00
ab58a45da5 Better var name and response message text. 2021-02-18 20:58:40 +01:00
dcaaeae51f Get prizes only returns wines without a winner already. 2021-02-18 20:58:09 +01:00
9fd67a6bc3 Removed unused parameter. 2021-02-18 20:55:41 +01:00
70c80849df No longer delete winner as part of selecting prize.
Winners are rather marked with prize_selected and have it's own endpoint
to remove all winners.
2021-02-18 20:54:15 +01:00
a28a8ccacb When selecting prize, add winner to wine.
Changed the way we register a prize for winner.
Now we have a new prize_selected boolean field on a winner. This is
used to filter on when finding what winners have not selected a prize
yet. This also replaces the previous method of removing virtualWinners
after they selected a prize.

PrelotteryWine also get's a winner reference. This is used to filter on
when finding what prizes are left, and also makes it easier to
archive/register a lottery when the wine has a winner attached.
2021-02-18 20:50:30 +01:00
4bd3b688e9 Get wines by id or search with wine object.
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.
2021-02-18 20:44:54 +01:00
930c458d9c Search history for winner name. 2021-02-18 20:40:35 +01:00
787882e753 History ordered by wins has limit parameter. 2021-02-18 20:40:14 +01:00
68b4e96ad0 Import with lowercase name, it's not a class. 2021-02-18 20:39:27 +01:00
56d2513a9c Incorrect history.js function called. 2021-02-18 20:38:49 +01:00
1c40fae69d Repository gets new search winner by query func.
Has sort parameter that defaults to newest first.
2021-02-17 19:26:01 +01:00
bca4558d59 orderByWins has limit parameter to slice response
Limit the number of rows returned, used for frontpage where we display
max 20.
2021-02-17 19:21:33 +01:00
38eb98e68b Sorting happens in mongo query, no longer in js. 2021-02-17 19:20:52 +01:00
c98ccbc3f0 We want a mongo instance of both winner and wine.
The inputs to these functions are objects, if we want to use mongoose we
need to get a new instance of wine and winner.
2021-02-17 19:19:13 +01:00
3d99a3e5f2 Wine repository gets function for all wines. 2021-02-17 19:17:36 +01:00
7292cf7983 Endpoint for getting wine schema.
This is for manual registration of prelottery wines from the admin page.
2021-02-15 22:38:22 +01:00
57fe7d444b Used correct func name for wines from vinmonpolet. 2021-02-15 22:34:51 +01:00
cb4a30b5e9 BIGBOY rewrite.
All endpoints have been re-worked to be more clear on what they do. They
also all have their own controller now.
2021-01-26 23:05:52 +01:00
b321f2cfdd Fixed import location for redis. 2021-01-26 23:04:15 +01:00
ce480e790a Replaced for clearer project structure & new ctrls.
These files where directly called from the api endpoints. Now all
functoins have been replaced with a controller interfacing to the
endpoint and a repository file for each of the functions.
2021-01-26 23:01:49 +01:00