Adds in Mantis features. Enabling automated downloading of Mantises into the internal database, browsing of them, and viewing of attachments (including .msg files).
Resolves #14
This commit is contained in:
parent
0e77e310bd
commit
5268d6aecd
15 changed files with 1583 additions and 44 deletions
|
@ -16,58 +16,23 @@ import session from 'express-session';
|
|||
import { PrismaSessionStore } from '@quixo3/prisma-session-store';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import pino from 'pino';
|
||||
import pinoHttp from 'pino-http';
|
||||
import apiRoutes from './routes/api.js';
|
||||
import authRoutes from './routes/auth.js';
|
||||
import chatRoutes from './routes/chat.js';
|
||||
import settingsRoutes from './routes/settings.js';
|
||||
import userPreferencesRoutes from './routes/userPreferences.js';
|
||||
import mantisRoutes from './routes/mantis.js'; // Import Mantis routes
|
||||
import cron from 'node-cron';
|
||||
import { generateAndStoreMantisSummary } from './services/mantisSummarizer.js';
|
||||
import { requireAuth } from './middlewares/authMiddleware.js';
|
||||
|
||||
import { setup as setupMantisDownloader } from './services/mantisDownloader.js';
|
||||
|
||||
import { logger } from './utils/logging.js';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
// Initialize Pino logger
|
||||
const targets = [];
|
||||
|
||||
// Console logging (pretty-printed in development)
|
||||
if (process.env.NODE_ENV !== 'production')
|
||||
{
|
||||
targets.push({
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
colorize: true
|
||||
},
|
||||
level: process.env.LOG_LEVEL || 'info'
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Basic console logging in production
|
||||
targets.push({
|
||||
target: 'pino/file', // Log to stdout in production
|
||||
options: { destination: 1 }, // 1 is stdout
|
||||
level: process.env.LOG_LEVEL || 'info'
|
||||
});
|
||||
}
|
||||
|
||||
// Database logging via custom transport
|
||||
targets.push({
|
||||
target: './utils/prisma-pino-transport.js', // Path to the custom transport
|
||||
options: {}, // No specific options needed for this transport
|
||||
level: process.env.DB_LOG_LEVEL || 'info' // Separate level for DB logging if needed
|
||||
});
|
||||
|
||||
const logger = pino({
|
||||
level: process.env.LOG_LEVEL || 'info', // Overall minimum level
|
||||
transport: {
|
||||
targets: targets
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize pino-http middleware
|
||||
const httpLogger = pinoHttp({ logger });
|
||||
|
||||
// Define Relying Party details (Update with your actual details)
|
||||
|
@ -75,14 +40,12 @@ export const rpID = process.env.NODE_ENV === 'production' ? 'stylepoint.uk' : 'l
|
|||
export const rpName = 'StylePoint';
|
||||
export const origin = process.env.NODE_ENV === 'production' ? `https://${rpID}` : `http://${rpID}:9000`;
|
||||
|
||||
// In-memory store for challenges (Replace with a persistent store in production)
|
||||
export const challengeStore = new Map();
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const app = express();
|
||||
|
||||
// Add pino-http middleware
|
||||
app.use(httpLogger);
|
||||
|
||||
if(!process.env.SESSION_SECRET)
|
||||
|
@ -142,6 +105,7 @@ app.use('/api/auth', authRoutes);
|
|||
app.use('/api/chat', requireAuth, chatRoutes);
|
||||
app.use('/api/user-preferences', requireAuth, userPreferencesRoutes);
|
||||
app.use('/api/settings', requireAuth, settingsRoutes);
|
||||
app.use('/api/mantis', requireAuth, mantisRoutes); // Register Mantis routes
|
||||
app.use('/api', requireAuth, apiRoutes);
|
||||
|
||||
if (process.env.PROD)
|
||||
|
@ -154,4 +118,6 @@ app.use(express.static('public', { index: false }));
|
|||
app.listen(8000, () =>
|
||||
{
|
||||
logger.info('Server is running on http://localhost:8000');
|
||||
|
||||
setupMantisDownloader();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue