Port değişti

This commit is contained in:
2025-11-07 01:48:12 +03:00
parent dd298df953
commit 6a2c07076d
8 changed files with 39 additions and 37 deletions

View File

@@ -53,8 +53,8 @@ npm install
npm run dev npm run dev
# 4. Tarayıcıda açma # 4. Tarayıcıda açma
# Frontend: http://localhost:5005 # Frontend: http://localhost:5173
# Backend API: http://localhost:3005 # Backend API: http://localhost:3000
``` ```
#### 1.2 Development Workflow #### 1.2 Development Workflow
@@ -1531,7 +1531,7 @@ const getFuelSlips = (userId, status) => {
const corsOptions = { const corsOptions = {
origin: process.env.NODE_ENV === 'production' origin: process.env.NODE_ENV === 'production'
? 'https://your-domain.com' ? 'https://your-domain.com'
: ['http://localhost:5005', 'http://localhost:4005'], : ['http://localhost:5173', 'http://localhost:4173'],
methods: ['GET', 'POST', 'PUT', 'DELETE'], methods: ['GET', 'POST', 'PUT', 'DELETE'],
allowedHeaders: ['Content-Type', 'Authorization'], allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true, credentials: true,

View File

@@ -5,8 +5,8 @@
KNOWLEDGE_BASE.md'deki iş akışlarına göre implement edilen tam fonksiyonel yakıt takip sistemi. KNOWLEDGE_BASE.md'deki iş akışlarına göre implement edilen tam fonksiyonel yakıt takip sistemi.
### 🚀 **Sunucu Durumu** ### 🚀 **Sunucu Durumu**
- **Frontend**: `http://localhost:5005/` (SvelteKit) - **Frontend**: `http://localhost:5173/` (SvelteKit)
- **Backend**: `http://localhost:3005` (Express/Socket.IO) - **Backend**: `http://localhost:3000` (Express/Socket.IO)
- **Status**: ✅ Çalışıyor - **Status**: ✅ Çalışıyor
## 🔐 **Test Kullanıcıları** ## 🔐 **Test Kullanıcıları**

View File

@@ -5,11 +5,11 @@
"main": "src/server.js", "main": "src/server.js",
"scripts": { "scripts": {
"dev": "npm run server & npm run client", "dev": "npm run server & npm run client",
"server": "PORT=3005 node src/server.js", "server": "PORT=3000 node src/server.js",
"client": "vite dev --port 5005", "client": "vite dev --port 5173",
"build": "vite build", "build": "vite build",
"preview": "vite preview --port 5005", "preview": "vite preview --port 5173",
"start": "PORT=3005 node src/production-server.js", "start": "PORT=3000 node src/production-server.js",
"prod": "npm run build && npm run start", "prod": "npm run build && npm run start",
"setup": "node -e \"import('./src/server.js').then(() => console.log('Database setup completed')).catch(console.error);\"", "setup": "node -e \"import('./src/server.js').then(() => console.log('Database setup completed')).catch(console.error);\"",
"init-db": "node -e \"import('./src/server.js').catch(console.error)\"" "init-db": "node -e \"import('./src/server.js').catch(console.error)\""

View File

@@ -29,7 +29,7 @@
console.log('🔌 Connecting to Socket.IO...'); console.log('🔌 Connecting to Socket.IO...');
// Socket.IO bağlantısı // Socket.IO bağlantısı
socket = io('http://localhost:3005'); socket = io('http://localhost:3000');
console.log('👤 Goods Manager ID:', user.id); console.log('👤 Goods Manager ID:', user.id);

View File

@@ -4,7 +4,7 @@ let socket = null;
export function getSocketClient() { export function getSocketClient() {
if (!socket) { if (!socket) {
socket = io('http://localhost:3005', { socket = io('http://localhost:3000', {
transports: ['websocket', 'polling'] transports: ['websocket', 'polling']
}); });

View File

@@ -72,7 +72,7 @@ const app = express();
const server = createServer(app); const server = createServer(app);
const io = new Server(server, { const io = new Server(server, {
cors: { cors: {
origin: process.env.NODE_ENV === 'production' ? false : ["http://localhost:5005"], origin: process.env.NODE_ENV === 'production' ? false : ["http://localhost:5173"],
methods: ["GET", "POST"] methods: ["GET", "POST"]
} }
}); });
@@ -80,7 +80,7 @@ const io = new Server(server, {
// Export io for use in other modules // Export io for use in other modules
export { io }; export { io };
const PORT = process.env.PORT || 3005; const PORT = process.env.PORT || 3000;
// ES Module equivalent of __dirname // ES Module equivalent of __dirname
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);

View File

@@ -117,15 +117,15 @@ const app = express();
const server = createServer(app); const server = createServer(app);
const io = new Server(server, { const io = new Server(server, {
cors: { cors: {
origin: "http://localhost:5005", origin: "http://localhost:5173",
methods: ["GET", "POST"] methods: ["GET", "POST"]
} }
}); });
// Export io for use in other modules // 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 // ES Module equivalent of __dirname
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
@@ -197,14 +197,6 @@ async function initializeDatabase() {
if (err) reject(err); 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 // Yakıt fişleri tablosu
db.run(`CREATE TABLE IF NOT EXISTS fuel_slips ( db.run(`CREATE TABLE IF NOT EXISTS fuel_slips (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -232,19 +224,29 @@ async function initializeDatabase() {
if (err) reject(err); if (err) reject(err);
}); });
// Her kullanıcıyı kontrol et ve yoksa ekle // Tablolar oluşturulduktan sonra kullanıcıları ekle
users.forEach(async (user) => { setTimeout(async () => {
const hashedPassword = await bcrypt.hash(user.password, 10); // Ö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) => { // Her kullanıcıyı kontrol et ve yoksa ekle
if (!row) { for (const user of users) {
db.run('INSERT INTO users (username, password, role, full_name) VALUES (?, ?, ?, ?)', const hashedPassword = await bcrypt.hash(user.password, 10);
[user.username, hashedPassword, user.role, user.full_name]);
}
});
});
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);
}); });
}); });
} }

View File

@@ -4,10 +4,10 @@ import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
plugins: [sveltekit()], plugins: [sveltekit()],
server: { server: {
port: 5005, port: 5173,
proxy: { proxy: {
'/api': { '/api': {
target: 'http://localhost:3005', target: 'http://localhost:3000',
changeOrigin: true changeOrigin: true
} }
} }