Saraha App is a backend RESTful API inspired by the Saraha concept, allowing users to receive anonymous messages securely.
Built with Node.js and Express, it follows a modular architecture, separating concerns into:
- Controllers β Handle incoming requests
- Services β Business logic and database operations
- Utilities β Helper functions and encryption
- Validators β Input validation with schemas
The app provides authentication, user management, and anonymous messaging functionality.
- β Secure signup & signin
- π JWT-based access & refresh tokens
- πͺ Logout from single or all devices
- π Track all logged-in devices
- β Terminate a specific device session
- π Logout from all active devices at once
- β Confirm email after registration
- π Resend confirmation email
- π Forgot & reset password flows
- π Resend password reset emails
- π Secure password hashing
- π Change password for authenticated users
- β³ Reset password using time-limited tokens
- π΅ Google OAuth login & registration
- π€ Retrieve authenticated user profile
- βοΈ Update user account information
- β Delete account permanently
- π€ Upload / update profile pictures
- βοΈ Cloudinary integration for file storage
- ποΈ Delete files or folders from cloud storage
- βοΈ Send anonymous messages
- π Receive messages privately
- π Control message visibility (public / private)
- π View public messages
- π Retrieve all users (Admin-only)
- π Retrieve all messages (Admin-only)
- ποΈ Role-based authorization
- π‘οΈ Authentication & authorization middlewares
- β Input validation using schema validators
- π± Environment-based configuration for sensitive data
The API is organized into two main modules:
- Users Module β Handles authentication and user operations
- Messages Module β Handles anonymous messaging
All endpoints are REST APIs returning JSON responses.
Legend:
π’ Public | π Auth-required |β οΈ Admin-only
| Method | Endpoint | Description | Access |
|---|---|---|---|
| POST | /api/users/signup |
Register a new user account | Public |
| POST | /api/users/signin |
Authenticate user & return access/refresh tokens | Public |
| POST | /api/users/logout |
Logout from current device | Auth |
| PUT | /api/users/confirmemail |
Confirm user email via token | Public |
| POST | /api/users/refreshtoken |
Generate new access token using refresh token | Auth |
| POST | /api/users/auth-gmail |
Login/Register via Google OAuth | Public |
| POST | /api/users/forgotpassword |
Send password reset email | Public |
| PUT | /api/users/resetpassword |
Reset password using reset token | Public |
| PUT | /api/users/changePassword |
Change password (authenticated user) | Auth |
| POST | /api/users/resend-confirmation |
Resend email confirmation | Public |
| POST | /api/users/resend-reset-password |
Resend password reset email | Public |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| PUT | /api/users/update |
Update user profile info | Auth |
| DELETE | /api/users/delete |
Delete user account | Auth |
| GET | /api/users/getall |
Retrieve all users | Admin |
| GET | /api/users/getprofile |
Retrieve authenticated user profile | Auth |
| GET | /api/users/getalldevices |
Retrieve all active devices | Auth |
| PUT | /api/users/terminateDevice |
Terminate a specific device | Auth |
| PUT | /api/users/logoutalldevices |
Logout from all devices | Auth |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| POST | /api/users/profilepicture |
Upload/Update profile picture | Auth |
| DELETE | /api/users/deletefilefromcloudinary |
Delete a specific file | Auth |
| DELETE | /api/users/deletefolderfromcloudinary |
Delete a folder | Auth |
| Method | Endpoint | Description | Access |
|---|---|---|---|
| POST | /api/messages/sendmessage/{receiverId} |
Send anonymous message | Auth |
| GET | /api/messages/usermessages |
Retrieve messages received by user | Auth |
| PATCH | /api/messages/messagevisibility/{messageId} |
Change message visibility | Auth |
| GET | /api/messages/getpublicmessages |
Retrieve all public messages | Public |
| GET | /api/messages/getallmessages |
Retrieve all messages | Admin |
POST /api/users/signupPublic β Register new userPOST /api/users/signinPublic β Login userPOST /api/users/logoutAuth β Logout current sessionPUT /api/users/confirmemailPublic β Confirm emailPOST /api/users/refreshtokenAuth β Refresh access tokenPOST /api/users/auth-gmailPublic β Google OAuth login
POST /api/users/forgotpasswordPublic β Send reset emailPUT /api/users/resetpasswordPublic β Reset passwordPUT /api/users/changePasswordAuth β Change password
PUT /api/users/updateAuth β Update profileDELETE /api/users/deleteAuth β Delete accountGET /api/users/getprofileAuth β Get profileGET /api/users/getallAdmin β Get all users
GET /api/users/getalldevicesAuth β Get active devicesPUT /api/users/terminateDeviceAuth β Terminate devicePUT /api/users/logoutalldevicesAuth β Logout all devices
POST /api/users/profilepictureAuth β Upload profile pictureDELETE /api/users/deletefilefromcloudinaryAuth β Delete a fileDELETE /api/users/deletefolderfromcloudinaryAuth β Delete a folder
POST /api/messages/sendmessage/{receiverId}Auth β Send anonymous messageGET /api/messages/usermessagesAuth β Get received messagesPATCH /api/messages/messagevisibility/{messageId}Auth β Change visibilityGET /api/messages/getpublicmessagesPublic β Get public messagesGET /api/messages/getallmessagesAdmin β Get all messages
npm installCreate a .env file in the root directory with values as described above.
npm run devβ‘ The server will start and expose all API endpoints for use.