diff --git a/server/dist/controller/SubscriberController.js b/server/dist/controller/SubscriberController.js deleted file mode 100644 index ebf0fa2..0000000 --- a/server/dist/controller/SubscriberController.js +++ /dev/null @@ -1,71 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AllSubscribers = exports.SubscriberRegister = void 0; -const SubscriberModel_1 = __importDefault(require("../models/SubscriberModel")); -const Mailer_1 = require("../mailer/Mailer"); -const SubscriberRegister = (req, res) => __awaiter(void 0, void 0, void 0, function* () { - try { - const { email } = req.body; - // Check if the user is already registered - const searchUser = yield SubscriberModel_1.default.find({ email }); - if (searchUser.length > 0) { - res.status(404).send({ message: "User already registered" }); - return; - } - // Create a new subscriber - const newUser = new SubscriberModel_1.default({ email }); - yield newUser.save(); - // Email Template - const Template = ` - - - - - - - Skin AI - - - Embedded Image -

Hello!

-

Thank you for joining us on this journey! We are thrilled to have you as one of our early subscribers at SkinAI. As a prelaunch subscriber, you will be the first to know about our official launch, exclusive updates, and early access opportunities. Here is a quick look at what you can expect from us:

-
-

User Details:

-

Email Address: ${newUser.email}

-

Time: ${new Date()}

-
-

Thank you for reading!

- - `; - // Send Email - yield (0, Mailer_1.SendEmail)(email, "Subscribed Successfully", Template); - res.status(201).send({ message: "Successfully subscribed", data: newUser }); - } - catch (error) { - res.status(500).send({ message: "Server-side error" }); - return; - } -}); -exports.SubscriberRegister = SubscriberRegister; -const AllSubscribers = (req, res) => __awaiter(void 0, void 0, void 0, function* () { - try { - const users = yield SubscriberModel_1.default.find(); - res.status(200).send({ subscribers: users }); - } - catch (error) { - res.status(500).send({ message: error }); - } -}); -exports.AllSubscribers = AllSubscribers; diff --git a/server/dist/controller/UserController.js b/server/dist/controller/UserController.js deleted file mode 100644 index 9e899ab..0000000 --- a/server/dist/controller/UserController.js +++ /dev/null @@ -1,133 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.UserRegister = exports.UserLogin = void 0; -const bcrypt_1 = __importDefault(require("bcrypt")); -const jsonwebtoken_1 = __importDefault(require("jsonwebtoken")); -const UserModel_1 = __importDefault(require("../models/UserModel")); -const Mailer_1 = require("../mailer/Mailer"); -const UserLogin = (req, res) => __awaiter(void 0, void 0, void 0, function* () { - try { - const { email, password } = req.body; - // Find user by email - const user = yield UserModel_1.default.findOne({ email }); - if (!user) { - res.status(400).json({ message: "Invalid credentials!" }); - return; - } - // Compare password - const isMatch = yield bcrypt_1.default.compare(password, user.password); - if (!isMatch) { - res.status(400).json({ message: "Invalid credentials!" }); - return; - } - // Create JWT payload - const payload = { - userId: user._id, - userEmail: user.email, - }; - // Sign token - const secret = process.env.JWT_SECRET; - const token = jsonwebtoken_1.default.sign(payload, secret, { expiresIn: "1d" }); - // Email template - const Template = ` - - - - - - - Login | Skin AI - - - Embedded Image -

Hello! ${user.name}

-

Thank you for logging into your account! We wanted you to acknowledge your recent login attempt was successful.

-
-

Login Details:

-

Email Address: ${user.email}

-

Login Time: ${new Date()}

-
-

Thank you for reading!

- - `; - // Send login success email - yield (0, Mailer_1.SendEmail)(email, "Login Successful", Template); - res.status(200).json({ message: "Logged in successfully", token }); - } - catch (error) { - res.status(500).json({ message: "Server error, please try again later." }); - } -}); -exports.UserLogin = UserLogin; -const UserRegister = (req, res) => __awaiter(void 0, void 0, void 0, function* () { - try { - const { name, email, password, mobile, profileImage } = req.body; - // Validate required fields - if (!name || !email || !password || !mobile) { - res.status(400).json({ message: "All fields are required!" }); - return; - } - // Check if user already exists - const existingUser = yield UserModel_1.default.findOne({ email }); - if (existingUser) { - res.status(400).json({ message: "User already exists!" }); - return; - } - // Hash password - const hashedPassword = yield bcrypt_1.default.hash(password, 10); - // Create new user - const newUser = new UserModel_1.default({ - name, - email, - password: hashedPassword, - mobile, - profileImage: profileImage || "https://default-profile-image-url.com/default.png", - }); - yield newUser.save(); - // Email template - const Template = ` - - - - - - - Register | Skin AI - - - Embedded Image -

Welcome! ${name}

-

Thank you for Registering! We welcome you to our family.

-
-

User Details:

-

Email Address: ${email}

-

Registration Time: ${new Date()}

-

IP Address: ${req.ip}

-
- - `; - // Send registration success email - yield (0, Mailer_1.SendEmail)(email, "Registration Successful", Template); - res.status(201).json({ - message: "User registered successfully", - user: { name, email, mobile, profileImage }, - }); - } - catch (error) { - console.error("Registration error:", error); - res.status(500).json({ message: "Server error, please try again later." }); - } -}); -exports.UserRegister = UserRegister; diff --git a/server/dist/index.js b/server/dist/index.js deleted file mode 100644 index 2b5461d..0000000 --- a/server/dist/index.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const express_1 = __importDefault(require("express")); -const cors_1 = __importDefault(require("cors")); -const body_parser_1 = __importDefault(require("body-parser")); -const path_1 = __importDefault(require("path")); -const dotenv_1 = __importDefault(require("dotenv")); -const db_config_1 = __importDefault(require("./lib/db.config")); // Ensure `db.config.ts` exports `ConnectDB` -const UserRoutes_1 = __importDefault(require("./routes/UserRoutes")); // Ensure `UserRoutes` exports `Router` -const SubscriberRoutes_1 = __importDefault(require("./routes/SubscriberRoutes")); // Ensure `SubscriberRoutes` exports `Router` -// Load environment variables -dotenv_1.default.config(); -const app = (0, express_1.default)(); -// Middleware -app.use((0, cors_1.default)()); -app.use(body_parser_1.default.json()); -/** User Routes */ -app.use("/api/v1/user", UserRoutes_1.default); -app.use("/api/v1/launch", SubscriberRoutes_1.default); -// Serve an HTML file for the root route -app.get("/", (req, res) => { - res.sendFile(path_1.default.join(__dirname, "templates", "serverTemplate.html")); -}); -// Catch-all route for undefined routes -app.use((req, res) => { - res.status(404).json({ message: "Route not found" }); -}); -// Global error handler -app.use((err, req, res, next) => { - console.error(err.stack); - res.status(500).json({ error: "Something went wrong!" }); -}); -// Connect to the database -const mongoURI = process.env.MONGO_URI; -if (!mongoURI) { - console.error("MONGO_URI is not defined in environment variables"); - process.exit(1); // Exit if no connection string is provided -} -(0, db_config_1.default)(mongoURI) - .then(() => { - console.log("Database connected successfully!"); -}) - .catch((error) => { - console.error("Database connection failed:", error); -}); -// Export the app for Vercel or other platforms -exports.default = app; diff --git a/server/dist/lib/db.config.js b/server/dist/lib/db.config.js deleted file mode 100644 index a07ae74..0000000 --- a/server/dist/lib/db.config.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const mongoose_1 = __importDefault(require("mongoose")); -/** - * Connect to MongoDB using the provided URI. - * @param mongoURI - The MongoDB connection string. - * @returns A promise indicating the success or failure of the connection. - */ -const ConnectDB = (mongoURI) => __awaiter(void 0, void 0, void 0, function* () { - try { - yield mongoose_1.default.connect(mongoURI); - console.log("MongoDB connected!"); - } - catch (err) { - console.error("MongoDB connection error:", err); - throw new Error("Failed to connect to MongoDB"); - } -}); -exports.default = ConnectDB; diff --git a/server/dist/mailer/Mailer.js b/server/dist/mailer/Mailer.js deleted file mode 100644 index 3985722..0000000 --- a/server/dist/mailer/Mailer.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.SendEmail = void 0; -const nodemailer_1 = __importDefault(require("nodemailer")); -const promises_1 = __importDefault(require("fs/promises")); -const SendEmail = (email, subject, template) => __awaiter(void 0, void 0, void 0, function* () { - try { - // Read the image file as a buffer - const imageAttachment = yield promises_1.default.readFile("./mailer/media/skin_ai_logo.png"); - // Create a Nodemailer transporter - const transporter = nodemailer_1.default.createTransport({ - host: "smtp.gmail.com", - port: 465, - secure: true, - auth: { - user: process.env.EMAIL_USER, // Email user from environment variables - pass: process.env.EMAIL_PASS, // Email password or app-specific password - }, - }); - // Email options - const mailOptions = { - from: process.env.EMAIL_USER, - to: email, - subject, - html: template, - attachments: [ - { - filename: "skin_ai_logo.png", - content: imageAttachment, - encoding: "base64", - cid: "uniqueImageCID", - }, - ], - }; - // Send email - yield transporter.sendMail(mailOptions); - console.log(`Email sent to ${email} successfully.`); - } - catch (error) { - console.error(`Failed to send email: ${error}`); - throw new Error("Email sending failed. Please check your configuration."); - } -}); -exports.SendEmail = SendEmail; diff --git a/server/dist/models/SubscriberModel.js b/server/dist/models/SubscriberModel.js deleted file mode 100644 index 9444421..0000000 --- a/server/dist/models/SubscriberModel.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || (function () { - var ownKeys = function(o) { - ownKeys = Object.getOwnPropertyNames || function (o) { - var ar = []; - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; - return ar; - }; - return ownKeys(o); - }; - return function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); - __setModuleDefault(result, mod); - return result; - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -const mongoose_1 = __importStar(require("mongoose")); -/** - * Mongoose schema for the Subscriber model. - */ -const SubscriberSchema = new mongoose_1.Schema({ - email: { type: String, unique: true, required: true }, -}); -/** - * Mongoose model for the Subscriber schema. - */ -const Subscriber = mongoose_1.default.model("Subscriber", SubscriberSchema); -exports.default = Subscriber; diff --git a/server/dist/models/UserModel.js b/server/dist/models/UserModel.js deleted file mode 100644 index 24d6a56..0000000 --- a/server/dist/models/UserModel.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || (function () { - var ownKeys = function(o) { - ownKeys = Object.getOwnPropertyNames || function (o) { - var ar = []; - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; - return ar; - }; - return ownKeys(o); - }; - return function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); - __setModuleDefault(result, mod); - return result; - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -const mongoose_1 = __importStar(require("mongoose")); -/** - * Mongoose schema for the User model. - */ -const userSchema = new mongoose_1.Schema({ - name: { type: String, required: true }, - email: { type: String, unique: true, required: true }, - password: { type: String, required: true }, - mobile: { type: String, required: true }, - profileImage: { type: String, required: true }, -}); -/** - * Mongoose model for the User schema. - */ -const User = mongoose_1.default.model("User", userSchema); -exports.default = User; diff --git a/server/dist/routes/SubscriberRoutes.js b/server/dist/routes/SubscriberRoutes.js deleted file mode 100644 index c886549..0000000 --- a/server/dist/routes/SubscriberRoutes.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const express_1 = __importDefault(require("express")); -const SubscriberController_1 = require("../controller/SubscriberController"); -const SubscriberRouter = express_1.default.Router(); -/** - * Route for registering a subscriber. - * Endpoint: POST /register - */ -SubscriberRouter.post("/register", SubscriberController_1.SubscriberRegister); -/** - * Route for fetching all subscribers. - * Endpoint: GET /subscribers - */ -SubscriberRouter.get("/subscribers", SubscriberController_1.AllSubscribers); -exports.default = SubscriberRouter; diff --git a/server/dist/routes/UserRoutes.js b/server/dist/routes/UserRoutes.js deleted file mode 100644 index db853c0..0000000 --- a/server/dist/routes/UserRoutes.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const express_1 = __importDefault(require("express")); -const UserController_1 = require("../controller/UserController"); -const UserRouter = express_1.default.Router(); -// User login route -UserRouter.post("/login", UserController_1.UserLogin); -// User registration route -UserRouter.post("/register", UserController_1.UserRegister); -exports.default = UserRouter;