From 55ead435484488d412a1b803830dec34590c57db Mon Sep 17 00:00:00 2001 From: Nexmoe <16796652+nexmoe@users.noreply.github.com> Date: Sat, 4 May 2024 11:13:49 +0800 Subject: [PATCH] S3 bucket (#120) * feat: Add S3 integration for modules Add new function `allS3` to upload module images to S3 bucket if not already uploaded. Update the Nuxt config to include S3 credentials. Update module gallery component to display S3 image if available. Update scheduler to run `allS3` every 3 hours. # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch main # Your branch is ahead of 'origin/main' by 1 commit. # (use "git push" to publish your local commits) # Changes to be committed: # modified: server/flowing.ts # modified: nuxt.config.ts # modified: components/module/Gallery.vue # modified: server/plugins/scheduler.ts # modified: prisma/schema.prisma # modified: .gitignore # modified: pnpm-lock.yaml * feat: Upload images to S3 and log success/error messages Uploaded images to S3 in 'allS3' function and added success and error messages using 'consola'. Added conditional check in 'startScheduler' to only run 'allS3' if S3 access key is provided. --- .gitignore | 2 + components/module/Gallery.vue | 4 +- components/public/Loading.vue | 2 +- nuxt.config.ts | 9 +- package.json | 1 + pnpm-lock.yaml | 1334 +++++++++++++++++++++++++++++++-- prisma/schema.prisma | 1 + server/flowing.ts | 32 + server/plugins/scheduler.ts | 12 +- server/s3.ts | 49 ++ 10 files changed, 1381 insertions(+), 65 deletions(-) create mode 100644 server/s3.ts diff --git a/.gitignore b/.gitignore index 239c57c..65629a4 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,5 @@ sw.* # Auto generate on postinstall step auto-imports.d.ts components.d.ts + +server/api/test.ts \ No newline at end of file diff --git a/components/module/Gallery.vue b/components/module/Gallery.vue index 2c5ff55..7a0bfbb 100644 --- a/components/module/Gallery.vue +++ b/components/module/Gallery.vue @@ -11,6 +11,8 @@ interface Props { } const props = defineProps() + +const cover = props.module.s3Key ? `https://space.r2.102415.xyz/${props.module.s3Key}` : props.module.image