Step 1: Download repo and install modules
git clone https://github.com/wallfair-organization/server-side
cd server-side
npm installStep 2: Start the docker containers needed
docker-compose -f docker/docker-compose.yml up -d
Step 3: Create a .env file (see .env.example) and start the server with:
# copy .env file from email
npm run start
Step 4: Configure the mongo container for replication
docker exec -it mongodb-wall bash
mongo -u wallfair -p walfair
rs.initiate( {
_id : "rs0",
members: [
{ _id: 0, host: "localhost:27017" },
]
});
Step 5: Run the postgresql config
docker exec -it docker_postgres_1 bash
psql -U postgres testdb
CREATE TABLE IF NOT EXISTS token_transactions (ID SERIAL PRIMARY KEY, sender varchar(255) not null, receiver varchar(255) not null, amount bigint not null, symbol varchar(255) not null, trx_timestamp timestamp not null);
CREATE TABLE IF NOT EXISTS token_balances (owner varchar(255) not null, balance bigint not null, symbol varchar(255) not null, last_update timestamp not null, PRIMARY KEY(owner, symbol));
CREATE TABLE IF NOT EXISTS bet_reports (bet_id varchar(255) not null PRIMARY KEY, reporter varchar(255) not null, outcome smallint not null, report_timestamp timestamp not null);
CREATE TABLE IF NOT EXISTS amm_interactions (ID SERIAL PRIMARY KEY, buyer varchar(255) NOT NULL, bet varchar(255) NOT NULL, outcome smallint NOT NULL, direction varchar(10) NOT NULL, investmentAmount bigint NOT NULL, feeAmount bigint NOT NULL, outcomeTokensBought bigint NOT NULL, trx_timestamp timestamp NOT NULL);
Header: "Authorization: Bearer jwtToken"
Request:
{
"phone": "+49123123123"
}Successful Result:
{
"phone": "+49123123123",
"smsStatus": "pending"
}Request:
{
"phone": "+49123123123",
"smsToken": "013416"
}Successful Result:
{
"userId": "608ae87f8e78eb0224ad3e28",
"phone": "+49123123123",
"name*": "Max",
"email*": "max@max.de",
"session": "jwtToken"
}*Optional only if provided
Successful Result:
{
"userId": "608ae87f8e78eb0224ad3e28",
"name*": "Max",
"profilePictureUrl*": "https://previewImageUrl.asd",
"balance": 900
}Successful Result:
[
{
"id": 1,
"buyer": "60cf4588bf102d5fc4c1b475",
"bet": "60cf46a61ef95168648364ab",
"outcome": "yes",
"direction": "BUY",
"investmentamount": "100000",
"feeamount": "1000",
"outcometokensbought": "197902",
"trx_timestamp": "2021年06月20日T13:47:38.937Z"
},
{
"id": 2,
"buyer": "60cf4588bf102d5fc4c1b475",
"bet": "60cf46a61ef95168648364ab",
"outcome": "yes",
"direction": "SELL",
"investmentamount": "49541",
"feeamount": "1000",
"outcometokensbought": "100000",
"trx_timestamp": "2021年06月20日T19:20:08.487Z"
}
]Successful Result:
{
"userId": "60b50d820619b44617959d43",
"refList": [
{
"id": "60b50d820619b44617959d43",
"name": "Nicholas",
"email": "nicholas@wallfair.io"
}
]
}*Optional only if provided
Successful Result:
{
"_id": "6091c24cae92745024088c74",
"title": "test",
"liveMode": true,
"liveStreamUrl": "https://www.google.de/",
"endDate": "1999年12月31日T23:00:00.000Z",
"date": "2021年05月04日T21:53:16.734Z",
"__v": 0
}Successful Result:
[
{
"bets": [
{
"_id": "60a7ff5364dee4f956660797",
"marketQuestion": "Wer gewinnt Redbull",
"hot": true,
"outcomes": [
{
"index": 0,
"name": "Jonas"
},
{
"index": 0,
"name": "Jörn"
}
],
"event": "60a7f9bdc0a1a7f8913b4a23",
"creator": "60a35b31bbb1f700155f2066",
"date": "2021年05月21日T18:43:31.908Z",
"__v": 0
},
{
"_id": "60a7ffb464dee4f956660799",
"marketQuestion": "Wer gewinnt Redbull2",
"hot": true,
"outcomes": [
{
"index": 0,
"name": "Jonas"
},
{
"index": 0,
"name": "Jörn"
}
],
"event": "60a7f9bdc0a1a7f8913b4a23",
"creator": "60a35b31bbb1f700155f2066",
"date": "2021年05月21日T18:45:08.324Z",
"__v": 0
}
],
"_id": "60a7f9bdc0a1a7f8913b4a23",
"name": "Redbull",
"tags": [
{
"_id": "60a7f9bdc0a1a7f8913b4a24",
"name": "jo"
},
{
"_id": "60a7f9bdc0a1a7f8913b4a25",
"name": "joooo"
}
],
"previewImageUrl": "https://previewImageUrl.asd",
"streamUrl": "https://google.com",
"date": "2021年05月21日T18:19:41.671Z",
"__v": 2
}
]- :type can be 'all', 'streamed', 'non-streamed', 'game'
- :category can be 'all', 'streamed-esports', 'streamed-shooter', 'streamed-mmorpg', 'streamed-other', 'sports', 'politics', 'crypto', 'celebrities', 'other'
- :searchQuery is optional
- :page is 1-based
- :sortby is an Event property to be used in mongoose syntax (ex: name (asc), -name (desc))
Successful Result:
[
{
"_id": "6107e58bf0a40958ecaab7f3",
"bets": [
"6107e5c9f0a40958ecaab932",
"6107e704f0a40958ecaac05a"
],
"name": "FIFA Match CyrusTwo",
"streamUrl": "...",
"previewImageUrl": "...",
"tags": [
{
"_id": "6107e58bf0a40958ecaab7f4",
"name": "fifa"
},
{
"_id": "6107e58bf0a40958ecaab7f5",
"name": "soccer"
}
],
"date": "2021年08月02日T22:00:00.000Z",
"__v": 2,
"category": "Esports",
"type": "streamed"
}
]Request:
{
"name": "Redbull",
"tags": [
{ "name": "jo" },
{ "name": "joooo" }
],
"streamUrl": "https://google.com",
"previewImageUrl": "https://previewImageUrl.asd"
}Successful Result:
{
"_id": "60a7f9bdc0a1a7f8913b4a23",
"name": "Redbull",
"tags": [
{
"_id": "60a7f9bdc0a1a7f8913b4a24",
"name": "jo"
},
{
"_id": "60a7f9bdc0a1a7f8913b4a25",
"name": "joooo"
}
],
"previewImageUrl": "https://previewImageUrl.asd",
"streamUrl": "https://google.com",
"bets": [],
"date": "2021年05月21日T18:19:41.671Z",
"__v": 0
}Request:
{
"eventId": "60a7f9bdc0a1a7f8913b4a23",
"marketQuestion": "Wer gewinnt Redbull",
"hot": true,
"outcomes": [
{
"index": 0,
"name": "Jonas"
},
{
"index": 0,
"name": "Jörn"
}
],
"endDate": "1621622318001"
}Successful Result:
{
"bets": [
{
"_id": "60a7ff5364dee4f956660797",
"marketQuestion": "Wer gewinnt Redbull",
"hot": true,
"outcomes": [
{
"index": 0,
"name": "Jonas"
},
{
"index": 0,
"name": "Jörn"
}
],
"event": "60a7f9bdc0a1a7f8913b4a23",
"creator": "60a35b31bbb1f700155f2066",
"date": "2021年05月21日T18:43:31.908Z",
"__v": 0
},
{
"_id": "60a7ffb464dee4f956660799",
"marketQuestion": "Wer gewinnt Redbull2",
"hot": true,
"outcomes": [
{
"index": 0,
"name": "Jonas"
},
{
"index": 0,
"name": "Jörn"
}
],
"event": "60a7f9bdc0a1a7f8913b4a23",
"creator": "60a35b31bbb1f700155f2066",
"date": "2021年05月21日T18:45:08.324Z",
"__v": 0
}
],
"_id": "60a7f9bdc0a1a7f8913b4a23",
"name": "Redbull",
"tags": [
{
"_id": "60a7f9bdc0a1a7f8913b4a24",
"name": "jo"
},
{
"_id": "60a7f9bdc0a1a7f8913b4a25",
"name": "joooo"
}
],
"previewImageUrl": "https://previewImageUrl.asd",
"streamUrl": "https://google.com",
"date": "2021年05月21日T18:19:41.671Z",
"__v": 2
}Request:
{
"amount": 10,
"outcome": 1,
"minOutcomeTokens*": 400
}*Optional
Successful Result:
{
"_id": "60a7ff5364dee4f956660797",
"marketQuestion": "Wer gewinnt Redbull",
"hot": true,
"outcomes": [
{
"index": 0,
"name": "Jonas"
},
{
"index": 0,
"name": "Jörn"
}
],
"event": "60a7f9bdc0a1a7f8913b4a23",
"creator": "60a35b31bbb1f700155f2066",
"date": "2021年05月21日T18:43:31.908Z",
"__v": 0
}Request:
{
"amount": 10,
"outcome": 1,
"minReturnAmount*": 400
}*Optional
Successful Result:
{
"_id": "60a7ff5364dee4f956660797",
"marketQuestion": "Wer gewinnt Redbull",
"hot": true,
"outcomes": [
{
"index": 0,
"name": "Jonas"
},
{
"index": 0,
"name": "Jörn"
}
],
"event": "60a7f9bdc0a1a7f8913b4a23",
"creator": "60a35b31bbb1f700155f2066",
"date": "2021年05月21日T18:43:31.908Z",
"__v": 0
}Request:
{
"amount": 10
}Der "amount" ist in EVNT andgegeben
Successful Result:
[
{
"index": 0,
"outcome": 9.10
},
{
"index": 1,
"outcome": 9.21
}
]Request:
{
"amount": 10
}Der "amount" ist in Outcome-Token (Potential Winnings) andgegeben
Successful Result:
[
{
"index": 0,
"outcome": 9.10
},
{
"index": 1,
"outcome": 9.21
}
]Successful Result:
{
"_id": "60a7ff5364dee4f956660797",
"marketQuestion": "Wer gewinnt Redbull",
"hot": true,
"outcomes": [
{
"index": 0,
"name": "Jonas"
},
{
"index": 1,
"name": "Jörn"
}
],
"event": "60a7f9bdc0a1a7f8913b4a23",
"creator": "60a35b31bbb1f700155f2066",
"date": "2021年05月21日T18:43:31.908Z",
"__v": 0
}Successful Result:
{"status":"OK"}Error Results:
{
"errors": [
{
"msg": "Invalid value",
"param": "userId",
"location": "body"
},
{
"msg": "Invalid value",
"param": "code",
"location": "body"
}
]
}{
"error": "EMAIL_ALREADY_CONFIRMED",
"message": "The email has already been confirmed!"
}{
"error": "INVALID_EMAIL_CODE",
"message": "The email code is invalid!"
}Successful Result:
{"status":"OK"}