-
Notifications
You must be signed in to change notification settings - Fork 0
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
New URL structure #24
New URL structure #24
Conversation
Is this a real-world case? One possible scenario could be to always look up the entire path to see if it exists, and if so, determine that the original file is requested without conversion. It will make all requests slower however... (it will also be harder to unit test because this logic is currently separate from looking up anything on S3, but that's another problem). |
399c2f3
to
80c536f
Compare
80c536f
to
c4b5ccf
Compare
I've put it together. Probably a lot to improve, but I think it's a good moment for a first review. Naming must be checked. And I've replaced the pipe with an underscore. The pipe caused an error somewhere in AWS, but the moment the pipe was in the URL the Lambda function isn't even executed. I've a deploy version (MLK staging) for testing: https://7ij2wddzl7.execute-api.eu-west-1.amazonaws.com/staging/resize?key=/scaled/convert:webp_height:100/mock/event-1.jpg.webp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Looking good, nice to clean some things up.
I'm having trouble reading the getInputFormat
and getOutputFormat
functions. Not because they're written unclearly, but because that stupid parameter just throws me off.
I'll try to think of a way to make this more explicit.
it("Return the right input format", function () { | ||
expect(getInputFormat("foo.jpg")).toBe("jpg"); | ||
expect(getInputFormat("foo.jpg.png")).toBe("png"); | ||
expect(getInputFormat("foo.jpg.png", "png")).toBe("jpg"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this test makes me realize I find the signature of getInputFormat
very difficult to read. This assertion was really surprising to me.
But I understand how it works when combined with the options string. I'll try to think of a way to make this API a little clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you come up with something? I tried to find another name, but keep on circling around "format" and "extension". They are both the same, but getInputExtension
isn't better IMO. Or maybe something with "source" and "destination" to ditch the word "input" might do the trick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, let's keep it like this.
Maybe in the future I'll find some inspiration.
|
||
const sharp = SHARP(body).withMetadata().resize(resizeOptions); | ||
|
||
if (outputFormat) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is outputFormat
ever undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a function argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
3589d3f
to
c0fabeb
Compare
@harmenjanssen Ik krijg die tests niet werkend op Ubuntu, lokaal wel. In de README staat iets over shard. Ik heb geprobeerd |
Hmm, vaag.
Dit zodat de binaries gebuild worden als Linux x64 versies. |
- Add support for parameters other then width and height - 500x500 becomes widht:500|height:500 - Add convert parameter to solve the issue with double extensions in the original file. (the reason this change has been made). - Upgrade Jest - Update README.md - Add CHANGELOG.md
Image created on Linux aren't the same as on MacOS. So when creating fixtures you have to do that on MacOS.
6c5d263
to
faf43a7
Compare
I really don't understand how the test fixtures have ever worked cross-platform. I've fixed it by running the tests on MacOS runners. Developers working on Linux have a problem, but I invite them to come up with a better solution. |
@harmenjanssen Can you look at the last commit, changing to a MacOS runner. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've thought about this, and came to the following conclusion: when I started this project I deployed from local to Lambda using Serverless.
That meant my local binaries were shipped to AWS and quickly turned out to be incompatible.
That's when I found that one-liner that forces the Linux versions to be installed, even when on MacOS. (and apparently this was no problem when running this on MacOS)
This way I could ship the correct binaries to AWS from my local machine.
However, I think the upgrade in Sharp introduced an incompatibility. I also see you changed some of the fixtures in this PR. Not sure why that is, did you re-generate them?
In any case: I'm totally fine with running the tests on a MacOS runner.
As long as we the tests are consistent between developer machines and CI, it's fine.
As long as a working version is deployed to AWS, it's fine.
It's too bad you can't deploy from your local machine, but that's not a hard requirement. (and maybe Serverless has a solution for this, come to think of it. Incompatible binaries are not uncommon in NPM land)
Yes because my tests failed locally.
Changing I'm going to merge this PR. It has taken way to much time. Maybe we find a better solution in the future. |
This is an exciting case for the image scaler: double extensions which are both an allowed output type:
foo.jpg.jpg
. This forces the original file (foo.jpg
) to be converted to JPG. But the original file isfoo.jpg.jpg
. I don't think we have a way to determine the original file name. It could be both.Let's discus.