This standalone service exposes the functionality of checking the validity of a provided EPUB file. The API offered is as follows:
POST /api/authPOST /api/epubchecker
- As this service is meant to be from many clients, the first endpoint allows clients to acquire their access tokens in order to be able to use the service*. A call to the
api/authendpoint considered valid if it contains the Authorization header with valueBasic base64encoded(clientId:clientSecret).
The response of a valid call to theapi/authwill return anaccessToken** (JWT) - A call to the
api/epubcheckerin order to be considered valid should have theAuthorizationproperty in its headers with valueBearer <the value of an accessToken provided by this service>. The propertyContent-Typeshould bemultipart/form-dataand finally the body should contain the actual EPUB under a form field calledepub.
The response of this endpoint will be aJSONobject with two properties:
outcome: String with value eitherokornot validmessages: Array ofmessageobjects (when an EPUB is not valid, otherwise empty)
e.g.
{
outcome:'not valid',
messages:[
{
"ID": "RSC-005",
"severity": "ERROR",
"message": "Error while parsing file: attribute \"data-number\" not allowed here; expected attribute \"class\", \"dir\", \"id\", \"lang\", \"style\", \"title\" or \"xml:lang\"",
"additionalLocations": 88,
"locations": [
{
"path": "EPUB/text/ch001_split_001.xhtml",
"line": 13,
"column": 58,
"context": null
},
{
"path": "EPUB/text/ch001_split_001.xhtml",
"line": 13,
"column": 70,
"context": null
},
],
"suggestion": null
}
]
}
*client's registration required beforehand
**the life span of an accessToken is 8 hours
The service is fully dockerized for ease of use for either development or for use in production.
In the root of the service run docker-compose up
This container includes the actual service as well as a Postgres DB
In the root of the service run docker-compose -f docker-compose.production.yml up
This container contains just the service. An external Postgres DB should be provided.
PUBSWEET_SECRET (e.g. a random string used for hashing)
POSTGRES_USER (required for connection to the db)
POSTGRES_PASSWORD (required for connection to the db)
POSTGRES_HOST (required for connection to the db)
POSTGRES_DB (required for connection to the db)
POSTGRES_PORT (required for connection to the db)
SERVER_PORT (port where the server will be exposed)
NODE_ENV (development or production)
All the above are required
When the service is up by executing docker exec -it <name_of_the_epubchecker_server_container> yarn create:client.
The above will produce a valid pair of clientId and clientSecret
This service is using the epubcheck validator provided by IDPF. The version of the validator that Editoria uses is 4.2.2.