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

Remove or make class pattern optional #12

Open
tomfa opened this issue May 24, 2021 · 0 comments
Open

Remove or make class pattern optional #12

tomfa opened this issue May 24, 2021 · 0 comments

Comments

@tomfa
Copy link
Owner

tomfa commented May 24, 2021

Use same pattern as e.g. Sentry.

import Vailable from 'vailable';

// Instead of 
const api = new Vailable({ ... });
api.findResources();

// Do
Vailable.login({ username, password});  // Only require to be run somewhere in the application first
// Alternatively
Valiable.authenticate({ token });

Vailable.isAuthenticated() // true/false
Vailable.findResources();

We can do this by storing auth outside the class instance as a default fallback if class itself does not have auth + making all methods static (can static methods use this?) – By keeping the class we can then also allow user to make multiple instances of a client for different users (low pri, I'm unsure of the usecase, but there probably is one)

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

No branches or pull requests

1 participant