I just have created a small POC (proof of concept) of a simple API to create scheduled triggers and receive postbacks with their relative payloads. I'll explain how it works and afterwards, I want to heard your opinion, ok?
//resources
POST https://apis.smallorange.co/cron/triggers
PUT https://apis.smallorange.co/cron/triggers/:id
// body
{
schedulerMode: 'relative' | 'absolute',
schedulerValue: 1, // schedulerMode === 'relative' ? value in minutes : 'absolute timestamp'
payload: {a: 1}, // any object which will be the postback's body
repeatInterval: 1 | null, // value in minutes to repeat the trigger
repeatTimes: 5 | null, // times to repeat the trigger
repeatUntil: null, // absolute timestamp to determine maximum TTL
url: 'https://requestb.in/uq74wzuq', // url to post when the trigger have runned
}
// See postbacks at:
// https://requestb.in/uq74wzuq?inspect
curl -X POST \
https://apis.smallorange.co/cron/triggers \
-H 'authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lc3BhY2UiOiJ0ZXN0Iiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNDk1NTg2NTg4fQ.p_I_vIFR0i6_XUVOk3Q3XRFYWqA0li_iwij7YEfrOKA' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"url": "https://requestb.in/uq74wzuq",
"schedulerValue": 1,
"repeatTimes": 10,
"repeatInterval": 1,
"payload": {
"hey": "there"
}
}'
curl -X PUT \
https://apis.smallorange.co/cron/triggers/cj31yc6m8000001p2c26w3r3a \
-H 'authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lc3BhY2UiOiJ0ZXN0Iiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNDk1NTg2NTg4fQ.p_I_vIFR0i6_XUVOk3Q3XRFYWqA0li_iwij7YEfrOKA' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"url": "https://requestb.in/uq74wzuq",
"schedulerValue": 1,
"repeatTimes": 5,
"repeatInterval": 1,
"payload": {
"hello": "world"
}
}'