"use strict";
// import 'dotenv/config';
// import 'reflect-metadata';
// import express from 'express';
// import cors from 'cors';
// import bodyParser from 'body-parser';
// import fs from 'fs';
// import https from 'https';
// import jwt from 'jsonwebtoken';
// import { v1 as uuidv1 } from 'uuid';
// import { isUndefined } from 'util';
// import nodemailer from 'nodemailer';
// import icalToolkit from 'ical-toolkit';
// import { LessThan, MoreThan } from 'typeorm';
// import { AppDataSource } from './data-source';
// import https from 'https';
// import { Student } from './entity/Student';
// import { Client } from './entity/Client';
// import { TitleStudent } from './entity/TitleStudent';
// import { TypeStudent } from './entity/TypeStudent';
// import { Classes } from './entity/Classes';
// import { Course } from './entity/Course';
// import { ClientType } from './entity/ClientType';
// import { CourseCategory } from './entity/CourseCategory';
// import { TeachingMode } from './entity/TeachingMode';
// import { ClassDetail } from './entity/ClassDetail';
// import { Address } from './entity/Address';
// import { User } from './entity/User';
// import { ClassNumber } from './entity/ClassNumber';
// const sslOptions = {
//   key: fs.readFileSync('cert/cloudapi-key.key'),
//   cert: fs.readFileSync('cert/cloudapi-cert.cert')
// };
// import authRoutes from './routes/auth';
// import clientRoutes from './routes/client';
// import studentRoutes from './routes/student';
// import classRoutes from './routes/class';
// const app = express();
// const port = process.env.PORT || 3000;
// app.use(cors());
// app.options('*', cors());
// app.use(bodyParser.json());
// // Register route modules
// app.use(authRoutes);
// app.use(clientRoutes);
// app.use(studentRoutes);
// app.use(classRoutes);
// function authentificationToken(req, res, next) {
//   const authHeader = req.headers['authorization'];
//   const token = authHeader && authHeader.split(' ')[1];
//   if (token == null) return res.sendStatus(401);
//   jwt.verify(token, process.env.ACCESS_TOKEN_SECRET, (err, user) => {
//     if (err) return res.sendStatus(403);
//     req.user = user;
//     next();
//   });
// }
// async function GetClassesDetailsDescription(ClassesDetails: ClassDetail[]) {
//   let description = '';
//   ClassesDetails.forEach(cd => {
//     description += '($ ' + cd.cost + ') ' + cd.Course.title + '\r\n';
//   });
//   return description;
// }
// function ClassMeetingNotify(c: Classes, status: string) {
//   GetClassesDetailsDescription(c.ClassesDetails).then(async result => {
//     let description = result;
//     if (c.note != null) description += 'Notes: ' + c.note;
//     let builder = icalToolkit.createIcsFileBuilder();
//     builder.spacers = true;
//     builder.NEWLINE_CHAR = '\r\n';
//     builder.throwError = false;
//     builder.ignoreTZIDMismatch = true;
//     builder.timezone = 'america/new_york';
//     builder.tzid = 'america/new_york';
//     builder.method = 'REQUEST';
//     builder.events.push({
//       start: c.startDate,
//       end: c.endDate,
//       transp: 'OPAQUE',
//       summary: c.client.name,
//       location: `${c.address1}, ${c.address2} ${c.city}, ${c.state}, ${c.zip}`,
//       uid: c.meetingUUID,
//       description: description,
//       status: status,
//       attendees: [
//         { name: 'Linda Cannon', email: 'llcannon757@gmail.com' },
//         { name: 'Linda Cannon', email: 'msds@cox.net' },
//         { name: 'Linda Cannon', email: '7181515@cox.net' },
//         { name: 'msds classes', email: 'msdsclasses@outlook.com' }
//       ]
//     });
//     const icsFileContent = builder.toString();
//     if (icsFileContent instanceof Error) return;
//     let transporter = nodemailer.createTransport({
//       host: 'smtp.office365.com',
//       port: 587,
//       secure: false,
//       auth: {
//         user: 'cloud.msdssafety@outlook.com',
//         pass: 'Lopez90200'
//       }
//     });
//     const message = {
//       from: 'gaetan90@outlook.fr',
//       to: ['gaetan90@outlook.fr'],
//       subject: `${c.number} - ${c.client.name} Phone: ${c.client.phoneNumber} EmergPhone: ${c.client.contactPhoneNumber} - ${description}`,
//       text: description,
//       icalEvent: {
//         filename: 'invitation.ics',
//         method: 'request',
//         content: icsFileContent
//       }
//     };
//     transporter.sendMail(message);
//   });
// }
// // Placeholder: routes will be restored below (in separate chunks if needed)
// AppDataSource.initialize().then(async connection => {
//   console.log('📦 Data Source has been initialized!');
//   https.createServer(sslOptions, app).listen(port, () => {
//     console.log(`🚀 Server is running at http://localhost:${port}`);
//   });
// }).catch(error => {
//   console.error('❌ Error during Data Source initialization:', error);
// });
