Closed GabuTheDev closed 9 months ago
I am sorry if this does not fit your codebase, I wanted to give it a try and code this but I found myself lost in the files.
seems easy enough to implement?
type parametersType = { clientId?: number, clientSecret?: string, redirectUri?: string, scope?: auth_scopes, state?: string, username?: string, password?: string }
type methodType = "lazer" | "stable" | "cli"
export async function login(method: methodType, { clientId, clientSecret, redirectUri, scope, state, username, password }: parametersType){
switch(method){
case "lazer":
return (await login_lazer(username, password))
case "stable":
return (await login_stable(clientId, clientSecret, scope))
case "cli":
return (await authorize_cli(clientId, clientSecret, redirectUri, scope, state))
default:
throw new Error("blah b lah...")
}
}
will PR when I catch a break. Writing this from my work computer XD Also would be useful to add in checks to make sure parameters are filled appropriately
like that ? https://github.com/cyperdark/osu-api-extended/commit/4be0e033b7d5454cd779e6ad4f99c1cc96da9930
My initial proposal was to have the method value detached from the passing object, as a different parameter.
It's done like that to have autocomplition like this
https://github.com/cyperdark/osu-api-extended/assets/21735205/351c9232-3e3d-42dd-9d70-32321dd23d13
you can technically still have that without including it in the object. Most IDEs allow you to simply click ctrl+space to let you autocomplete
yeah but:
yea, that's what I was saying. btw your gif doesn't work
yea, that's what I was saying. btw your gif doesn't work
it doesn't load? lemme upload it again:
works now yea
@GabuTheDev look at video again, after i specify a method autocomplition will show parameters that can be specified for this method, rest will be hidden
@GabuTheDev look at video again, after i specify a method autocomplition will show parameters that can be specified for this method, rest will be hidden
Whatever, just push this pr.
Description
Here are some benefits of upgrading:
Examples:
A pretty good example is the auth function.
with this kind of upgrade, you can also opt-in for a single auth function.
You can now merge
auth.login()
,auth.login_lazer()
&auth.authorize_cli()
into 1 function:meaning:
method="stable"
you would needclient_id
,client_secret
&scopes
.method="lazer"
you would needusername
&password
.method="cli"
you would needclient_id
,client_secret
,callback_url
&scopes
or you could give up on the method property entirely. here"s a code example: