- Register User
- Check Username Eligibility
- Check Email Eligibility
- Login User
- Check Auth
- Update Avatar
- Get Avatar
- Update User Data
- Get User Data
- Get Records
- Get Level
Creates new user with given credentials
-
URL
/register
-
Method:
POST
-
Headers:
'Content-Type': 'application/json'
-
URL Params
None
-
Query Params
None
-
Data Params
{ email: string; username: string; password: string; adminPassword?: string; }
-
Success Response:
- Code: 201 CREATED
Content:{ "username": "Lev Sylin", "email": "[email protected]", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjNkM2UwN2I0MjAyZTVmNWJlMzMyZGU1IiwicGFzc3dvcmQiOiJyc2Nsb25lIiwiaWF0IjoxNjc0ODI5OTQ3LCJleHAiOjE2NzQ4NTE1NDd9.WGbXvAV02oPqZx6awbR53Lw3TSksZBWH6Ja-tT2hO58" }
- Code: 201 CREATED
-
Error Response:
-
Code: 400 BAD REQUEST
Content:Invalid input: "email", "password" and "username" are required
OR
-
Code: 409 CONFLICT
Content:A user with this email address already exists
OR
-
Code: 422 UNPROCESSABLE ENTITY
Content:Username is already taken
OR
-
Code: 401 UNAUTHORIZED
Content:Invalid admin password
-
-
Notes:
None
Checks username eligibility
-
URL
/register/check-username
-
Method:
POST
-
Headers:
'Content-Type': 'application/json'
-
URL Params
None
-
Query Params
None
-
Data Params
{ username: string; }
-
Success Response:
- Code: 200 OK
Content: None
- Code: 200 OK
-
Error Response:
-
Code: 400 BAD REQUEST
Content:Invalid input: "username" is required
OR
-
Code: 422 UNPROCESSABLE ENTITY
Content:Username is already taken
-
-
Notes:
None
Checks email eligibility
-
URL
/register/check-email
-
Method:
POST
-
Headers:
'Content-Type': 'application/json'
-
URL Params
None
-
Query Params
None
-
Data Params
{ email: string; }
-
Success Response:
- Code: 200 OK
Content: None
- Code: 200 OK
-
Error Response:
-
Code: 400 BAD REQUEST
Content:Invalid input: "email" is required
OR
-
Code: 409 CONFLICT
Content:A user with this email address already exists
-
-
Notes:
None
Validates credentials. Returns a token on success
-
URL
/login
-
Method:
POST
-
Headers:
'Content-Type': 'application/json'
-
URL Params
None
-
Query Params
None
-
Data Params
{ login: string; password: string; }
-
Success Response:
- Code: 200 OK
Content:{ "username": "Lev Sylin", "email": "[email protected]", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjNkM2UwN2I0MjAyZTVmNWJlMzMyZGU1IiwicGFzc3dvcmQiOiJyc2Nsb25lIiwiaWF0IjoxNjc0ODI5OTQ3LCJleHAiOjE2NzQ4NTE1NDd9.WGbXvAV02oPqZx6awbR53Lw3TSksZBWH6Ja-tT2hO58" }
- Code: 200 OK
-
Error Response:
-
Code: 400 BAD REQUEST
Content:Invalid input: "password" and "login" are required
OR
-
Code: 404 NOT FOUND
Content:User with this "password" and "login" was not found
-
-
Notes:
None
Checks token validity
-
URL
/check-auth
-
Method:
GET
-
Headers:
'Content-Type': 'application/json'
'x-access-token': ${token}
-
URL Params
None
-
Query Params
None
-
Data Params
None
-
Success Response:
-
Code: 200 OK
Content:None
-
-
Error Response:
-
Code: 401 UNAUTHORIZED
Content:Invalid Token
-
-
Notes:
None
Changes the user's avatar to the sent one if the given token is valid
-
URL
/avatar
-
Method:
PATCH
-
Headers:
'Content-Type': 'multipart/form-data'
'x-access-token': ${token}
-
URL Params
Unrequired:
username=[string]
-
Query Params
None
-
Data Params
{ file: Binary; }
-
Success Response:
- Code: 200 OK
Content: None
- Code: 200 OK
-
Error Response:
-
Code: 403 FORBIDDEN
Content:A token is required for authentication
OR
-
Code: 401 UNAUTHORIZED
Content:Invalid Token
OR
-
Code: 401 UNAUTHORIZED
Content:You don't have rights to do that
OR
-
Code: 404 NOT FOUND
Content:User with this "nickname" not found
-
-
Notes:
-
Request must be sent using the multipart/form-data content-type. See test-pages/uploadImage.html
-
Only admin users can use "nickname" in url params to update other user's avatar
-
Responses with user's avatar
-
URL
/avatar/:username
-
Method:
GET
-
Headers:
None
-
URL Params
Required:
username=[string]
-
Query Params
None
-
Data Params
None
-
Success Response:
- Code: 200 OK
Content:image/png, image/jpg (chunked)
- Code: 200 OK
-
Error Response:
-
Code: 400 BAD REQUEST
Content:Invalid input: "username" is required
OR
-
Code: 404 NOT FOUND
Content:User with this "username" not found
-
-
Notes:
None
Validates token. Replaces user data with the data from request's body. Returns object of mutable user data.
-
URL
/user
-
Method:
PATCH
-
Headers:
'Content-Type': 'application/json'
'x-access-token': ${token}
-
URL Params
Unrequired:
username=[string]
-
Query Params
None
-
Data Params
{ language?: "en_us" | "es_es" | "ru" | "uk"; records?: Record<gameName, Array<number>>; }
-
Success Response:
- Code: 200 OK
Content:{ "language": "en_us", "records": { "flexbox": [1, 2] } }
- Code: 200 OK
-
Error Response:
-
Code: 403 FORBIDDEN
Content:A token is required for authentication
OR
-
Code: 401 UNAUTHORIZED
Content:Invalid Token
OR
-
Code: 401 UNAUTHORIZED
Content:You don't have rights to do that
-
-
Notes:
- Only admin users can use "nickname" in url params to update other user's data
Validates token. Returns object of mutable user data.
-
URL
/user
-
Method:
GET
-
Headers:
'x-access-token': ${token}
-
URL Params
Unrequired:
username=[string]
-
Query Params
None
-
Data Params
None
-
Success Response:
- Code: 200 OK
Content:{ "language": "en_us", "records": { "flexbox": [1, 2] } }
- Code: 200 OK
-
Error Response:
-
Code: 403 FORBIDDEN
Content:A token is required for authentication
OR
-
Code: 401 UNAUTHORIZED
Content:Invalid Token
OR
-
Code: 401 UNAUTHORIZED
Content:You don't have rights to do that
-
-
Notes:
- Only admin users can use "nickname" in url params to get other user's data
Validates a token. Returns an array of users records objects.
-
URL
/records
-
Method:
GET
-
Headers:
'x-access-token': ${token}
-
URL Params
None
-
Query Params
Unrequired:
page = [number]
limit = [number]
sort = 'username' | 'levelFlexbox'
order = 'asc' | 'ascending' | 'desc' | 'descending'
-
Data Params
None
-
Success Response:
- Code: 200 OK
Content:[ { "username": "aaa", "levelFlexbox": 3 }, { "username": "bbb", "levelFlexbox": 1 }, { "username": "ccc", "levelFlexbox": 8 }, { "username": "ddd", "levelFlexbox": 5 }, { "username": "eee", "levelFlexbox": 12 }, { "username": "fff", "levelFlexbox": 2 }, { "username": "ggg", "levelFlexbox": 6 }, { "username": "hhh", "levelFlexbox": 1 }, { "username": "iii", "levelFlexbox": 1 }, { "username": "jjj", "levelFlexbox": 9 }, { "username": "kkk", "levelFlexbox": 5 } ]
- Code: 200 OK
-
Error Response:
-
Code: 403 FORBIDDEN
Content:A token is required for authentication
OR
-
Code: 401 UNAUTHORIZED
Content:Invalid Token
-
-
Notes:
None
Validates token. Returns level data according to user's language.
-
URL
/levels/:game/:level
-
Method:
GET
-
Headers:
'x-access-token': ${token}
-
URL Params
Required:
game = "flexbox" | [string]
level = [number]
-
Query Params
None
-
Data Params
None
-
Success Response:
-
Code: 200 OK
Content:{ "winCondition":"justify-content: flex-end;", "name":"Выравнивание содержимого Flex Контейнера", "description":{ "paragraph":"Добро пожаловать в Flexbox Froggy. Игра, в которой тебе нужно помочь лягушонку Фроги и его друзьям, написав CSS код! Направь этого лягушонка на лилию справа, используя свойство <code>justify-content</code>, которое выравнивает элементы горизонтально и принимает следующие значения:", "rulesList":[ "<code>flex-start</code>: Элементы выравниваются по левой стороне контейнера.", "<code>flex-end</code>: Элементы выравниваются по правой стороне контейнера.", "<code>center</code>: Элементы выравниваются по центру контейнера.", "<code>space-between</code>: Элементы отображаются с одинаковыми отступами между ними.", "<code>space-around</code>: Элементы отображаются с одинаковыми отступами вокруг них." ], "example":"Например, <code>justify-content: flex-end;</code> сдвинет лягушонка вправо." }, "submitText":"Следующий Уровень", "type1Quantity":1, "type2Quantity":0, "type3Quantity":0 }
-
Code: 200 OK
-
Error Response:
-
Code: 403 FORBIDDEN
Content:A token is required for authentication
OR
-
Code: 401 UNAUTHORIZED
Content:Invalid Token
OR
-
Code: 404 NOT FOUND
Content:Level ${levelNumber} of the game "${game}" not found
-
-
Notes:
None