Port değişti
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
|
||||
console.log('🔌 Connecting to Socket.IO...');
|
||||
// Socket.IO bağlantısı
|
||||
socket = io('http://localhost:3005');
|
||||
socket = io('http://localhost:3000');
|
||||
|
||||
console.log('👤 Goods Manager ID:', user.id);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ let socket = null;
|
||||
|
||||
export function getSocketClient() {
|
||||
if (!socket) {
|
||||
socket = io('http://localhost:3005', {
|
||||
socket = io('http://localhost:3000', {
|
||||
transports: ['websocket', 'polling']
|
||||
});
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ const app = express();
|
||||
const server = createServer(app);
|
||||
const io = new Server(server, {
|
||||
cors: {
|
||||
origin: process.env.NODE_ENV === 'production' ? false : ["http://localhost:5005"],
|
||||
origin: process.env.NODE_ENV === 'production' ? false : ["http://localhost:5173"],
|
||||
methods: ["GET", "POST"]
|
||||
}
|
||||
});
|
||||
@@ -80,7 +80,7 @@ const io = new Server(server, {
|
||||
// Export io for use in other modules
|
||||
export { io };
|
||||
|
||||
const PORT = process.env.PORT || 3005;
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
// ES Module equivalent of __dirname
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
|
||||
@@ -117,15 +117,15 @@ const app = express();
|
||||
const server = createServer(app);
|
||||
const io = new Server(server, {
|
||||
cors: {
|
||||
origin: "http://localhost:5005",
|
||||
origin: "http://localhost:5173",
|
||||
methods: ["GET", "POST"]
|
||||
}
|
||||
});
|
||||
|
||||
// Export io for use in other modules
|
||||
export { io };
|
||||
// export { io }; // Commented out to avoid circular dependency
|
||||
|
||||
const PORT = process.env.PORT || 3005;
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
// ES Module equivalent of __dirname
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
@@ -197,14 +197,6 @@ async function initializeDatabase() {
|
||||
if (err) reject(err);
|
||||
});
|
||||
|
||||
// Örnek kullanıcıları ekle
|
||||
const users = [
|
||||
{ username: 'admin', password: 'admin123', role: 'admin', full_name: 'Sistem Yöneticisi' },
|
||||
{ username: 'fuel', password: 'fuel123', role: 'fuel_manager', full_name: 'Yakıt Sorumlusu' },
|
||||
{ username: 'goods', password: 'goods123', role: 'goods_manager', full_name: 'Mal Sorumlusu' },
|
||||
{ username: 'ibrahim_kara', password: 'kara123', role: 'goods_manager', full_name: 'İbrahim Kara' }
|
||||
];
|
||||
|
||||
// Yakıt fişleri tablosu
|
||||
db.run(`CREATE TABLE IF NOT EXISTS fuel_slips (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -232,19 +224,29 @@ async function initializeDatabase() {
|
||||
if (err) reject(err);
|
||||
});
|
||||
|
||||
// Her kullanıcıyı kontrol et ve yoksa ekle
|
||||
users.forEach(async (user) => {
|
||||
const hashedPassword = await bcrypt.hash(user.password, 10);
|
||||
// Tablolar oluşturulduktan sonra kullanıcıları ekle
|
||||
setTimeout(async () => {
|
||||
// Örnek kullanıcıları ekle
|
||||
const users = [
|
||||
{ username: 'admin', password: 'admin123', role: 'admin', full_name: 'Sistem Yöneticisi' },
|
||||
{ username: 'fuel', password: 'fuel123', role: 'fuel_manager', full_name: 'Yakıt Sorumlusu' },
|
||||
{ username: 'goods', password: 'goods123', role: 'goods_manager', full_name: 'Mal Sorumlusu' },
|
||||
{ username: 'ibrahim_kara', password: 'kara123', role: 'goods_manager', full_name: 'İbrahim Kara' }
|
||||
];
|
||||
|
||||
db.get('SELECT id FROM users WHERE username = ?', [user.username], (err, row) => {
|
||||
if (!row) {
|
||||
db.run('INSERT INTO users (username, password, role, full_name) VALUES (?, ?, ?, ?)',
|
||||
[user.username, hashedPassword, user.role, user.full_name]);
|
||||
}
|
||||
});
|
||||
});
|
||||
// Her kullanıcıyı kontrol et ve yoksa ekle
|
||||
for (const user of users) {
|
||||
const hashedPassword = await bcrypt.hash(user.password, 10);
|
||||
|
||||
resolve();
|
||||
db.get('SELECT id FROM users WHERE username = ?', [user.username], (err, row) => {
|
||||
if (!row) {
|
||||
db.run('INSERT INTO users (username, password, role, full_name) VALUES (?, ?, ?, ?)',
|
||||
[user.username, hashedPassword, user.role, user.full_name]);
|
||||
}
|
||||
});
|
||||
}
|
||||
resolve();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user