Automated Action 545563e776 Implement comprehensive real-time chat API with NestJS
- 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.
2025-06-21 17:13:05 +00:00

84 lines
2.2 KiB
JavaScript

const t = require('tap')
const MPS = require('../')
t.test('ok if size checks out', t => {
const mps = new MPS({ size: 4 })
mps.write(Buffer.from('a').toString('hex'), 'hex')
mps.write(Buffer.from('sd'))
mps.end('f')
return mps.concat().then(data => t.equal(data.toString(), 'asdf'))
})
t.test('error if size exceeded', t => {
const mps = new MPS({ size: 1 })
mps.on('error', er => {
t.match(er, {
message: 'Bad data size: expected 1 bytes, but got 4',
found: 4,
expect: 1,
code: 'EBADSIZE',
name: 'SizeError',
})
t.end()
})
mps.write('asdf')
})
t.test('error if size is not met', t => {
const mps = new MPS({ size: 999 })
t.throws(() => mps.end(), {
message: 'Bad data size: expected 999 bytes, but got 0',
found: 0,
name: 'SizeError',
expect: 999,
code: 'EBADSIZE',
})
t.end()
})
t.test('error if non-string/buffer is written', t => {
const mps = new MPS({size:1})
mps.on('error', er => {
t.match(er, {
message: 'MinipassSized streams only work with string and buffer data'
})
t.end()
})
mps.write({some:'object'})
})
t.test('projectiles', t => {
t.throws(() => new MPS(), {
message: 'invalid expected size: undefined'
}, 'size is required')
t.throws(() => new MPS({size: true}), {
message: 'invalid expected size: true'
}, 'size must be number')
t.throws(() => new MPS({size: NaN}), {
message: 'invalid expected size: NaN'
}, 'size must not be NaN')
t.throws(() => new MPS({size:1.2}), {
message: 'invalid expected size: 1.2'
}, 'size must be integer')
t.throws(() => new MPS({size: Infinity}), {
message: 'invalid expected size: Infinity'
}, 'size must be finite')
t.throws(() => new MPS({size: -1}), {
message: 'invalid expected size: -1'
}, 'size must be positive')
t.throws(() => new MPS({objectMode: true}), {
message: 'MinipassSized streams only work with string and buffer data'
}, 'no objectMode')
t.throws(() => new MPS({size: Number.MAX_SAFE_INTEGER + 1000000}), {
message: 'invalid expected size: 9007199255740992'
})
t.end()
})
t.test('exports SizeError class', t => {
t.isa(MPS.SizeError, 'function')
t.isa(MPS.SizeError.prototype, Error)
t.end()
})