feat: admin panel CRUD, Cloudinary upload, logo, user management

This commit is contained in:
mstfyldz
2026-06-05 17:38:01 +03:00
parent 53eeeee474
commit 5e4e2f0db9
43 changed files with 3917 additions and 281 deletions
+39
View File
@@ -0,0 +1,39 @@
import { Client } from 'pg';
import bcrypt from 'bcryptjs';
import dotenv from 'dotenv';
dotenv.config();
const client = new Client({
connectionString: process.env.DATABASE_URL,
});
async function main() {
await client.connect();
const username = 'admin';
const password = 'password123'; // Users should change this!
const passwordHash = await bcrypt.hash(password, 10);
try {
// Check if user already exists
const res = await client.query('SELECT id FROM users WHERE username = $1', [username]);
if (res.rowCount && res.rowCount > 0) {
console.log('Admin user already exists.');
} else {
await client.query(
'INSERT INTO users (username, password_hash, role, created_at, updated_at) VALUES ($1, $2, $3, NOW(), NOW())',
[username, passwordHash, 'admin']
);
console.log('Admin user created successfully.');
console.log(`Username: ${username}`);
console.log(`Password: ${password}`);
}
} catch (error) {
console.error('Error creating admin user:', error);
} finally {
await client.end();
}
}
main();