37 lines
892 B
TypeScript
37 lines
892 B
TypeScript
import express from 'express';
|
|
import cors from 'cors';
|
|
import helmet from 'helmet';
|
|
import { env } from './config/env.js';
|
|
import { errorMiddleware } from './middlewares/error.middleware.js';
|
|
import { authRoutes } from './routes/auth.routes.js';
|
|
import { dashboardRoutes } from './routes/dashboard.routes.js';
|
|
import { cfdiRoutes } from './routes/cfdi.routes.js';
|
|
|
|
const app = express();
|
|
|
|
// Security
|
|
app.use(helmet());
|
|
app.use(cors({
|
|
origin: env.CORS_ORIGIN,
|
|
credentials: true,
|
|
}));
|
|
|
|
// Body parsing
|
|
app.use(express.json());
|
|
app.use(express.urlencoded({ extended: true }));
|
|
|
|
// Health check
|
|
app.get('/health', (req, res) => {
|
|
res.json({ status: 'ok', timestamp: new Date().toISOString() });
|
|
});
|
|
|
|
// API Routes
|
|
app.use('/api/auth', authRoutes);
|
|
app.use('/api/dashboard', dashboardRoutes);
|
|
app.use('/api/cfdi', cfdiRoutes);
|
|
|
|
// Error handling
|
|
app.use(errorMiddleware);
|
|
|
|
export { app };
|