0.0.6 • Published 9 years ago

roadiejs-counter v0.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

roadiejs-counter

A plugin for RoadieJS

Provides API endpoints and data-tasks for auto-incrementing number sequences.

Contents

API

getCurrentAndIncrement

Returns the current value of the specified counter, and then increments it ready for the next request.

Request

GET /counters/:ns/:bp/:bv/:counterName

ParameterNotes
counterNameName of the counter to get current value of and then increment
Response

Status 200

{
  "value": 5
}
NameNotes
valueThe integer value from the counter.

getCurrent

Returns the current value of the specified counter, without incrementing it.

Request

GET /counters/:ns/:bp/:bv/:counterName/current

ParameterNotes
counterNameName of the counter to get the current value of
Response

Status 200

{
  "value": 6
}
NameNotes
valueThe integer value from the counter.

setCurrent

Sets the current value of the specified counter to the provided value.

Request

PUT /counters/:ns/:bp/:bv/:counterName/current

ParameterNotes
counterNameName of the counter to set the value of
Body
{
  nextValue: 5
}
NameNotes
nextValueRequired. The value to which the counter should be set (i.e. the next value a subsequent getCurrent or getCurrentAndIncrement will return).
Response

Status 200


deleteCounter

Deletes the specified counter (any subsequent calls refering to it will then cause errors).

Request

DELETE /counters/:ns/:bp/:bv/:counterName

ParameterNotes
counterNameName of the counter to delete

Elements

counter

Registers a RoadieJS counter (useful for auto-incrementing ids - just like a database sequence).

Example
{
  "element": "counter",
  "id": "counterTest",
  "config": {
    "startWith": 10,
    "incrementBy": 1
  }
}
Config
NameTypeNotes
startWithnumberThe first number out the counter (defaults to 1 if not supplied).
incrementBynumberHow much to subsequently increase the counter by after the current value is returned (defaults to 1 if not supplied).

Activities

setValueFromCounter

Sets a value on the target activity to a counter's current value, and then increments.

Example
{
  "element": "activity",
  "id": "setEmployeeNumber",
  "path": "employeeNumber",
  "config": {
    "activityType": "setValueFromCounter",
    "config": {
      "counterId": "employeeNumberCounter",
      "targetActivityId": "createNewEmployeeUi",
      "path": "employeeNumber"
    }
  }
}
Config
NameTypeNotes
counterIdstringName of the counter that should provide the value.
targetActivityIdstringName of an activity in the current flow where the value should be set.
pathstringA key name to store the counter's thay, will be set target activity's data object.

License

MIT

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago