Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom api action #9

Open
joshp23 opened this issue Nov 29, 2016 · 1 comment
Open

custom api action #9

joshp23 opened this issue Nov 29, 2016 · 1 comment
Labels

Comments

@joshp23
Copy link

joshp23 commented Nov 29, 2016

As it is trivial to create an api action for YOURLS, it would novel if there was an equally trivial way to define custom api actions for yourls-api.js. Is there such a hook?
edit and delete seem particularly handy.

@neocotic
Copy link
Owner

@joshp23 I'm in the process of a bit of refactoring relating to how the library makes requests (see #6) which might make this possible since the sendRequest method will be exposed. But it's really just a matter of importing and modifying the yourls object to add the methods you want. If they're URL-specific, you might have more trouble since the URL constructor isn't exposed, but I guess you could do something hacky like this:

yourls.yourCustomAction = function() {
    // ...

    return this
}

var URL = yourls.url('_').constructor
URL.prototype.yourCustomAction = function() {
    // ...

    return this
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants