"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
require("dotenv/config");
require("reflect-metadata");
const express_1 = __importDefault(require("express"));
const cors_1 = __importDefault(require("cors"));
const https_1 = __importDefault(require("https"));
const fs_1 = __importDefault(require("fs"));
const data_source_1 = require("./data-source");
const client_1 = __importDefault(require("./routes/client"));
const class_1 = __importDefault(require("./routes/class"));
const courses_router_1 = __importDefault(require("./routes/courses.router"));
const user_router_1 = __importDefault(require("./routes/user.router"));
const student_1 = __importDefault(require("./routes/student"));
const auth_1 = __importDefault(require("./routes/auth"));
const app = (0, express_1.default)();
const port = 3000;
const sslOptions = {
    key: fs_1.default.readFileSync('cert/cloudapi-key.key'),
    cert: fs_1.default.readFileSync('cert/cloudapi-cert.cert')
};
app.use((0, cors_1.default)());
app.use(express_1.default.json());
app.options('*', (0, cors_1.default)());
app.use(express_1.default.static('uploads'));
app.get('/', (req, res) => {
    res.send('Course API 2.0.5 is running 🚀');
});
app.use('/', client_1.default);
app.use('/', class_1.default);
app.use('/', courses_router_1.default);
app.use('/', user_router_1.default);
app.use('/', student_1.default);
app.use('/', auth_1.default);
data_source_1.AppDataSource.initialize()
    .then(() => {
    console.log('📦 Data Source has been initialized!');
    // https_1.default.createServer(sslOptions, app).listen(port, () => {
    //     console.log(`🚀 Server is running at http://localhost:${port}`);
    // });
    app.listen(port, () => {
        console.log(`Server running at http://localhost:${port}`);
    });
})
    .catch((error) => {
    console.error('❌ Error during Data Source initialization:', error);
});
