Test assignment on Fullstack Python/AngularJS developer position Raw
User
----
name text
surname text
salt text
enc_passwd text
Contacts
--------
ref_to_user integer
contact text
contact_type enum(tel, email, skype)
$module.factory()
), перехват $http.{...}
через interceptors, если REST сервер возвращает HTTP/401
, то открыть Bootstrap modal dialog, спросить name
и passwd
, получить токен через открытый REST API Endpoint (пр. /login
), сохранить в singleton./login
должны быть закрыты авторизацией.name
и surname
простым %like%
./api/users
– зарегистрировать нового пользователяMethod: post
Request:
{
email: text
name: text
password: text
surname: text
}
Response:
http/201
{
username: text, equals to 'name'
}
http/400
/api/login
– залогиниться с credentials нового пользователя и получить JWT-токенMethod: post
Request:
{
email: text
password: text
}
Response:
http/200
{
token: jwt_token
}
http/400
http/401
/api/contacts_list
– получить полные списки контактов всех пользователейMethod: get
HTTP header:
Authorization: jwt_token
Request:
{
}
Response:
http/200
{
data: [
{
contacts: [
{
id: int,
text: text,
type: text
}, ...
],
id: int,
name: text,
surname: text
}, ...
],
"success": true
}
http/400
http/401
/api/contacts
– получить полный список контактов для текущего пользователяMethod: get
HTTP header:
Authorization: jwt_token
Request:
{
}
Response:
http/200
{
contacts: [
{
id: int,
text: text,
type: text
}, ...
]
id: int
name: text
surname: text
success: true
}
http/400
http/401
/api/contacts
- создать новую запись в адресной книгеMethod: post
HTTP header:
Authorization: jwt_token
Request:
{
text: text,
type: text
}
Response:
http/200
{
id: int,
text: text, equals to request
type: text, equals to request
}
http/400
http/401
/api/contacts
- удалить запись из адресной книгиMethod: delete
HTTP header:
Authorization: jwt_token
Request:
{
id: int
}
Response:
http/200
{
success: true
}
http/400
http/401
/api/contacts
- отредактировать запись в адресной книгеMethod: put
HTTP header:
Authorization: jwt_token
Request:
{
id: int,
text: text,
type: text
}
Response:
http/200
{
contacts: [
{
id: int,
text: text,
type: text
}, ...
]
id: int
name: text
surname: text
success: true
}
http/400
http/401
/api/search
- поиск по адресной книге по полям name
, surname
, используя SQL LIKEMethod: get
HTTP header:
Authorization: jwt_token
Request:
{
q: text, must be at least 3 symbols
}
Response:
http/200
{
data: [
{
contacts: [
{
id: int,
text: text,
type: text
}, ...
],
id: int,
name: text,
surname: text
}, ...
],
"success": true
}
http/400
http/401