Skip to content

tarasyarema/tinderupc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Melice Corp main API engine

Run

Execute startDB.sh, build.sh and run.sh. You will need a .env file with the following envars:

SECRET=
MONGO_HOST=
MONGO_PORT=
MONGO_INITDB_ROOT_USERNAME=
MONGO_INITDB_ROOT_PASSWORD=

API reference (Inital pivot version v69.0.0)

Register: POST /register

Request

Can be called via form data or JSON body. The mandatory format has to be the following:

{
	"email": "biene@hackupc.com",
	"password": "biene"
}

After that, you can add all the key, value pairs you want. They will be stored in the meta object of the user created.

Returns

A JWT token.

HTTP 200

{
   "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjVkYTI4OTk0NmNkMWNhM2E5MDg4ZDg1NSJ9.ohkLJrptxT0F4wuQekOQEK-qpxNHnrA-jVTwZ4psx74"
}

Login: POST /login

Request

Can be called via form data or JSON body. The format has to be the following:

{
	"email": "biene@hackupc.com",
	"password": "biene"
}

Returns

A JWT token.

HTTP 200

{
   "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjVkYTI4OTk0NmNkMWNhM2E5MDg4ZDg1NSJ9.ohkLJrptxT0F4wuQekOQEK-qpxNHnrA-jVTwZ4psx74"
}

Logout: POST /logout

Request

You should delete the auth header before calling this.

Returns

HTTP 200

{
   "message": "logged out"
}

Get stack: GET /

Request

The token as a Authorization: Bearer {token} header.

Returns

Returns JSON

HTTP 200

{
   "data": [
      {
         "id": "5da25e5286dc7e9c3be99a0d",
         "data": {
            "lang": "C",
            "desccription": "I like maths!",
            "age": 22
         }
      },
      {
         "id": "5da25e5286dc7e9c3be99a0d",
         "data": {
            "lang": "Python",
            "dick": 25
         }
      }
   ]
}

Vote: POST /vote

Request

The token as a Authorization: Bearer {token} header.

Can be called via form data or JSON body. The format has to be the following:

{
	"id_a": "5da25e5286dc7e9c3be99a0d",
	"id_b": "5da26d9687f808f820d54233",
	"win": false
}

The parameters mean:

  1. id_a: User A id.
  2. id_b: User B id.
  3. win: True if the selected is id_a, False if it's id_b.

Returns

HTTP 200

{
   "message": "user relations updated"
}

Get ranking: GET /ranking

Request

The token as a Authorization: Bearer {token} header.

Returns

Returns JSON with an array (actual max 5 elements, may be changed xd).

HTTP 200

{
   "data": [
      {
         "id": "5da26d9687f808f820d54233",
         "elo": 1546.0200225109015,
         "user_data": {
            "email": "jajaasd",
            "meta": {
               "lang": "Python 3.7",
               "description": "hola  asd k tal"
            }
         }
      },
      {
         "id": "5da23afa05650a08e4ca6a8f",
         "elo": 1534.137483083232,
         "user_data": {
            "email": "2pac",
            "meta": {
               "lang": "OCaml",
               "description": "jeje"
            }
         }
      },
      {
         "id": "5da25e5286dc7e9c3be99a0d",
         "elo": 1516.983271764316,
         "user_data": {
            "email": "taras",
            "meta": {
               "lang": "C",
               "desccription": "asdasd asdas"
            }
         }
      },
      {
         "id": "5da25857e57c8c0839a12bea",
         "elo": 1465.0496502835474,
         "user_data": {
            "email": "asd",
            "meta": {
               "lang": "R",
               "description": "juju"
            }
         }
      },
      {
         "id": "5da25e8e5dd47b259e2ac2e3",
         "elo": 1434.9030321116102,
         "user_data": {
            "email": "taras",
            "meta": {
               "lang": "C",
               "desccription": "asdasd asdas"
            }
         }
      }
   ]
}

Post media for a user: POST /media

Request

The token as a Authorization: Bearer {token} header. Binary data with optional Content-Type header. Adds a document to the media collection with user_id the given user.

Now it adds raw binary data to the db, in the next pivot (v1337.0.0) this will be changed to a url of the image in some cloud platform (Google Cloud probably).

Returns

Returns JSON

HTTP 200

{
   "message": "media content uploaded"
}

Get a user profile: GET /profile

Request

The token as a Authorization: Bearer {token} header.

Returns

Returns JSON

HTTP 200

{
   "user": {
      "id": "5da48689bac312608d6d23fc",
      "meta": {
         "description": ":3",
         "lang": "Python 2.7",
         "position": "CEO",
         "age": 22,
         "orientation": "all",
         "whatever": "love you bb"
      }
   },
   "media": [
      {
         "id": "5da493415a0927043cc640f9",
         "data": {
            "$binary": "iVB...rkJggg==",
            "$type": "00"
         },
         "type": "image/png"
      }
   ]
}

About

Because being alone sucks, I guess....

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published