- Add explicit IRouter type to all route files - Add explicit Express type to app.ts - Fix env.ts by moving getCorsOrigins after parsing - Fix token.ts SignOptions type for expiresIn - Cast req.params.id to String() in controllers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import express, { type Express } from 'express';
|
|
import cors from 'cors';
|
|
import helmet from 'helmet';
|
|
import { env, getCorsOrigins } 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';
|
|
import { impuestosRoutes } from './routes/impuestos.routes.js';
|
|
import { exportRoutes } from './routes/export.routes.js';
|
|
import { alertasRoutes } from './routes/alertas.routes.js';
|
|
import { calendarioRoutes } from './routes/calendario.routes.js';
|
|
import { reportesRoutes } from './routes/reportes.routes.js';
|
|
import { usuariosRoutes } from './routes/usuarios.routes.js';
|
|
import { tenantsRoutes } from './routes/tenants.routes.js';
|
|
import fielRoutes from './routes/fiel.routes.js';
|
|
import satRoutes from './routes/sat.routes.js';
|
|
|
|
const app: Express = express();
|
|
|
|
// Security
|
|
app.use(helmet());
|
|
app.use(cors({
|
|
origin: getCorsOrigins(),
|
|
credentials: true,
|
|
}));
|
|
|
|
// Body parsing - increased limit for bulk XML uploads (1GB)
|
|
app.use(express.json({ limit: '1gb' }));
|
|
app.use(express.urlencoded({ extended: true, limit: '1gb' }));
|
|
|
|
// 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);
|
|
app.use('/api/impuestos', impuestosRoutes);
|
|
app.use('/api/export', exportRoutes);
|
|
app.use('/api/alertas', alertasRoutes);
|
|
app.use('/api/calendario', calendarioRoutes);
|
|
app.use('/api/reportes', reportesRoutes);
|
|
app.use('/api/usuarios', usuariosRoutes);
|
|
app.use('/api/tenants', tenantsRoutes);
|
|
app.use('/api/fiel', fielRoutes);
|
|
app.use('/api/sat', satRoutes);
|
|
|
|
// Error handling
|
|
app.use(errorMiddleware);
|
|
|
|
export { app };
|