Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions backend/app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const dotenv = require('dotenv');
dotenv.config();

const express = require('express')
const mongoose = require('mongoose')
const cors = require('cors')
const dotenv = require('dotenv');
const rateLimit = require('express-rate-limit');
const app = express();
app.set('trust proxy', 1);
const GC = require('./utils/GC');
dotenv.config();

// Middleware
app.use(cors());
Expand Down
22 changes: 21 additions & 1 deletion backend/config/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,33 @@ const dotenv = require("dotenv");
dotenv.config()

if (!process.env.REDIS_URL) {
if (process.env.NODE_ENV !== 'production') {
console.log("DEBUG: ENV KEYS:", Object.keys(process.env));
}
throw new Error("REDIS_URL is not defined in .env");
}

const redis = new Redis(process.env.REDIS_URL);
const redis = new Redis(process.env.REDIS_URL, {
retryStrategy(times) {
const delay = Math.min(times * 50, 2000);
if (times > 3) {
console.warn("⚠️ Redis: Max retries reached. Caching will be disabled.");
return null; // Stop retrying
}
return delay;
},
maxRetriesPerRequest: null // Allow requests to fail if not connected
});

redis.on('ready', () => {
console.log('ioredis client is connected and ready.');
});

redis.on('error', (err) => {
console.error('❌ Redis Connection Error:', err.message);
console.error(' -> Ensure Redis is running on localhost:6379');
console.error(' -> Windows: Use WSL or a Memurai/Redis port.');
// Do not throw; lets the app continue without caching if needed
});

module.exports = redis;
4 changes: 2 additions & 2 deletions backend/controllers/auth.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ module.exports.sendOtp = async (req, res) => {
try {
const { email } = onlyEmailSchema.parse(req.body);
const otp = Math.floor(100000 + Math.random() * 900000);
// Secure: OTP logging removed
const existingUser = await Developer.findOne({ email });
if (!existingUser) return res.status(400).json({ error: "User not found" });

Expand Down Expand Up @@ -150,8 +151,7 @@ module.exports.verifyOtp = async (req, res) => {
const existingOtp = await otpSchema.findOne({ userId: existingUser._id });
if (!existingOtp) return res.status(400).json({ error: "You havn't requested an OTP" });

console.log(existingOtp.otp);
console.log(otp);
// Secure: OTP verification logging removed
if (existingOtp.otp !== otp) return res.status(400).json({ error: "Incorrect OTP" });

await existingOtp.deleteOne();
Expand Down
6 changes: 6 additions & 0 deletions backend/services/redisCaching.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const redis = require("../config/redis");

async function setProjectByApiKeyCache(api, project) {
if (redis.status !== "ready") return;
try {
const data = JSON.stringify(project);
await redis.set(
Expand All @@ -15,6 +16,7 @@ async function setProjectByApiKeyCache(api, project) {
}

async function getProjectByApiKeyCache(api) {
if (redis.status !== "ready") return null;
try {
const data = await redis.get(`project:apikey:${api}`);
if (!data) return null;
Expand All @@ -28,6 +30,7 @@ async function getProjectByApiKeyCache(api) {
}

async function deleteProjectByApiKeyCache(api) {
if (redis.status !== "ready") return;
try {
await redis.del(`project:apikey:${api}`);
} catch (err) {
Expand All @@ -37,6 +40,7 @@ async function deleteProjectByApiKeyCache(api) {


async function setProjectById(id, project) {
if (redis.status !== "ready") return;
try {
const data = JSON.stringify(project);
await redis.set(
Expand All @@ -52,6 +56,7 @@ async function setProjectById(id, project) {


async function getProjectById(id) {
if (redis.status !== "ready") return null;
try {
const data = await redis.get(`project:id:${id}`);
if (!data) return null;
Expand All @@ -65,6 +70,7 @@ async function getProjectById(id) {


async function deleteProjectById(id) {
if (redis.status !== "ready") return;
try {
await redis.del(`project:id:${id}`);
} catch (err) {
Expand Down
77 changes: 77 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"preview": "vite preview"
},
"dependencies": {
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/modifiers": "^9.0.0",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@tailwindcss/vite": "^4.1.18",
"@tanstack/react-table": "^8.21.3",
"axios": "^1.13.2",
Expand Down
Loading
Loading