roccomuso / node-webhooks

:arrow_right_hook: Node.js module to create and trigger your own webHooks.
190 stars 47 forks source link

Static DB #6

Closed simonschllng closed 6 years ago

simonschllng commented 7 years ago

I am looking to implement webhook calls. I don't need a dynamic DB so I would not make use of add, etc. Therefor it would be great to be able to use a static DB, checked into revision control along the project. What is the json syntax of the current db? Is the syntax stable?

EDIT:

Ok, found it. Scrolled down too fast.

DB Structure Example:
{
    "shortname1": [url1, url2, ...],
    "shortname2": [url3, url4, ...],
     ...
     ...
    "shortnameX": [urlZ, ...]
}

Would be nice to be able to set this as plain object.

roccomuso commented 7 years ago

Ok, let's talk about this. You basically mean adding a new method called webHooks.update(OBJ); ? this can be easily implemented.

Right now you can pass a JSON file with pre-existing content:

var webHooks = new WebHooks({
    db: './webHooksDB.json' // json file that store webhook URLs
});

With an update method you would be able to add a JSON object programmatically to the DB.

simonschllng commented 7 years ago

What I actually want to do is simply:

var obj = { hooks: [{}, {}] }; // complete config / in memory db

var webHooks = new WebHooks(obj);

I don't want to give a json file at all.

roccomuso commented 7 years ago

So we're referring to the in-memory storage: #4 . These new persistence methods are under development. But the code should be refactored for this improvements. PR are more than welcome.

eloquence commented 6 years ago

@simonschllng If this is still relevant, you may be interested in https://github.com/roccomuso/node-webhooks/pull/16

roccomuso commented 6 years ago

InMemory storage shipped with v1.3.0.