Skip to content
This repository was archived by the owner on May 27, 2022. It is now read-only.

Latest commit

 

History

History
1241 lines (942 loc) · 21.6 KB

File metadata and controls

1241 lines (942 loc) · 21.6 KB

streamers-edge v0.1.0

Backend module for StreamersEdge application

Admin

Get authorized admin profile

Get profile of authorized admin

GET /api/v1/admin/profile

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "result": {
    "id": "5cc315041ec568398b99d7ca",
    "username": "test",
    "email": "test@email.com",
    "twitchUserName": "",
    "googleName": "",
    "avatar": "",
    "youtube": "",
    "facebook": "",
    "peerplaysAccountName": "",
    "bitcoinAddress": "",
    "userType": "viewer"
  }
}

Ban user by id

POST /api/v1/admin/users/ban/:userId

Success Response

Success-Response:

HTTP/1.1 200 OK
{
 "result": true,
 "status": 200
}

get user info by id

GET /api/v1/admin/users/ban/:userId

Success Response

Success-Response:

HTTP/1.1 200 OK
{
 "status": 200
 "result": {
    "id": "1",
    "username": "test",
    "youtube": "",
    "facebook": "",
    "peerplaysAccountName": "",
    "twitchId": "42342",
    "twitchLink": "https://www.twitch.tv/42342/videos",
  }
}

Get users with their status

Get profiles of all users with their ban status

GET /api/v1/admin/users

Parameters

Name Type Description
offset Number optional

Number of rows to skip

limit Number
flag String optional

Filter param to fetch users by status

search String optional

Filter by username / email

Success Response

Success-Response:

HTTP/1.1 200 OK
[
  {
    "status": 200,
    "result": {
      "id": "1",
      "username": "test",
      "email": "test@email.com",
      "isEmailVerified": true,
      "twitchUserName": "",
      "twitchId": "",
      "googleId": "",
      "googleName": "",
      "avatar": "",
      "youtube": "",
      "facebook": "",
      "peerplaysAccountName": "",
      "bitcoinAddress": "",
      "userType": "viewer",
      "status": "banned",
      "ban-histories.bannedById": "2"
      "ban-histories.bannedAt": "2019-06-29T12:26:56.453Z"
    }
  }
]

Auth

Confirm email

GET /api/v1/auth/confirm-email/:token

Logout

POST /api/v1/auth/logout

Examples

Request-Example:

{}

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "result": true
}

Sign in

POST /api/v1/auth/sign-in

Examples

Request-Example:

{
  "login": "test@test.com",
  "password": "testtest"
}

Sign up

POST /api/v1/auth/sign-up

Examples

Request-Example:

{
  "email": "test@test.com",
  "username": "test",
  "password": "testtest",
  "repeatPassword": "testtest"
}

Forgot password

POST /api/v1/auth/forgot-password

Examples

Request-Example:

{
  "email": "test@test.com"
}

Reset password

POST /api/v1/auth/reset-password

Examples

Request-Example:

{
  "token": "fb7ce9c3913ed08a0dfd45d4bc",
  "password": "testpass",
  "repeatPassword": "testpass"
}

Challenges

Create new challenge

POST /api/v1/challenges

Parameters

Name Type Description
name String

Name of challenge

startDate Date optional

Date of start challenge in ISO format

endDate Date optional

Date of end challenge in ISO format

game String

Type of challenge game. Now can be 'pubg' only

accessRule String

Type of access - anyone or invite

ppyAmount Number

PPY Amount for challenge in "satoshis"

conditionsText String optional

Required only if conditions is empty

conditions Object[] optional

Conditions array

conditions.param String optional

result_place, win_time, frags

conditions.operator String optional

>, <, =, >=, <=

conditions.value Number optional

Can be integer number

conditions.join String optional

AND, OR or END. END can be used once

Examples

Request-Example:

