Skip to content

Commit

Permalink
fix: use public bucket url
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Nov 6, 2024
1 parent a5af9d7 commit 9ba2a24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
19 changes: 0 additions & 19 deletions modules/runtime/server/slides.ts

This file was deleted.

13 changes: 6 additions & 7 deletions modules/slides.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import crypto from 'node:crypto'
import { addServerHandler, createResolver, defineNuxtModule, updateRuntimeConfig, useRuntimeConfig } from 'nuxt/kit'
import { defineNuxtModule, updateRuntimeConfig, useNuxt, useRuntimeConfig } from 'nuxt/kit'
import { $fetch } from 'ofetch'
import { S3Client, PutObjectCommand, HeadObjectCommand } from '@aws-sdk/client-s3'

Expand All @@ -8,8 +8,8 @@ export default defineNuxtModule({
name: 'slides',
},
async setup () {
const nuxt = useNuxt()
const config = useRuntimeConfig()
const resolver = createResolver(import.meta.url)

if (!config.github.token) return

Expand Down Expand Up @@ -61,11 +61,10 @@ export default defineNuxtModule({
await s3Client.send(new PutObjectCommand({ Bucket, Key, Body: Buffer.from(file) }))
}

// add handler for this endpoint
addServerHandler({
handler: resolver.resolve('./runtime/server/slides'),
route: `/slides/${Key}`,
})
nuxt.options.routeRules ||= {}
nuxt.options.routeRules[`/slides/${Key}`] = {
redirect: `https://slides.roe.dev/${Bucket}/${Key}`,
}
}
},
})
Expand Down

0 comments on commit 9ba2a24

Please sign in to comment.