refactor(admin) : remove auto detect followers and use validPlatforms instead
This commit is contained in:
@@ -1,18 +1,11 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import { revalidateTag } from "next/cache";
|
import { revalidateTag } from "next/cache";
|
||||||
|
const validPlatforms = ["youtube", "roblox", "discord", "tiktok"];
|
||||||
import { readdirSync } from "fs";
|
|
||||||
import { join } from "path";
|
|
||||||
|
|
||||||
export async function refetchPlatform(
|
export async function refetchPlatform(
|
||||||
platform: string
|
platform: string
|
||||||
): Promise<{ count: number | null }> {
|
): Promise<{ count: number | null }> {
|
||||||
// Validate platform against actual files to prevent path traversal
|
|
||||||
const dir = join(process.cwd(), "lib", "followers");
|
|
||||||
const validPlatforms = readdirSync(dir)
|
|
||||||
.filter((f) => f.endsWith(".ts") && f !== "index.ts")
|
|
||||||
.map((f) => f.replace(".ts", ""));
|
|
||||||
|
|
||||||
if (!validPlatforms.includes(platform)) {
|
if (!validPlatforms.includes(platform)) {
|
||||||
throw new Error("Invalid platform");
|
throw new Error("Invalid platform");
|
||||||
|
|||||||
@@ -1,17 +1,9 @@
|
|||||||
import { AdminShellServer } from "@/components/admin-shell-server";
|
import { AdminShellServer } from "@/components/admin-shell-server";
|
||||||
import { readdirSync } from "fs";
|
|
||||||
import { join } from "path";
|
|
||||||
import { BackendClient } from "./client";
|
import { BackendClient } from "./client";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
const platforms = ["youtube", "roblox", "discord", "tiktok"];
|
||||||
|
|
||||||
export default async function BackendPage() {
|
export default async function BackendPage() {
|
||||||
// Auto-discover platform files from lib/followers/
|
|
||||||
const dir = join(process.cwd(), "lib", "followers");
|
|
||||||
const platforms = readdirSync(dir)
|
|
||||||
.filter((f) => f.endsWith(".ts") && f !== "index.ts")
|
|
||||||
.map((f) => f.replace(".ts", ""));
|
|
||||||
|
|
||||||
// Read current cached counts from Redis
|
// Read current cached counts from Redis
|
||||||
let counts: Record<string, number | null> = {};
|
let counts: Record<string, number | null> = {};
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user