{
  "name": "Test name",
  "startDate": "2019-04-04T08:32:19.818Z",
  "endDate": "2019-04-04T08:32:19.818Z",
  "game": "pubg",
  "accessRule": "anyone",
  "ppyAmount": 100,
  "invitedAccounts": [],
  "conditionsText": [],
  "conditions": [{
    "param": "resultPlace",
    "operator": ">",
    "value": 1,
    "join": "END"
  }]
}

Success Response

Success-Response:

HTTP/1.1 200 OK
{
 "result": {
   "id": 11,
   "name": "test",
   "createdAt": "2019-06-02T06:11:44.866Z",
   "startDate": "2019-07-04T08:32:19.818Z",
   "endDate": null,
   "game": "pubg",
   "accessRule": "anyone",
   "ppyAmount": "1",
   "conditionsText": "test",
   "user": {
     "id": 1,
     "username": "username",
     "youtube": "",
     "facebook": "",
     "peerplaysAccountName": "",
     "bitcoinAddress": ""
   },
   "conditions": [{
     "id": 4,
     "param": "resultPlace",
     "operator": ">",
     "value": 1,
     "join": "OR",
     "createdAt": "2019-06-02T06:11:44.874Z",
     "updatedAt": "2019-06-02T06:11:44.874Z",
     "challengeId": 11
   }, {
     "id": 5,
     "param": "resultPlace",
     "operator": ">",
     "value": 1,
     "join": "END",
     "createdAt": "2019-06-02T06:11:44.875Z",
     "updatedAt": "2019-06-02T06:11:44.875Z",
     "challengeId": 11
   }],
   "invitedUsers": []
 },
 "status": 200
}

Get challenge by id

GET /api/v1/challenges/:id

Success Response

Success-Response:

HTTP/1.1 200 OK
{
 "result": {
   "id": 11,
   "name": "test",
   "createdAt": "2019-06-02T06:11:44.866Z",
   "startDate": "2019-07-04T08:32:19.818Z",
   "endDate": null,
   "game": "pubg",
   "accessRule": "anyone",
   "ppyAmount": "1",
   "conditionsText": "test",
   "user": {
     "id": 1,
     "username": "username",
     "youtube": "",
     "facebook": "",
     "peerplaysAccountName": "",
     "bitcoinAddress": ""
   },
   "conditions": [{
     "id": 4,
     "param": "resultPlace",
     "operator": ">",
     "value": 1,
     "join": "OR",
     "createdAt": "2019-06-02T06:11:44.874Z",
     "updatedAt": "2019-06-02T06:11:44.874Z",
     "challengeId": 11
   }, {
     "id": 5,
     "param": "resultPlace",
     "operator": ">",
     "value": 1,
     "join": "END",
     "createdAt": "2019-06-02T06:11:44.875Z",
     "updatedAt": "2019-06-02T06:11:44.875Z",
     "challengeId": 11
   }],
   "invitedUsers": []
 },
 "status": 200
}

Get all challenges

GET /api/v1/challenges

Success Response

Success-Response:

HTTP/1.1 200 OK
{
 "result": {
   "id": 11,
   "name": "test",
   "createdAt": "2019-06-02T06:11:44.866Z",
   "startDate": "2019-07-04T08:32:19.818Z",
   "endDate": null,
   "game": "pubg",
   "accessRule": "anyone",
   "ppyAmount": "1",
   "conditionsText": "test",
   "user": {
     "id": 1,
     "username": "username",
     "youtube": "",
     "facebook": "",
     "peerplaysAccountName": "",
     "bitcoinAddress": ""
   },
   "conditions": [{
     "id": 4,
     "param": "resultPlace",
     "operator": ">",
     "value": 1,
     "join": "OR",
     "createdAt": "2019-06-02T06:11:44.874Z",
     "updatedAt": "2019-06-02T06:11:44.874Z",
     "challengeId": 11
   }, {
     "id": 5,
     "param": "resultPlace",
     "operator": ">",
     "value": 1,
     "join": "END",
     "createdAt": "2019-06-02T06:11:44.875Z",
     "updatedAt": "2019-06-02T06:11:44.875Z",
     "challengeId": 11
   }],
   "invitedUsers": []
 },
 "status": 200
}

