
- Complete NestJS TypeScript implementation with WebSocket support - Direct messaging (DM) and group chat functionality - End-to-end encryption with AES encryption and key pairs - Media file support (images, videos, audio, documents) up to 100MB - Push notifications with Firebase Cloud Messaging integration - Mention alerts and real-time typing indicators - User authentication with JWT and Passport - SQLite database with TypeORM entities and relationships - Comprehensive API documentation with Swagger/OpenAPI - File upload handling with secure access control - Online/offline status tracking and presence management - Message editing, deletion, and reply functionality - Notification management with automatic cleanup - Health check endpoint for monitoring - CORS configuration for cross-origin requests - Environment-based configuration management - Structured for Flutter SDK integration Features implemented: ✅ Real-time messaging with Socket.IO ✅ User registration and authentication ✅ Direct messages and group chats ✅ Media file uploads and management ✅ End-to-end encryption ✅ Push notifications ✅ Mention alerts ✅ Typing indicators ✅ Message read receipts ✅ Online status tracking ✅ File access control ✅ Comprehensive API documentation Ready for Flutter SDK development and production deployment.
66 lines
1.9 KiB
JavaScript
66 lines
1.9 KiB
JavaScript
"use strict";
|
|
|
|
var rawAsap = require("./raw");
|
|
var freeTasks = [];
|
|
|
|
/**
|
|
* Calls a task as soon as possible after returning, in its own event, with
|
|
* priority over IO events. An exception thrown in a task can be handled by
|
|
* `process.on("uncaughtException") or `domain.on("error")`, but will otherwise
|
|
* crash the process. If the error is handled, all subsequent tasks will
|
|
* resume.
|
|
*
|
|
* @param {{call}} task A callable object, typically a function that takes no
|
|
* arguments.
|
|
*/
|
|
module.exports = asap;
|
|
function asap(task) {
|
|
var rawTask;
|
|
if (freeTasks.length) {
|
|
rawTask = freeTasks.pop();
|
|
} else {
|
|
rawTask = new RawTask();
|
|
}
|
|
rawTask.task = task;
|
|
rawTask.domain = process.domain;
|
|
rawAsap(rawTask);
|
|
}
|
|
|
|
function RawTask() {
|
|
this.task = null;
|
|
this.domain = null;
|
|
}
|
|
|
|
RawTask.prototype.call = function () {
|
|
if (this.domain) {
|
|
this.domain.enter();
|
|
}
|
|
var threw = true;
|
|
try {
|
|
this.task.call();
|
|
threw = false;
|
|
// If the task throws an exception (presumably) Node.js restores the
|
|
// domain stack for the next event.
|
|
if (this.domain) {
|
|
this.domain.exit();
|
|
}
|
|
} finally {
|
|
// We use try/finally and a threw flag to avoid messing up stack traces
|
|
// when we catch and release errors.
|
|
if (threw) {
|
|
// In Node.js, uncaught exceptions are considered fatal errors.
|
|
// Re-throw them to interrupt flushing!
|
|
// Ensure that flushing continues if an uncaught exception is
|
|
// suppressed listening process.on("uncaughtException") or
|
|
// domain.on("error").
|
|
rawAsap.requestFlush();
|
|
}
|
|
// If the task threw an error, we do not want to exit the domain here.
|
|
// Exiting the domain would prevent the domain from catching the error.
|
|
this.task = null;
|
|
this.domain = null;
|
|
freeTasks.push(this);
|
|
}
|
|
};
|
|
|