feat: add admin dashboard and core API routes with Docker configuration
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { ContentStatus } from "@prisma/client";
|
||||
import { getAuthUser } from "@/lib/auth-utils";
|
||||
import { sanitizeHTML } from "@/lib/sanitize";
|
||||
|
||||
export async function createNews(data: {
|
||||
title: string;
|
||||
@@ -14,6 +16,11 @@ export async function createNews(data: {
|
||||
sources?: any;
|
||||
}) {
|
||||
try {
|
||||
const authUser = await getAuthUser();
|
||||
if (!authUser) {
|
||||
return { success: false, error: "Authentification requise" };
|
||||
}
|
||||
|
||||
const slug = data.title
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
@@ -21,12 +28,12 @@ export async function createNews(data: {
|
||||
|
||||
const post = await prisma.blogPost.create({
|
||||
data: {
|
||||
title: data.title,
|
||||
excerpt: data.excerpt,
|
||||
content: data.content,
|
||||
author: data.author,
|
||||
title: data.title.trim().slice(0, 200),
|
||||
excerpt: data.excerpt.trim().slice(0, 500),
|
||||
content: sanitizeHTML(data.content || ''),
|
||||
author: data.author.trim().slice(0, 100),
|
||||
imageUrl: data.imageUrl,
|
||||
tags: data.tags || [],
|
||||
tags: Array.isArray(data.tags) ? data.tags.slice(0, 20) : [],
|
||||
sources: data.sources || [],
|
||||
status: 'PENDING' as ContentStatus, // Always pending for user submission
|
||||
slug: `${slug}-${Math.random().toString(36).substring(2, 7)}`
|
||||
|
||||
Reference in New Issue
Block a user