Invite user to new challenge

POST /api/v1/challenges/invite

Parameters

Name Type Description
userId Number

Invited user Id

challengeId Number

Id of of challenge

Examples

Request-Example:

{
  "userId": "6",
  "challengeId": "107",
}

Success Response

Success-Response:

HTTP/1.1 200 OK
{
 "result": {
   "id": 11,
   "name": "test",
   "createdAt": "2019-06-02T06:11:44.866Z",
   "startDate": "2019-07-04T08:32:19.818Z",
   "endDate": null,
   "game": "pubg",
   "accessRule": "anyone",
   "ppyAmount": "1",
   "conditionsText": "test",
   "user": {
     "id": 1,
     "username": "username",
     "youtube": "",
     "facebook": "",
     "peerplaysAccountName": "",
     "bitcoinAddress": ""
   },
   "conditions": [{
     "id": 4,
     "param": "resultPlace",
     "operator": ">",
     "value": 1,
     "join": "OR",
     "createdAt": "2019-06-02T06:11:44.874Z",
     "updatedAt": "2019-06-02T06:11:44.874Z",
     "challengeId": 11
   }, {
     "id": 5,
     "param": "resultPlace",
     "operator": ">",
     "value": 1,
     "join": "END",
     "createdAt": "2019-06-02T06:11:44.875Z",
     "updatedAt": "2019-06-02T06:11:44.875Z",
     "challengeId": 11
   }],
   "invitedUsers": []
 },
 "status": 200
}

Join user to challenge

POST /api/v1/challenges/join

Parameters

Name Type Description
challengeId Number

User join to this challenge

tx Object

transaction for this challenge

Examples

Request-Example:

{
  "challengeId": "107",
  "tx": {
    {
      ref_block_num: 37792,
      ref_block_prefix: 2533853773,
      expiration: '2019-06-28T14:17:57',
      operations:
        [0,
          {
            fee: {amount: '2000000', asset_id: '1.3.0'},
            from: '1.2.54',
            to: '1.2.55',
            amount: {amount: '10000', asset_id: '1.3.0'},
            memo: undefined,
            extensions: []
          }],
      extensions: [],
      signatures: ['1f2baa40114f8ed62ec1d3979b5...343716bd033262']
    }
  }
}

Success Response

Success-Response:

HTTP/1.1 200 OK
{
 "result": {
   "joinedAt": "2019-06-26T14:46:29.415Z",
   "isPayed": false,
   "id": 4,
   "challengeId": 15,
   "userId": 6,
   "updatedAt": "2019-06-26T14:46:29.416Z",
   "createdAt": "2019-06-26T14:46:29.416Z"
 }
 "status": 200
}

Success-Response:

HTTP/1.1 200 OK
{
 "result": {
   "id": 11,
   "name": "test",
   "createdAt": "2019-06-02T06:11:44.866Z",
   "startDate": "2019-07-04T08:32:19.818Z",
   "endDate": null,
   "game": "pubg",
   "accessRule": "anyone",
   "ppyAmount": "1",
   "conditionsText": "test",
   "user": {
     "id": 1,
     "username": "username",
     "youtube": "",
     "facebook": "",
     "peerplaysAccountName": "",
     "bitcoinAddress": ""
   },
   "conditions": [{
     "id": 4,
     "param": "resultPlace",
     "operator": ">",
     "value": 1,
     "join": "OR",
     "createdAt": "2019-06-02T06:11:44.874Z",
     "updatedAt": "2019-06-02T06:11:44.874Z",
     "challengeId": 11
   }, {
     "id": 5,
     "param": "resultPlace",
     "operator": ">",
     "value": 1,
     "join": "END",
     "createdAt": "2019-06-02T06:11:44.875Z",
     "updatedAt": "2019-06-02T06:11:44.875Z",
     "challengeId": 11
   }],
   "invitedUsers": []
 },
 "status": 200
}

Subscribe to new notification

POST /api/v1/challenges/subscribe

