@rbbn/werkout-server v1.0.5
Werkout Server
The Werkout Server is a core of the Werkout solution. It is a server built on Express.js and WebSockets and used for managing resources and communications/interactions between an "instructor" and a "partner".
For information on "instructors" and "partners", see the docs
folder in the werkout-js-lib
package.
Responsibilities
- Broker messages between clients (i.e., "instructors" and "partners")
- Manage resources
- Registering resources to the werkout server (e.g., partner apps or data objects)
- Reserving/allocating registered resources to "instructors" when requests are received for resources.
- Releasing/removing resources
- Conveying information from partner to instructor (e.g., state updates)
Usage
The server can be started using the yarn start
script. Use yarn start --help
to see the list of available command-line arguments.
REST API
The server provides REST APIs for both instructors and partners.
Instructor APIs
POST /instructors
- Create/Register an instructor in the Werkout Server
POST /instructors/id/reservations
- Create a reservation request on the Werkout Server (i.e., request resources)
GET /instructors/id/reservations/requestID
- Retrieve the resources reserved if the reservation was successful
DELETE /instructors/id
- Delete an instructor from the Werkout Server (NOTE: this removes all active requests and reservations)
DELETE /instructors/id/reservations/requestID
- Delete/close a reservation request and release all reserved resources
Partner APIs
POST /resources/type
- Create/register a resource of the given type
in the werkout server. (NOTE: type
can be only "partners" or "data")
PUT /resources/partners/id
- Update a partner resources state value
GET /resources
- Returns all resources registered in the Werkout Server
GET /resources/type
- Returns all resources of a given type
GET /resources/type/id
- Returns a resource of the given type
and id
Operations API
This API is used by the partners in order to communicate information after being instructed to perform an action by an instructor
POST /operations
- Used to call a method on a partner (Body should contain a JSON object with the partner ID and method name)
PUT /operations/id
- Used to update the results of a method run by the partner.
Postman
For information on body types and general API usage, we suggest you load the postman collection provided by the package werkout-server.postman_collection.json
into the Postman application.