release: PicHost v1.0.0

Multi-user image hosting with RBAC, upload preferences, and admin settings.
This commit is contained in:
O96u committed 2026-08-22 14:36:57 +08:00
commit bc4cba7e52
115 files changed
+26508

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { clientIp, logInfo } from '../utils/logger'
/**
* 只记录 /api/*,避免 /images、/twikoo 直链刷屏。
*/
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('request', (event) => {
event.context._reqStartedAt = Date.now()
})
nitroApp.hooks.hook('afterResponse', (event) => {
const path = getRequestURL(event).pathname
if (!path.startsWith('/api/')) return
// 高频探测接口降噪
if (path === '/api/auth/me' || path === '/api/auth/config') return
const method = getMethod(event)
const status = getResponseStatus(event)
const started = event.context._reqStartedAt as number | undefined
const ms = started ? Date.now() - started : undefined
logInfo(`${method} ${path}`, {
status,
ms,
ip: clientIp(event)
})
})
})
+20
View File
@@ -0,0 +1,20 @@
import { getDataDir } from '../utils/storage'
import { runAutoDeleteCleanup } from '../utils/auto-delete'
import { logInfo } from '../utils/logger'
export default defineNitroPlugin(() => {
const port = process.env.NITRO_PORT || process.env.PORT || '6892'
logInfo('PicHost starting', {
port,
dataDir: getDataDir(),
nodeEnv: process.env.NODE_ENV || 'development',
imageBaseUrl: process.env.IMAGE_BASE_URL || '(request origin)',
logLevel: process.env.LOG_LEVEL || 'info'
})
void runAutoDeleteCleanup().then((result) => {
if (!result.skipped && (result.deleted > 0 || result.failed > 0)) {
logInfo('startup auto-delete', { ...result })
}
})
})