Parameters

Name Type Description
endpoint String

url for user

expirationTime Number

time of expiration

keys Object

object

keys.p256dh String optional

string in p256dh

keys.auth String optional

auth string

Examples

Request-Example:

{
  endpoint: 'https://fcm.googleapis.com/...lbTgv66-WEEWWK9bxZ_ksHhV_Z49vBvnYZdeS6cL6kk',
  expirationTime: null,
  keys:
   {
     p256dh: 'BOQWqnde....j7Dk-o',
     auth: 'EYFQS0dh2KaPMXx9nmVPww'
   }
}

Success Response

Success-Response:

HTTP/1.1 200 OK
{
 "result": "BOQWqndev7VP-UCLv9QIqDtkcNwRjyu4QBPDTCymL6ILHWklqWP1XxXRLmAYywsfgGs7K8Yub_6jQKiN0j7Dk-o",
 "status": 200
}

Facebook

Auth by facebook

GET /api/v1/auth/facebook

Google

Auth by google

GET /api/v1/auth/google

PayPal

Process payment paypal

POST /api/v1/payment

Profile

Create peerplays account for authorized user

POST /api/v1/profile/peerplays/create-account

Examples

Request-Example:

{
  "name": "testaccount",
  "activeKey": "PPY5iePa6MU4QHGyY5tk1XjngDG1j9jRWLspXxLKUqxSc4sh51ZS4",
  "ownerKey": "PPY5iePa6MU4QHGyY5tk1XjngDG1j9jRWLspXxLKUqxSc4sh51ZS4",
}

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "result": {
    "id": 7,
    "username": "test",
    "email": "test@email.com",
    "twitchUserName": "",
    "googleName": "",
    "youtube": "",
    "facebook": "",
    "twitch": "",
    "peerplaysAccountName": "",
    "bitcoinAddress": "",
    "userType": "viewer",
    "avatar": ""
 }
}

Delete profile avatar

DELETE /api/v1/profile/avatar

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "result": {
    "id": 7,
    "username": "test",
    "email": "test@email.com",
    "twitchUserName": "",
    "googleName": "",
    "youtube": "",
    "facebook": "",
    "twitch": "",
    "peerplaysAccountName": "",
    "bitcoinAddress": "",
    "userType": "viewer",
    "avatar": ""
 }
}

Get authorized user profile

Get profile of authorized user

GET /api/v1/profile

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "result": {
    "id": 7,
    "username": "test",
    "email": "test@email.com",
    "twitchUserName": "",
    "googleName": "",
    "youtube": "",
    "facebook": "",
    "twitch": "",
    "peerplaysAccountName": "",
    "bitcoinAddress": "",
    "userType": "viewer",
    "avatar": ""
 }
}

Update authorized user profile

PATCH /api/v1/profile

Examples

Request-Example:

{
  "avatar": "",
  "youtube": "",
  "facebook": "",
  "peerplaysAccountName": "",
  "bitcoinAddress": "",
  "userType": "viewer"
}

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "result": {
    "id": 7,
    "username": "test",
    "email": "test@email.com",
    "twitchUserName": "",
    "googleName": "",
    "youtube": "",
    "facebook": "",
    "twitch": "",
    "peerplaysAccountName": "",
    "bitcoinAddress": "",
    "userType": "viewer",
    "avatar": ""
 }
}

Add or change account avatar

POST /api/v1/profile/avatar

Examples

Request-Example:

"file": ...file...

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "result": {
    "id": 7,
    "username": "test",
    "email": "test@email.com",
    "twitchUserName": "",
    "googleName": "",
    "youtube": "",
    "facebook": "",
    "twitch": "",
    "peerplaysAccountName": "",
    "bitcoinAddress": "",
    "userType": "viewer",
    "avatar": ""
 }
}

Report

Report user

POST /api/v1/report

Examples

Request-Example:

{
  "reportedUserId": 2,
  "reason": "vulgarity-on-stream",
  "description": "bad, very bad",
  "videoUrl": "url"
}

