121 lines
5.2 KiB
TypeScript
121 lines
5.2 KiB
TypeScript
import { Pool } from 'pg';
|
|
import { PrismaPg } from '@prisma/adapter-pg';
|
|
import { PrismaClient } from '@prisma/client';
|
|
|
|
const connectionString =
|
|
process.env.DATABASE_URL ||
|
|
'postgres://postgres:mBTWE2cDKGExtpktguD3HPe8y9Xr9kWFYdxV4WHQKISLLGoBAS4UdtfSCfXwvPpq@65.109.236.58:37298/postgres';
|
|
|
|
const pool = new Pool({ connectionString });
|
|
const adapter = new PrismaPg(pool);
|
|
const db = new PrismaClient({ adapter });
|
|
|
|
async function main() {
|
|
console.log('Seeding PostgreSQL database...');
|
|
|
|
// Clear existing records
|
|
await db.videoChapter.deleteMany();
|
|
await db.resourceDownload.deleteMany();
|
|
await db.codeSnippet.deleteMany();
|
|
await db.lesson.deleteMany();
|
|
await db.cheatsheetItem.deleteMany();
|
|
await db.cheatsheet.deleteMany();
|
|
|
|
// Create Lessons
|
|
await db.lesson.create({
|
|
data: {
|
|
slug: 'nextjs-16-app-router-full-course',
|
|
title: 'Next.js 16 App Router & Server Actions Complete Masterclass (Code & Project)',
|
|
youtubeId: 'dQw4w9WgXcQ',
|
|
youtubeUrl: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
|
|
thumbnailUrl: 'https://images.unsplash.com/photo-1618401471353-b98afee0b2eb?w=800&auto=format&fit=crop&q=80',
|
|
duration: '42:15',
|
|
category: 'Next.js',
|
|
tags: ['Next.js 16', 'App Router', 'Server Actions', 'TypeScript', 'Tailwind CSS v4'],
|
|
viewsCount: 24500,
|
|
downloadCount: 4120,
|
|
likesCount: 1890,
|
|
isFeatured: true,
|
|
summary: 'In this tutorial, we build a full-stack Next.js 16 application from scratch covering App Router architecture, proxy.ts middleware, Server Actions, and PostgreSQL integration.',
|
|
notesMarkdown: [
|
|
'In Next.js 16, using proxy.ts is recommended over deprecated middleware.ts.',
|
|
'Server Actions functions are declared with "use server" directive and can be invoked directly from client components.',
|
|
'Data fetching revalidation uses revalidatePath or revalidateTag helpers.',
|
|
'Form handling UX is significantly improved using useActionState and useFormStatus hooks.'
|
|
],
|
|
codeSnippets: {
|
|
create: [
|
|
{
|
|
fileName: 'app/actions.ts',
|
|
language: 'typescript',
|
|
description: 'Server Action function handling form submission',
|
|
code: `'use server'\n\nimport { revalidatePath } from 'next/cache';\n\nexport async function submitProjectIdea(formData: FormData) {\n const title = formData.get('title') as string;\n\n if (!title || title.length < 3) {\n return { success: false, error: 'Title must be at least 3 characters long.' };\n }\n\n revalidatePath('/ideas');\n return { success: true, message: 'Submitted!' };\n}`
|
|
}
|
|
]
|
|
},
|
|
downloads: {
|
|
create: [
|
|
{ title: 'Full Project Source Code', type: 'zip', url: '#', size: '4.2 MB' },
|
|
{ title: 'GitHub Repository', type: 'github', url: 'https://github.com/ayrisdev/nextjs-16-starter' }
|
|
]
|
|
},
|
|
chapters: {
|
|
create: [
|
|
{ time: '00:00', seconds: 0, title: 'Introduction & Demo' },
|
|
{ time: '04:15', seconds: 255, title: 'Next.js 16 Project Setup' },
|
|
{ time: '11:30', seconds: 690, title: 'Routing & proxy.ts' },
|
|
{ time: '21:00', seconds: 1260, title: 'Server Actions' },
|
|
{ time: '32:45', seconds: 1965, title: 'PostgreSQL & Prisma' },
|
|
{ time: '40:00', seconds: 2400, title: 'Deployment' }
|
|
]
|
|
}
|
|
}
|
|
});
|
|
|
|
// Create Cheatsheets
|
|
await db.cheatsheet.create({
|
|
data: {
|
|
slug: 'git-komutlari-hizli-rehber',
|
|
title: 'Essential Git & GitHub Commands Cheatsheet',
|
|
category: 'DevOps & Tooling',
|
|
description: 'Handy reference for daily Git workflow, branching, and conflict resolution commands.',
|
|
tags: ['Git', 'GitHub', 'Terminal'],
|
|
items: {
|
|
create: [
|
|
{ command: 'git checkout -b feature/new-feature', description: 'Creates a new branch and switches to it.' },
|
|
{ command: 'git status', description: 'Lists modified and untracked files.' },
|
|
{ command: 'git commit -m "feat: add new page"', description: 'Saves changes with a descriptive commit message.' },
|
|
{ command: 'git push origin feature/new-feature', description: 'Pushes the branch to remote repository.' },
|
|
{ command: 'git log --oneline -n 5', description: 'Displays last 5 commits in clean single line format.' }
|
|
]
|
|
}
|
|
}
|
|
});
|
|
|
|
// Create Prompts
|
|
await db.prompt.deleteMany();
|
|
await db.prompt.create({
|
|
data: {
|
|
slug: 'fullstack-nextjs-architect-prompt',
|
|
title: 'Full-Stack Next.js 16 System Architect Prompt',
|
|
category: 'System Architecture',
|
|
description: 'System prompt for building production-ready Next.js 16 App Router code with Server Actions and Prisma.',
|
|
content: `You are a Senior Next.js 16 Architect. Always use TypeScript strict mode, App Router, proxy.ts for middleware, Server Actions with Zod validation, and Prisma ORM.`,
|
|
tags: ['Next.js', 'System Prompt', 'AI Architecture'],
|
|
isOpen: false,
|
|
}
|
|
});
|
|
|
|
console.log('Seeding completed successfully!');
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error('Seed error:', e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await db.$disconnect();
|
|
await pool.end();
|
|
});
|