medallyon / grogsile.org-archive

The (old) Official Bot For ESO International
https://discordapp.com/invite/0jGipOeWW06jNmlL
Apache License 2.0
1 stars 0 forks source link

Create individual end-points for HTTP methods to characters & guilds #15

Closed medallyon closed 7 years ago

medallyon commented 7 years ago

Instead of POSTing to /new every time and basing the actions on the content, create an endpoint for characters (perhaps something like /api/esoi/users/characters) to which one can POST, PATCH, DELETE, etc.

same for guilds

medallyon commented 7 years ago

End-point for users will be: api.grogsile.me/esoi/users End-point for characters will be api.grogsile.me/esoi/users/:user/characters End-point for (in-game) guilds will be api.grogsile.me/esoi/guilds

medallyon commented 7 years ago

End-points for the authenticated user will be replaced with @me instead of :user example: api.grogsile.me/esoi/users/@me

medallyon commented 7 years ago

As I'm using ajax for the form submission at /new?type=character, it becomes seemingly impossible to use the authenticated user object for API authentication.

medallyon commented 7 years ago

The only reason I'm using ajax in the first place is because of the avatar, anyway. I will see if there's a way for me to convert the avatar data into a hidden base64 string that will be sent with the normal form.

medallyon commented 7 years ago

It appears that when trying to fill an HTML input type=text with the base64 URL, the browser window freezes and eventually kills itself. I'm now thinking of using a back-end image cropping library to crop and save the image.

medallyon commented 7 years ago

I had to shift the end-points to https://esoi.grogsile.me/api/:... because the authenticated user object is not transmitted with the request over to another subdomain (such as https://api.grogsile.me/).

Everything works now, except for the images (images are saved as empty .png files).