Success Response

Success-Response:

HTTP/1.1 200 OK
  {
  "result": {
      "id": 2,
      "reportedUserId": 2,
      "reportedByUserId": 1,
      "reason": "vulgarity-on-stream",
      "description": "bad, very bad",
      "videoUrl": "url",
      "updatedAt": "2019-07-01T14:16:05.933Z",
      "createdAt": "2019-07-01T14:16:05.933Z"
    },
    "status": 200
  }

Stream

Get stream

Get Stream by StreamId

GET /api/v1/stream/:id

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "result": {
  "id": 1,
  "name": "TSM chocoTaco | today's weather: thirsty",
  "game": "pubg",
  "sourceName": "twitch",
  "embedUrl": "",
  "channelId": "34608843376",
  "views": 3536,
  "isLive": true,
  "startTime": "2019-06-21T00:09:40.000Z",
  "thumbnailUrl": "https://static-cdn.jtvnw.net/previews-ttv/live_user_chocotaco-{width}x{height}.jpg",
  "user": {
      "id": 10,
      "username": "jotprabh",
      "email": "prabhjot.narula@gmail.com",
      "twitchUserName": null,
      "googleName": null,
      "youtube": "",
      "facebook": "",
      "peerplaysAccountName": "",
      "bitcoinAddress": "",
      "userType": null
    }
  },
  "status": 200
}

Get streams

Get Streams

GET /api/v1/streams

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "result": [
      {
          "id": 1,
          "name": "TSM chocoTaco | today's weather: thirsty",
          "game": "pubg",
          "sourceName": "twitch",
          "embedUrl": "",
          "channelId": "34608843376",
          "views": 3536,
          "isLive": true,
          "startTime": "2019-06-21T00:09:40.000Z",
          "thumbnailUrl": "https://static-cdn.jtvnw.net/previews-ttv/live_user_chocotaco-{width}x{height}.jpg",
          "user": {
              "id": 10,
              "username": "jotprabh",
              "email": "prabhjot.narula@gmail.com",
              "twitchUserName": null,
              "googleName": null,
              "youtube": "",
              "facebook": "",
              "peerplaysAccountName": "",
              "bitcoinAddress": "",
              "userType": null
          }
      }
  ],
  "status": 200
}

Get Streams for users from Twitch

GET /api/v1/stream/populate-twitch-streams

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "result": true
}

Transactions

Get user transactions

GET /api/v1/transactions

Parameters

Name Type Description
limit String
skip String optional

Success Response

Success-Response:

HTTP/1.1 200 OK
{
 "status": 200
 "result": [{
   "id": 1,
   "txId": "8ed2756c1b26883585f6259eca90ad0e44be04a2",
   "blockNum": 901602,
   "trxNum": 0,
   "ppyAmountValue": 100,
   "type": "challengeCreation",
   "createdAt": "2019-07-01T07:25:33.100Z",
   "updatedAt": "2019-07-01T07:25:33.100Z",
   "userId": 1,
   "challengeId": 3
 }]
}

Twitch

Auth by twitch

GET /api/v1/auth/twitch

Users

Change notification status

PATCH /api/v1/users/setNotification

Parameters

Name Type Description
set Boolean

notification for user

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "result": [1],
  "status": 200
}

Get user by id

GET /api/v1/users/:id

Parameters

Name Type Description
id String

User id

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "result": {
    "id": "5cc315041ec568398b99d7ca",
    "username": "test",
    "youtube": "",
    "facebook": "",
    "peerplaysAccountName": "",
    "bitcoinAddress": ""
  }
}

Get users list

GET /api/v1/users

Parameters

Name Type Description
search String optional

Filter by PeerPlays Account Name

limit Number

Limit of rows

skip Number optional

Number of rows to skip

Success Response

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "result": [{
    "id": "5cc315041ec568398b99d7ca",
    "username": "test",
    "youtube": "",
    "facebook": "",
    "peerplaysAccountName": "",
    "bitcoinAddress": ""
  }]
}