kwicherbelliaken / bad-reviews-make-good-movies

0 stars 0 forks source link

[FEATURE]: add integration with Letterbxd API #6

Closed slackermorris closed 1 year ago

slackermorris commented 1 year ago

https://api-docs.letterboxd.com/

slackermorris commented 1 year ago

This is the endpoint that I am intending to hit:

slackermorris commented 1 year ago

It seems for each request that I have to create a salted string and sign the request with it:

slackermorris commented 1 year ago

Perhaps I can use this to hardcode the values before I install any dependencies to manage the same salting:

slackermorris commented 1 year ago

I need access to the API. If I don't get it then I will have to parse the RSS feed. Yikes.

slackermorris commented 1 year ago

The API is in beta. I need to request access to it. Alternatively, I can export and import my data using CSV. This truly might be my only option.

Read Path

I would have to make an export of my data. It's gzipped so I would have to unzip it and then file search it. Since I don't have access to the API I would have to perform this action via a headless browser or something similar.

Write Path

I would have to do the above in reverse. This would be hugely problematic. Again, I'd have to use a headless browser or equivalent.

Something like an on demand headless browser that assumes my credentials and logs into Letterboxd and performs the relevant actions. This seems a little strange.

slackermorris commented 1 year ago

I am thinking that it might be more beneficial to stand up my own datasource. Likely using a Serverless Stack.

I guess one of my questions at the moment will be whether or not I want to include this code in my existing astro project or not.

  1. Can I use Astro with the AWS SDK?

Yeah, it feels like it would be way easier to stand a Serverless Stack project up and just expose endpoints off it.

slackermorris commented 1 year ago

This might not be relevant, but it seems interesting:

slackermorris commented 1 year ago

For this to work I likely have to enable SSR as well. I think this requires installing an adapter.

Yeah, the content is dynamic. There is no way that I can use SSG for this.

I should be making use of SSR adapters. Or a different framework.

slackermorris commented 1 year ago

Regardless of whether I can use the aws-sdk in the current Astro project or not, those resources I am interfacing with need to be on AWS somehow. So, my best bet is to write my own backend. I'll use a Serverless Stack.

slackermorris commented 1 year ago

Lol, this is the exact adapter I need:

Drop a deployment solution (Serverless Stack, AWS) into your chosen framework

It scaffolds a monorepo. We can write serverless functions.

slackermorris commented 1 year ago

This is a tutorial that involves building a SST project:

slackermorris commented 1 year ago

I think it will be a good idea to review the permissions specified here.

TBH I think this is a whole other thing to be done. I need to pull my head around IAM policies. I think once I do this that using something like this: an analyser of AWS activity to determine policies for a user, would be the best thing to use.

Also, refer to this, perhaps set up a DynamoDB and try to set an item into it.

slackermorris commented 1 year ago

We have deployment.

Screen Shot 2023-08-12 at 10 31 23 AM
slackermorris commented 1 year ago

I should stand a Dynamo table up. See how it feels. I think it is really important to better understand DynamoDB and how it works to leverage how it stores data.

slackermorris commented 1 year ago

This is what I am referring to.

slackermorris commented 1 year ago
Screen Shot 2023-08-12 at 11 49 07 AM

This was really helpful for setting the table up. But I think I need something a little more bespoke Astro (setting shit in front matter, etc).

This gives a better explanation of why this project structure is employed.

slackermorris commented 1 year ago

Hmmm. It seems like my project structure is a bit amiss.

Screen Shot 2023-08-12 at 12 06 49 PM

SST and Astro tutorial.

slackermorris commented 1 year ago

Actually, I don't think I need to make any changes. As per.

Ahhh 👇. I see now.

Screen Shot 2023-08-12 at 12 50 35 PM
slackermorris commented 1 year ago

I am referring to this.

https://pieg1bg8t8.execute-api.ap-southeast-2.amazonaws.com

Screen Shot 2023-08-12 at 12 42 02 PM
slackermorris commented 1 year ago

I got the table stood up.

Screen Shot 2023-08-12 at 12 45 33 PM
slackermorris commented 1 year ago

I think I need to get rid of the bottom two resources. I don't deploy this to this region anymore. It is an artefact of first deployments.

Screen Shot 2023-08-12 at 3 19 00 PM
slackermorris commented 1 year ago

This is how to read from Dynamo using a Lambda we have written in the packages > fns directory. Then I'm not sure how Astro can consume this endpoint.

I wonder if we can use the aws-sdk > DynamoDB client directly in the front matter of the Astro pages?

slackermorris commented 1 year ago

There is potential here to integrate ElectroDB. But I think I should consider this someplace else down the line.

slackermorris commented 1 year ago

I really need to review the "Architectural Section" of this video to better understand what is happening here.

This is also a great resource.

slackermorris commented 1 year ago

This helped me to understand how to test lambdas locally.

slackermorris commented 1 year ago

This is what I am using to create the POST endpoint for creating a user.

I'll then need to integrate this with the Astro project. I think I can make a call to the endpoint in the front matter.

slackermorris commented 1 year ago
Screen Shot 2023-08-13 at 11 50 22 AM

I had all my .sst files checked in.

This helped me confirm that they shouldn't be.

slackermorris commented 1 year ago

This is handy but it is super outdated as well.

slackermorris commented 1 year ago

These two are equivalent when recommending how to add consume DynamoDB in a lambda handler.

slackermorris commented 1 year ago

What is npx sst dev used for?

Screen Shot 2023-08-13 at 1 55 08 PM

What is sst bind used for?

Screen Shot 2023-08-13 at 1 54 42 PM
slackermorris commented 1 year ago

I would really like to clear up the scripts section. Get things to run as pre scripts/sequentially.