Skip to content

Instantly share code, notes, and snippets.

@olegvg
Last active April 7, 2017 11:47
Show Gist options
  • Save olegvg/29e9ad1000aa695059b0825c99486cd5 to your computer and use it in GitHub Desktop.
Save olegvg/29e9ad1000aa695059b0825c99486cd5 to your computer and use it in GitHub Desktop.
Test assignment on Fullstack Python/AngularJS developer position Raw

Тестовое задание. Fullstack (Python + JavaScript) Developer.

Приложение "Адресная книга"

Описание API backend
Remark: type of 'text' implies unicode
Endpoint: /api/users – зарегистрировать нового пользователя

Method: post

Request:

{ 
    email: text
    name: text
    password: text
    surname: text
}

Response:

http/201

{
    username: text, equals to 'name'
}

http/400

Endpoint: /api/login – залогиниться с credentials нового пользователя и получить JWT-токен

Method: post

Request:

{ 
    email: text
    password: text
}

Response:

http/200

{
    token: jwt_token
}

http/400

http/401

Endpoint: /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

Endpoint: /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

Endpoint: /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

Endpoint: /api/contacts - удалить запись из адресной книги

Method: delete

HTTP header:

Authorization: jwt_token

Request:

{ 
    id: int
}

Response:

http/200

{
    success: true
}

http/400

http/401

Endpoint: /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

Endpoint: /api/search - поиск по адресной книге по полям name, surname, используя SQL LIKE

Method: 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

Тестовое задание. Fullstack (Python + JavaScript) Developer.

Приложение "Адресная книга".

Нефункциональные требования:
  • Язык: Python (CPython 3.5) на сервере, JavaScript ECMAScript5-compatible на клиенте.
  • Фреймвроки: Falcon, SQLAlchemy / declarative, AngularJS 1.x, Twitter Bootstrap 3.x последних стабильных ревизий.
  • СУБД Sqlite3.
  • Хранение и обработка данных должна производиться в unicode.
  • Фронтенд должен быть полностью на статике.
  • *Фронтенд должен быть написан в AMD-совместимом виде, загрузка должна производиться через requirejs, установка с помощью npm.
  • **Должны использоваться скрипты Grunt / Gulp / Webpack для подготовки dist-окружения: uglify, minify, LESS/SASS-компиляция по необходимости.
Модель данных:
User
----
name text
surname text
salt text
enc_passwd text

Contacts
--------
ref_to_user integer
contact text
contact_type enum(tel, email, skype)
Функциональные требования:
  • Механизм авторизации: без разделения прав доступа, с использованием JSON Web Token.
  • Авторизация в angular: хранение JWT-токена в singleton ($module.factory()), перехват $http.{...} через interceptors, если REST сервер возвращает HTTP/401, то открыть Bootstrap modal dialog, спросить name и passwd, получить токен через открытый REST API Endpoint (пр. /login), сохранить в singleton.
  • Все REST API Endpoint-ы кроме /login должны быть закрыты авторизацией.
  • Поиск по адресной книге должен осуществляться по полям name и surname простым %like%.
  • Добавление новых людей и контактных данных должно осуществляться по месту, либо кнопкой "добавить".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment