chore: remove db credentials from tracking and add template file

This commit is contained in:
2025-12-28 23:04:08 +11:00
parent fc16340c25
commit 64bdc868b2
4 changed files with 17 additions and 10 deletions

View File

@@ -1,8 +1,5 @@
const { Pool } = require('pg');
const config = require('./lib/db-config');
// Force localhost for server-side check
config.host = 'localhost';
config.password = 'WebPerfTest2025'; // Ensure password is explicit just in case
const pool = new Pool(config);
async function checkData() {

11
lib/db-config.template.js Normal file
View File

@@ -0,0 +1,11 @@
// Database Configuration Template
// Copy this file to lib/db-config.js and update with your actual credentials
// NEVER commit lib/db-config.js to Git - it's in .gitignore for security
module.exports = {
host: 'YOUR_DATABASE_HOST', // e.g., 'localhost' or '172.16.69.219'
user: 'YOUR_DATABASE_USER', // e.g., 'postgres'
password: 'YOUR_DATABASE_PASSWORD', // Database password
database: 'YOUR_DATABASE_NAME', // e.g., 'webperformance'
port: 5432, // Default PostgreSQL port
};

View File

@@ -264,10 +264,13 @@ async function _executeTest(url, options) {
];
try {
console.log('📝 Attempting DB Insert for Test:', testId);
console.log('👤 User UUID:', options.userUuid);
const db = require('../lib/db');
await db.pool.query(insertQuery, values);
console.log('✅ DB Insert Success!');
} catch (dbErr) {
console.error('Failed to save result to DB:', dbErr);
console.error('Failed to save result to DB:', dbErr);
// Don't fail the whole test if DB save fails, just log it
}

View File

@@ -1,10 +1,6 @@
const { Pool } = require('pg');
const config = require('./lib/db-config');
const { v4: uuidv4 } = require('uuid');
// Force localhost
config.host = 'localhost';
config.password = 'WebPerfTest2025';
const crypto = require('crypto');
const pool = new Pool(config);
@@ -13,7 +9,7 @@ async function testInsert() {
const client = await pool.connect();
try {
const testId = uuidv4();
const testId = crypto.randomUUID();
const query = `
INSERT INTO test_results (
id, url, user_uuid, is_mobile,