Some checks are pending
Deploy to Production / deploy (push) Waiting to run
- Changed admin frontend port from 3000 to 3300 across all configuration files - Changed API backend port from 3001 to 3301 across all configuration files - Updated health check endpoints to use new ports in CI/CD workflow - Modified documentation and deployment guides to reflect new port numbers - Updated Caddy and Nginx reverse proxy configurations to use new ports
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import path from 'path';
|
|
import dotenv from 'dotenv';
|
|
dotenv.config({ path: path.resolve(__dirname, '../../../.env') });
|
|
import express from 'express';
|
|
import cors from 'cors';
|
|
import morgan from 'morgan';
|
|
import authRouter from './auth';
|
|
import mediaRouter from './media';
|
|
import sttRouter from './stt';
|
|
import draftsRouter from './drafts';
|
|
import postsRouter from './posts';
|
|
import ghostRouter from './ghost';
|
|
import aiGenerateRouter from './ai-generate';
|
|
import aiRoutesNew from './routes/ai.routes';
|
|
import settingsRouter from './settings';
|
|
|
|
const app = express();
|
|
console.log('ENV ADMIN_PASSWORD loaded:', Boolean(process.env.ADMIN_PASSWORD));
|
|
|
|
// Middleware
|
|
app.use(cors({
|
|
origin: process.env.CORS_ORIGIN || 'http://localhost:3300',
|
|
credentials: true
|
|
}));
|
|
app.use(morgan('dev'));
|
|
app.use(express.json());
|
|
|
|
// API routes
|
|
app.use('/api/auth', authRouter);
|
|
app.use('/api/media', mediaRouter);
|
|
app.use('/api/stt', sttRouter);
|
|
app.use('/api/drafts', draftsRouter);
|
|
app.use('/api/posts', postsRouter);
|
|
app.use('/api/ghost', ghostRouter);
|
|
// Use new refactored AI routes
|
|
app.use('/api/ai', aiRoutesNew);
|
|
// Keep old routes temporarily for backward compatibility (can remove after testing)
|
|
// app.use('/api/ai', aiGenerateRouter);
|
|
app.use('/api/settings', settingsRouter);
|
|
app.get('/api/health', (_req, res) => {
|
|
res.json({ ok: true });
|
|
});
|
|
|
|
// Error handler
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
app.use((err: any, _req: express.Request, res: express.Response, _next: express.NextFunction) => {
|
|
console.error('API Error:', err);
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
});
|
|
|
|
// Start server
|
|
const PORT = process.env.PORT || 3301;
|
|
app.listen(PORT, () => {
|
|
console.log(`API server running on port ${PORT}`);
|
|
});
|