- Registration form: added 5 new role options to dropdown - Sidebar: new roles get proper nav access via ALL_ROLES/LEADER_ROLES - Dashboard: isLeader check expanded to include new leadership roles - Shared/Pages: role badge colors added for all new roles - Invite modal: expanded role dropdown
43 lines
998 B
JavaScript
43 lines
998 B
JavaScript
import express from 'express';
|
|
import cors from 'cors';
|
|
import { initDB } from './db.js';
|
|
import authRoutes from './routes/auth.js';
|
|
import taskRoutes from './routes/tasks.js';
|
|
|
|
const app = express();
|
|
const PORT = process.env.PORT || 3001;
|
|
|
|
app.use(cors());
|
|
app.use(express.json());
|
|
|
|
// Routes
|
|
app.use('/api/auth', authRoutes);
|
|
app.use('/api/tasks', taskRoutes);
|
|
|
|
// Health check
|
|
app.get('/api/health', (_req, res) => {
|
|
res.json({ status: 'ok', timestamp: new Date().toISOString() });
|
|
});
|
|
|
|
// Initialize DB and start server
|
|
// Initialize DB and start server
|
|
async function start() {
|
|
try {
|
|
await initDB();
|
|
if (process.env.NODE_ENV !== 'test') {
|
|
app.listen(PORT, () => {
|
|
console.log(`🚀 Backend server running on port ${PORT}`);
|
|
});
|
|
}
|
|
} catch (err) {
|
|
console.error('❌ Failed to start server:', err);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
if (process.env.NODE_ENV !== 'test') {
|
|
start();
|
|
}
|
|
|
|
export { app, start };
|