
- 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.
84 lines
1.4 KiB
TypeScript
84 lines
1.4 KiB
TypeScript
import * as fastq from '../'
|
|
import { promise as queueAsPromised } from '../'
|
|
|
|
// Basic example
|
|
|
|
const queue = fastq(worker, 1)
|
|
|
|
queue.push('world', (err, result) => {
|
|
if (err) throw err
|
|
console.log('the result is', result)
|
|
})
|
|
|
|
queue.push('push without cb')
|
|
|
|
queue.concurrency
|
|
|
|
queue.drain()
|
|
|
|
queue.empty = () => undefined
|
|
|
|
console.log('the queue tasks are', queue.getQueue())
|
|
|
|
queue.idle()
|
|
|
|
queue.kill()
|
|
|
|
queue.killAndDrain()
|
|
|
|
queue.length
|
|
|
|
queue.pause()
|
|
|
|
queue.resume()
|
|
|
|
queue.running()
|
|
|
|
queue.saturated = () => undefined
|
|
|
|
queue.unshift('world', (err, result) => {
|
|
if (err) throw err
|
|
console.log('the result is', result)
|
|
})
|
|
|
|
queue.unshift('unshift without cb')
|
|
|
|
function worker(task: any, cb: fastq.done) {
|
|
cb(null, 'hello ' + task)
|
|
}
|
|
|
|
// Generics example
|
|
|
|
interface GenericsContext {
|
|
base: number;
|
|
}
|
|
|
|
const genericsQueue = fastq<GenericsContext, number, string>({ base: 6 }, genericsWorker, 1)
|
|
|
|
genericsQueue.push(7, (err, done) => {
|
|
if (err) throw err
|
|
console.log('the result is', done)
|
|
})
|
|
|
|
genericsQueue.unshift(7, (err, done) => {
|
|
if (err) throw err
|
|
console.log('the result is', done)
|
|
})
|
|
|
|
function genericsWorker(this: GenericsContext, task: number, cb: fastq.done<string>) {
|
|
cb(null, 'the meaning of life is ' + (this.base * task))
|
|
}
|
|
|
|
const queue2 = queueAsPromised(asyncWorker, 1)
|
|
|
|
async function asyncWorker(task: any) {
|
|
return 'hello ' + task
|
|
}
|
|
|
|
async function run () {
|
|
await queue.push(42)
|
|
await queue.unshift(42)
|
|
}
|
|
|
|
run()
|