feat: Add image transforms

This commit is contained in:
Wanjohi
2025-06-05 03:39:15 +03:00
parent 0124af1b70
commit a47dc91b22
12 changed files with 305 additions and 192 deletions

View File

@@ -4,6 +4,7 @@ import { domain } from "./dns";
import { secret } from "./secret";
import { cluster } from "./cluster";
import { postgres } from "./postgres";
import { storage } from "./storage";
export const apiService = new sst.aws.Service("Api", {
cluster,
@@ -12,6 +13,7 @@ export const apiService = new sst.aws.Service("Api", {
link: [
bus,
auth,
storage,
postgres,
secret.SteamApiKey,
secret.PolarSecret,

View File

@@ -1,23 +1,14 @@
import {api} from "./api"
import { domain } from "./dns";
import { storage } from "./storage";
const cache = new sst.cloudflare.Kv("ImageCache");
const bucket = new sst.cloudflare.Bucket("ImageBucket");
const imageRouter = new sst.aws.Router("ImageRouter", {
routes: {
"/*": {
bucket: storage,
rewrite: { regex: "^/([a-zA-Z0-9_-]+)$", to: "/images/$1" },
},
},
});
export const imageCdn = new sst.cloudflare.Worker("ImageCDN", {
url: true,
domain: "cdn." + domain,
link: [bucket, cache, imageRouter],
link: [bucket, cache, api],
handler: "packages/functions/src/images/index.ts",
});

View File

@@ -1,3 +1 @@
export const storage = new sst.aws.Bucket("Storage",{
access: "cloudfront",
});
export const storage = new sst.aws.Bucket("Storage");