mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
feat(admin): add manual R2 stats refresh endpoint/button and share in-memory storage snapshot cache
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { auth } from '@/lib/auth';
|
||||
import { apiErrors, successResponse } from '@/lib/api-response';
|
||||
import { refreshR2StorageSnapshot } from '@/lib/admin-stats';
|
||||
|
||||
export async function POST() {
|
||||
try {
|
||||
const session = await auth();
|
||||
if (!session?.user?.isAdmin) {
|
||||
return apiErrors.forbidden('Admin access required');
|
||||
}
|
||||
|
||||
const refreshedAt = await refreshR2StorageSnapshot();
|
||||
|
||||
return successResponse({
|
||||
ok: true,
|
||||
refreshedAt,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error refreshing R2 admin stats cache:', error);
|
||||
return apiErrors.internalError('Failed to refresh R2 stats');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user