
- 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.
72 lines
1.9 KiB
JavaScript
72 lines
1.9 KiB
JavaScript
const Minipass = require('minipass')
|
|
const _data = Symbol('_data')
|
|
const _length = Symbol('_length')
|
|
class Collect extends Minipass {
|
|
constructor (options) {
|
|
super(options)
|
|
this[_data] = []
|
|
this[_length] = 0
|
|
}
|
|
write (chunk, encoding, cb) {
|
|
if (typeof encoding === 'function')
|
|
cb = encoding, encoding = 'utf8'
|
|
|
|
if (!encoding)
|
|
encoding = 'utf8'
|
|
|
|
const c = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, encoding)
|
|
this[_data].push(c)
|
|
this[_length] += c.length
|
|
if (cb)
|
|
cb()
|
|
return true
|
|
}
|
|
end (chunk, encoding, cb) {
|
|
if (typeof chunk === 'function')
|
|
cb = chunk, chunk = null
|
|
if (typeof encoding === 'function')
|
|
cb = encoding, encoding = 'utf8'
|
|
if (chunk)
|
|
this.write(chunk, encoding)
|
|
const result = Buffer.concat(this[_data], this[_length])
|
|
super.write(result)
|
|
return super.end(cb)
|
|
}
|
|
}
|
|
module.exports = Collect
|
|
|
|
// it would be possible to DRY this a bit by doing something like
|
|
// this.collector = new Collect() and listening on its data event,
|
|
// but it's not much code, and we may as well save the extra obj
|
|
class CollectPassThrough extends Minipass {
|
|
constructor (options) {
|
|
super(options)
|
|
this[_data] = []
|
|
this[_length] = 0
|
|
}
|
|
write (chunk, encoding, cb) {
|
|
if (typeof encoding === 'function')
|
|
cb = encoding, encoding = 'utf8'
|
|
|
|
if (!encoding)
|
|
encoding = 'utf8'
|
|
|
|
const c = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, encoding)
|
|
this[_data].push(c)
|
|
this[_length] += c.length
|
|
return super.write(chunk, encoding, cb)
|
|
}
|
|
end (chunk, encoding, cb) {
|
|
if (typeof chunk === 'function')
|
|
cb = chunk, chunk = null
|
|
if (typeof encoding === 'function')
|
|
cb = encoding, encoding = 'utf8'
|
|
if (chunk)
|
|
this.write(chunk, encoding)
|
|
const result = Buffer.concat(this[_data], this[_length])
|
|
this.emit('collect', result)
|
|
return super.end(cb)
|
|
}
|
|
}
|
|
module.exports.PassThrough = CollectPassThrough
|