Publish Docker image / build-and-push (push) Canceled after 0s
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
Multi-user image hosting with RBAC, upload preferences, and admin settings.
16 lines
486 B
TypeScript
16 lines
486 B
TypeScript
import { requestPathToImageKey, serveImageByKey } from '../utils/serve-image'
|
||
|
||
/**
|
||
* 仅当路径像图片 key({type}/YYYY/MM/file.ext)时才接管。
|
||
* 其它请求(/_nuxt、/api、页面)原样放行。
|
||
*/
|
||
export default defineEventHandler(async (event) => {
|
||
const method = getMethod(event)
|
||
if (method !== 'GET' && method !== 'HEAD') return
|
||
|
||
const key = requestPathToImageKey(getRequestURL(event).pathname)
|
||
if (!key) return
|
||
|
||
return serveImageByKey(event, key)
|
||
})
|