Skip to content

setting up dev#1

Open
rohitgami11 wants to merge 93 commits intomainfrom
dev
Open

setting up dev#1
rohitgami11 wants to merge 93 commits intomainfrom
dev

Conversation

@rohitgami11
Copy link
Owner

@rohitgami11 rohitgami11 commented Jul 1, 2025

Note

Refactors backend into a new src app with email OTP auth, sockets/Kafka, Cloudinary, and image/static APIs, migrates data model from phone to email, and updates the frontend (auth, posts, chat, images) to the new endpoints and real-time stack.

  • Backend:
    • App Structure: Move server to src/ (app.js, robust index.js for Azure/iisnode) with web.config and static serving under /public.
    • Auth: Add email OTP flow (/auth/*) with JWT, Otp model, token verification, and profile update.
    • Data Model: Switch identifiers from phone to email (User, Post); add Message model with indexes/TTL.
    • Routes/Controllers: New postRoutes, userRoutes (email-based + JWT profile), messageRoutes (CRUD/status/stats), imageRoutes (serve/list images).
    • Real-time & Messaging: Integrate Socket.io (sockets/*) with optional Redis (Valkey) pub/sub; add Kafka config/producer/consumer and messageService for persistence/batching.
    • Images: Cloudinary config/uploader for base64 images; static image endpoints and caching headers.
    • DB/Infra: Safer Mongo connection, index management, env guards; added dependencies (cloudinary, kafkajs, ioredis, jwt, nodemailer/googleapis/resend, socket.io).
    • Remove legacy logger and old routes/postRoutes.js (phone-based).
  • Frontend:
    • Auth: Replace Appwrite phone OTP with backend email OTP + JWT (AuthContext), logout, token storage; update README and EAS env to EXPO_PUBLIC_BASE_URL.
    • Posts/Users: Update services and screens to use email and new /api endpoints; add base64 conversion for image upload; owner actions (edit/delete) and improved image loading placeholders.
    • Real-time: Add SocketContext, AppStateListener, wrap app with provider; rework Chat/Notifications to use Socket.io.
    • UI/Navigation: Tab reordering (Home/Stories/Help & Ask/Chat/Menu), new menu screen, sidebar slides from right; asset paths updated.
    • Images: New imageService to load backend-hosted images with fallbacks.
  • Config:
    • package.json points to src/index.js; add dependencies (socket.io-client, etc.); update app.json asset paths and EAS env vars.

Written by Cursor Bugbot for commit 499d2a1. This will update automatically on new commits. Configure here.

@rohitgami11 rohitgami11 added the eas-build-all:development Create Build for dev label Jul 1, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

router.get('/phone/:phone', userController.getUserByPhone);
router.put('/phone/:phone', userController.createOrUpdateUser);
router.delete('/phone/:phone', userController.deleteUser);
router.get('/email/:email', userController.getUserByEmail);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Middleware Order Blocks Error Handling

Error handling middleware is placed before route definitions, which prevents it from catching errors thrown by the routes below. In Express, error-handling middleware must be defined after all other middleware and routes to function properly.

Fix in Cursor Fix in Web

}
}

// Start periodic buffer flushing
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Unstoppable intervals leak system resources.

The startBufferFlushing method creates an interval with setInterval but never stores the interval ID or provides a way to clear it. This creates a memory leak because the interval will continue running even if the service is destroyed or the application shuts down. The interval should be stored and cleared in a cleanup method.

Fix in Cursor Fix in Web

setMessages((prev) => [...prev, data.message]);
});
_socket.on("message:delivered", (data) => {
console.log("Received message:delivered", data);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Chat Messages Lack Full Context

The chat:receive event handler extracts data.message and adds it to the messages array, but the backend sends the full message object with properties like id, timestamp, senderId, etc. Extracting only data.message loses critical metadata. The frontend should store the complete message object to display sender information, timestamps, and message IDs for proper chat functionality.

Fix in Cursor Fix in Web

console.log("Received notification:", data);
pub.publish("NOTIFICATION_MESSAGES", JSON.stringify(data));
});
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Null Publisher Breaks Notifications

The notification socket handler calls pub.publish() without checking if pub is null. When VALKEY_HOST is not configured, pub is null (as set in socket.js), causing a runtime error when notifications are sent. The handler needs to verify pub exists before publishing.

Fix in Cursor Fix in Web

required: true,
default: Date.now,
expires: 600 // 10 minutes in seconds
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Broken Expiration: Documents Vanish Instantly

The expiresAt field has both default: Date.now and expires: 600. The default sets the expiration time to the current timestamp instead of 10 minutes in the future. Documents will expire immediately upon creation. The default should be Date.now() + 600000 or removed entirely if set programmatically.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eas-build-all:development Create Build for dev

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants