Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
enapupe committed Nov 3, 2023
1 parent 40f6712 commit 11c38d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish to dockerhub and perform a deploy on cloud run

on:
push:
branches: ["develop"]
branches: ["develop", "staging"]

jobs:
build-and-push-image:
Expand Down
19 changes: 10 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ app.get("*", async (req, res) => {
const quality = Number(searchParams.get("q")) || 90;
const width = Number(searchParams.get("w")) || undefined;
const height = Number(searchParams.get("h")) || undefined;
const format = getFormat(webp, avif);
// const format = getFormat(webp, avif);
const format = "jpeg";

const { data, status } = await getImage(href);
if (status > 399) {
Expand All @@ -45,16 +46,16 @@ app.get("*", async (req, res) => {
.send("upstream server did not respond with a valid status code");
}

const processedImage = await sharp(data)
.rotate()
.resize({ width, height })
.toFormat(format, { quality });

return res
res
.set("Cache-Control", "public, max-age=15552000")
.set("Vary", "Accept")
.type(`image/${format}`)
.send(await processedImage.toBuffer());
.type(`image/${format}`);

sharp(data)
.rotate()
.resize({ width, height })
.toFormat(format, { quality, progressive: true })
.pipe(res);
} catch (e) {
return res.status(500).send(JSON.stringify(e));
}
Expand Down

0 comments on commit 11c38d3

Please sign in to comment.