feat: initial project scaffold
- React 19 + Vite + TailwindCSS frontend - Express + TypeScript backend API - PostgreSQL schema and migrations - Docker Compose orchestration - Drone CI/CD pipeline - Pages: Dashboard, Servers, Containers, Services, Logs, Metrics, Settings
This commit is contained in:
46
backend/src/index.ts
Normal file
46
backend/src/index.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import express, { Express, Request, Response } from 'express';
|
||||
import cors from 'cors';
|
||||
import helmet from 'helmet';
|
||||
import morgan from 'morgan';
|
||||
import dotenv from 'dotenv';
|
||||
import { errorHandler } from './middleware/errorHandler';
|
||||
import { notFound } from './middleware/notFound';
|
||||
import apiRoutes from './routes';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const app: Express = express();
|
||||
const port = process.env.PORT || 3001;
|
||||
|
||||
// Middleware
|
||||
app.use(helmet());
|
||||
app.use(cors({
|
||||
origin: process.env.CORS_ORIGIN || 'http://localhost:5173',
|
||||
credentials: true
|
||||
}));
|
||||
app.use(morgan('dev'));
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
// Health check
|
||||
app.get('/health', (req: Request, res: Response) => {
|
||||
res.json({
|
||||
status: 'ok',
|
||||
timestamp: new Date().toISOString(),
|
||||
uptime: process.uptime()
|
||||
});
|
||||
});
|
||||
|
||||
// API Routes
|
||||
app.use('/api', apiRoutes);
|
||||
|
||||
// Error handling
|
||||
app.use(notFound);
|
||||
app.use(errorHandler);
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`⚡️ Server is running on port ${port}`);
|
||||
console.log(`🌍 Environment: ${process.env.NODE_ENV || 'development'}`);
|
||||
});
|
||||
|
||||
export default app;
|
||||
Reference in New Issue
Block a user