Skip to content

Commit

Permalink
rename s3 bucket env to be more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikskog committed May 6, 2024
1 parent 7d2e7c6 commit 086827f
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:
FAGKOM_STRIPE_PUBLIC_KEY: ${{ secrets.FAGKOM_STRIPE_PUBLIC_KEY }}
FAGKOM_STRIPE_SECRET_KEY: ${{ secrets.FAGKOM_STRIPE_SECRET_KEY }}
FAGKOM_STRIPE_WEBHOOK_SECRET: ${{ secrets.FAGKOM_STRIPE_WEBHOOK_SECRET }}
S3_BUCKET_MONOWEB: ${{ secrets.S3_BUCKET_MONOWEB }}
STATIC_ASSETS_BUCKET: ${{ secrets.STATIC_ASSETS_BUCKET }}
GTX_AUTH0_CLIENT_ID: ${{ secrets.GTX_AUTH0_CLIENT_ID }}
GTX_AUTH0_CLIENT_SECRET: ${{ secrets.GTX_AUTH0_CLIENT_SECRET }}
GTX_AUTH0_ISSUER: ${{ secrets.GTX_AUTH0_ISSUER }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ export const useCreateOfflineModal = () => () =>
modal: "offline/create",
title: "Opprett ny Offline",
innerProps: {},
size: "lg",
size: "xl",
})
2 changes: 1 addition & 1 deletion apps/dashboard/src/utils/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ export async function s3UploadFile(file: File, fields: Record<string, string>, u
}

export function buildAssetUrl(key: string) {
return `${env.NEXT_PUBLIC_S3_BUCKET_MONOWEB}/${key}`
return `https://s3.eu-north-1.amazonaws.com/${env.NEXT_PUBLIC_STATIC_ASSETS_BUCKET}/testing/${key}`
}
4 changes: 2 additions & 2 deletions packages/core/src/modules/asset/asset-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export class AssetServiceImpl implements AssetService {
const generatedKey = crypto.randomUUID() + filename
const encodedKey = encodeS3URI(generatedKey)
const presignedUrl = await this.s3Repository.createPresignedPost(
env.S3_BUCKET_MONOWEB,
`testing/${encodedKey}`,
env.STATIC_ASSETS_BUCKET,
`${encodedKey}`,
mimeType,
maxSizeMB
)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/modules/external/s3-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class S3RepositoryImpl implements S3Repository {
): Promise<PresignedPost> {
return await _createPresignedPost(this.s3Client, {
Bucket: bucket,
Key: filepath,
Key: `testing/${filepath}`,
Fields: {
"content-type": mimeType,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/env/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export declare type EnvironmentKeys =
| "GTX_AUTH0_ISSUER"
| "NEXT_PUBLIC_NODE_ENV"
| "NEXT_PUBLIC_VERCEL_URL"
| "NEXT_PUBLIC_S3_BUCKET_MONOWEB"
| "NEXT_PUBLIC_STATIC_ASSETS_BUCKET"
| "NEXTAUTH_SECRET"
| "NODE_ENV"
| "S3_BUCKET_MONOWEB"
| "STATIC_ASSETS_BUCKET"
| "TRIKOM_STRIPE_PUBLIC_KEY"
| "TRIKOM_STRIPE_SECRET_KEY"
| "TRIKOM_STRIPE_WEBHOOK_SECRET"
Expand Down
8 changes: 4 additions & 4 deletions packages/env/src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ export const createEnvironment = (skipValidation = false) =>
FAGKOM_STRIPE_SECRET_KEY: environmentVariableSchema,
FAGKOM_STRIPE_WEBHOOK_SECRET: environmentVariableSchema,

S3_BUCKET_MONOWEB: environmentVariableSchema,
STATIC_ASSETS_BUCKET: environmentVariableSchema,
},
client: {
NEXT_PUBLIC_NODE_ENV: environmentVariableSchema.optional(),
NEXT_PUBLIC_VERCEL_URL: environmentVariableSchema.optional(),
NEXT_PUBLIC_S3_BUCKET_MONOWEB: environmentVariableSchema.optional(),
NEXT_PUBLIC_STATIC_ASSETS_BUCKET: environmentVariableSchema.optional(),
},
runtimeEnv: {
DASHBOARD_AUTH0_CLIENT_ID: process.env.DASHBOARD_AUTH0_CLIENT_ID,
Expand Down Expand Up @@ -68,11 +68,11 @@ export const createEnvironment = (skipValidation = false) =>
FAGKOM_STRIPE_SECRET_KEY: process.env.FAGKOM_STRIPE_SECRET_KEY,
FAGKOM_STRIPE_WEBHOOK_SECRET: process.env.FAGKOM_STRIPE_WEBHOOK_SECRET,

S3_BUCKET_MONOWEB: process.env.S3_BUCKET_MONOWEB,
STATIC_ASSETS_BUCKET: process.env.STATIC_ASSETS_BUCKET,

NEXT_PUBLIC_NODE_ENV: process.env.NODE_ENV,
NEXT_PUBLIC_VERCEL_URL: process.env.VERCEL_URL,
NEXT_PUBLIC_S3_BUCKET_MONOWEB: process.env.NEXT_PUBLIC_S3_BUCKET_MONOWEB,
NEXT_PUBLIC_STATIC_ASSETS_BUCKET: process.env.NEXT_PUBLIC_STATIC_ASSETS_BUCKET,
},
skipValidation,
})
Expand Down
115 changes: 5 additions & 110 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
}
},
"globalEnv": [
"S3_BUCKET_MONOWEB",
"STATIC_ASSETS_BUCKET",
"NODE_ENV",
"WEB_AUTH0_CLIENT_ID",
"WEB_AUTH0_CLIENT_SECRET",
Expand Down

0 comments on commit 086827f

Please sign in to comment.