Password Policy/App rename/PM Scheduling Improvements
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
require('dotenv').config();
|
||||
|
||||
const moment = require('moment');
|
||||
moment.locale('en');
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const { DB_PATH, initialize } = require('./db');
|
||||
@@ -27,16 +29,19 @@ const taxRuleRoutes = require('./routes/taxRules');
|
||||
const templateRoutes = require('./routes/templates');
|
||||
const workdayRoutes = require('./routes/workday');
|
||||
|
||||
console.log(`${moment().format()} ✅ Starting DepreCore server with database at ${DB_PATH}`);
|
||||
function createApp() {
|
||||
initialize();
|
||||
|
||||
const app = express();
|
||||
app.use(createCorsMiddleware());
|
||||
app.use(express.json({ limit: '12mb' }));
|
||||
console.log(`${moment().format()} ✅ Express app initialized with JSON body parsing and CORS middleware`);
|
||||
|
||||
app.get('/api/health', (req, res) => {
|
||||
res.json({ ok: true, app: 'MixedAssets', database: DB_PATH });
|
||||
res.json({ ok: true, app: 'DepreCore', database: DB_PATH });
|
||||
});
|
||||
console.log(`${moment().format()} ✅ Health check endpoint registered at /api/health`);
|
||||
|
||||
app.use('/api', authRoutes);
|
||||
app.use('/api', requireAuth);
|
||||
@@ -59,9 +64,12 @@ function createApp() {
|
||||
app.use('/api', dataPortabilityRoutes);
|
||||
app.use('/api', adminRoutes);
|
||||
app.use('/api', workdayRoutes);
|
||||
console.log(`${moment().format()} ✅ API routes registered under /api`);
|
||||
|
||||
const distPath = path.join(process.cwd(), 'dist');
|
||||
app.use(express.static(distPath));
|
||||
console.log(`${moment().format()} ✅ Static file serving configured for ${distPath}`);
|
||||
|
||||
app.get(/.*/, (req, res, next) => {
|
||||
if (req.path.startsWith('/api')) return next();
|
||||
return res.sendFile(path.join(distPath, 'index.html'));
|
||||
@@ -70,8 +78,10 @@ function createApp() {
|
||||
app.use((error, req, res, next) => {
|
||||
if (res.headersSent) return next(error);
|
||||
const status = error.status || 500;
|
||||
return res.status(status).json({ error: error.message || 'MixedAssets server error' });
|
||||
console.error(`${moment().format()} ❌ Error: ${error.message}\n${error.stack}`);
|
||||
return res.status(status).json({ error: error.message || 'DepreCore server error' });
|
||||
});
|
||||
console.log(`${moment().format()} ✅ Global error handler registered`);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user