security: remove hardcoded DB credentials from code files

This commit is contained in:
AyrisAI
2026-07-23 17:58:07 +03:00
parent a2d6cf653d
commit f67afd32da
3 changed files with 13 additions and 9 deletions
+5 -3
View File
@@ -7,9 +7,11 @@ const globalForPrisma = globalThis as unknown as {
}; };
function createPrismaClient(): PrismaClient { function createPrismaClient(): PrismaClient {
const connectionString = const connectionString = process.env.DATABASE_URL;
process.env.DATABASE_URL ||
'postgres://postgres:mBTWE2cDKGExtpktguD3HPe8y9Xr9kWFYdxV4WHQKISLLGoBAS4UdtfSCfXwvPpq@65.109.236.58:37298/postgres'; if (!connectionString) {
throw new Error('[DB] DATABASE_URL environment variable is not set!');
}
const pool = new Pool({ connectionString }); const pool = new Pool({ connectionString });
const adapter = new PrismaPg(pool); const adapter = new PrismaPg(pool);
+1 -1
View File
@@ -2,6 +2,6 @@ import { defineConfig } from '@prisma/config';
export default defineConfig({ export default defineConfig({
datasource: { datasource: {
url: process.env.DATABASE_URL || 'postgres://postgres:mBTWE2cDKGExtpktguD3HPe8y9Xr9kWFYdxV4WHQKISLLGoBAS4UdtfSCfXwvPpq@65.109.236.58:37298/postgres', url: process.env.DATABASE_URL,
}, },
}); });
+7 -5
View File
@@ -2,9 +2,11 @@ import { Pool } from 'pg';
import { PrismaPg } from '@prisma/adapter-pg'; import { PrismaPg } from '@prisma/adapter-pg';
import { PrismaClient } from '@prisma/client'; import { PrismaClient } from '@prisma/client';
const connectionString = const connectionString = process.env.DATABASE_URL;
process.env.DATABASE_URL ||
'postgres://postgres:mBTWE2cDKGExtpktguD3HPe8y9Xr9kWFYdxV4WHQKISLLGoBAS4UdtfSCfXwvPpq@65.109.236.58:37298/postgres'; if (!connectionString) {
throw new Error('[Seed] DATABASE_URL environment variable is not set!');
}
const pool = new Pool({ connectionString }); const pool = new Pool({ connectionString });
const adapter = new PrismaPg(pool); const adapter = new PrismaPg(pool);
@@ -20,6 +22,7 @@ async function main() {
await db.lesson.deleteMany(); await db.lesson.deleteMany();
await db.cheatsheetItem.deleteMany(); await db.cheatsheetItem.deleteMany();
await db.cheatsheet.deleteMany(); await db.cheatsheet.deleteMany();
await db.prompt.deleteMany();
// Create Lessons // Create Lessons
await db.lesson.create({ await db.lesson.create({
@@ -93,13 +96,12 @@ async function main() {
}); });
// Create Prompts // Create Prompts
await db.prompt.deleteMany();
await db.prompt.create({ await db.prompt.create({
data: { data: {
slug: 'fullstack-nextjs-architect-prompt', slug: 'fullstack-nextjs-architect-prompt',
title: 'Full-Stack Next.js 16 System Architect Prompt', title: 'Full-Stack Next.js 16 System Architect Prompt',
category: 'System Architecture', category: 'System Architecture',
description: 'System prompt for building production-ready Next.js 16 App Router code with Server Actions and Prisma.', description: 'System prompt for building production-ready Next.js 16 App Router code.',
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.`, 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'], tags: ['Next.js', 'System Prompt', 'AI Architecture'],
isOpen: false, isOpen: false,