
- 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.
76 lines
2.3 KiB
JavaScript
76 lines
2.3 KiB
JavaScript
'use strict';
|
|
const path = require('path');
|
|
const pathType = require('path-type');
|
|
|
|
const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
|
|
|
|
const getPath = (filepath, cwd) => {
|
|
const pth = filepath[0] === '!' ? filepath.slice(1) : filepath;
|
|
return path.isAbsolute(pth) ? pth : path.join(cwd, pth);
|
|
};
|
|
|
|
const addExtensions = (file, extensions) => {
|
|
if (path.extname(file)) {
|
|
return `**/${file}`;
|
|
}
|
|
|
|
return `**/${file}.${getExtensions(extensions)}`;
|
|
};
|
|
|
|
const getGlob = (directory, options) => {
|
|
if (options.files && !Array.isArray(options.files)) {
|
|
throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof options.files}\``);
|
|
}
|
|
|
|
if (options.extensions && !Array.isArray(options.extensions)) {
|
|
throw new TypeError(`Expected \`extensions\` to be of type \`Array\` but received type \`${typeof options.extensions}\``);
|
|
}
|
|
|
|
if (options.files && options.extensions) {
|
|
return options.files.map(x => path.posix.join(directory, addExtensions(x, options.extensions)));
|
|
}
|
|
|
|
if (options.files) {
|
|
return options.files.map(x => path.posix.join(directory, `**/${x}`));
|
|
}
|
|
|
|
if (options.extensions) {
|
|
return [path.posix.join(directory, `**/*.${getExtensions(options.extensions)}`)];
|
|
}
|
|
|
|
return [path.posix.join(directory, '**')];
|
|
};
|
|
|
|
module.exports = async (input, options) => {
|
|
options = {
|
|
cwd: process.cwd(),
|
|
...options
|
|
};
|
|
|
|
if (typeof options.cwd !== 'string') {
|
|
throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
|
|
}
|
|
|
|
const globs = await Promise.all([].concat(input).map(async x => {
|
|
const isDirectory = await pathType.isDirectory(getPath(x, options.cwd));
|
|
return isDirectory ? getGlob(x, options) : x;
|
|
}));
|
|
|
|
return [].concat.apply([], globs); // eslint-disable-line prefer-spread
|
|
};
|
|
|
|
module.exports.sync = (input, options) => {
|
|
options = {
|
|
cwd: process.cwd(),
|
|
...options
|
|
};
|
|
|
|
if (typeof options.cwd !== 'string') {
|
|
throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
|
|
}
|
|
|
|
const globs = [].concat(input).map(x => pathType.isDirectorySync(getPath(x, options.cwd)) ? getGlob(x, options) : x);
|
|
|
|
return [].concat.apply([], globs); // eslint-disable-line prefer-spread
|
|
};
|