Skip to content

Test Frontend API

L. Le Meur edited this page Jun 22, 2020 · 8 revisions

In brief

The Test Frontend is split into two parts:

  • A server part written in Go, which act as a middleware between a user interface and the License Server.
  • A client part written in Typescript and React, which is a pure user interface.

The Test Frontend Server exposes a set of REST methods which are used by the client part, but may also be used by any other REST client:

  • Create, update, list and delete users.
  • Create, update, list and delete encrypted publications.
  • Let a user acquire a publication.
  • Let a user generate and fetch a license.
  • Fetch an up-to-date license by its identifier.

Some of these REST API endpoints are not documented; they'll be if needed.

For each publication, the frontend stores:

  • Identifier
  • Title

For each user, the frontend stores:

  • Identifier
  • Email
  • Name
  • Hash of the passphrase

API

Fetch an existing license

GET <FrontBaseURL>/api/v1/licenses/<license_id>

Return:

This method calls the License Server with a request for an existing license.

Post a publication to the server

POST <FrontBaseURL>/publicationUpload

Query Parameter:

title: the title of the publication. This title should no already exist in the database.

Payload: A multipart message, with a unique key named "file" and a binary value which is the content of the un-encrypted publication.

An equivalent curl command is of the form:
curl --location --request POST 'http://<server>/publicationUpload?title=<publication-title>'
--form 'file=@/<path>/<file-name.epub>'

Return:

  • 200 ok
  • 400 (bad request)

This method encrypts the publication and notifies the License Server, which stores the encrypted publication in its final storage location.