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
..

Tools

clang-format

The clang-format checking tools is designed to check changed lines of code compared to given git-refs.

Migration Script

The migration tool is designed to reduce repetitive work in the migration process. However, the script is not aiming to convert every thing for you. There are usually some small fixes and major reconstruction required.

How To Use

To run the conversion script, first make sure you have the latest node-addon-api in your node_modules directory.

npm install node-addon-api

Then run the script passing your project directory

node ./node_modules/node-addon-api/tools/conversion.js ./

After finish, recompile and debug things that are missed by the script.

Quick Fixes

Here is the list of things that can be fixed easily.

  1. Change your methods' return value to void if it doesn't return value to JavaScript.
  2. Use . to access attribute or to invoke member function in Napi::Object instead of ->.
  3. Napi::New(env, value); to `Napi::[Type]::New(env, value);

Major Reconstructions

The implementation of Napi::ObjectWrap is significantly different from NAN's. Napi::ObjectWrap takes a pointer to the wrapped object and creates a reference to the wrapped object inside ObjectWrap constructor. Napi::ObjectWrap also associates wrapped object's instance methods to Javascript module instead of static methods like NAN.

So if you use Nan::ObjectWrap in your module, you will need to execute the following steps.

  1. Convert your [ClassName]::New function to a constructor function that takes a Napi::CallbackInfo. Declare it as
[ClassName](const Napi::CallbackInfo& info);

and define it as

[ClassName]::[ClassName](const Napi::CallbackInfo& info) : Napi::ObjectWrap<[ClassName]>(info){
  ...
}

This way, the Napi::ObjectWrap constructor will be invoked after the object has been instantiated and Napi::ObjectWrap can use the this pointer to create a reference to the wrapped object.

  1. Move your original constructor code into the new constructor. Delete your original constructor.
  2. In your class initialization function, associate native methods in the following way.
Napi::FunctionReference constructor;

void [ClassName]::Init(Napi::Env env, Napi::Object exports, Napi::Object module) {
  Napi::HandleScope scope(env);
  Napi::Function ctor = DefineClass(env, "Canvas", {
    InstanceMethod<&[ClassName]::Func1>("Func1"),
    InstanceMethod<&[ClassName]::Func2>("Func2"),
    InstanceAccessor<&[ClassName]::ValueGetter>("Value"),
    StaticMethod<&[ClassName]::StaticMethod>("MethodName"),
    InstanceValue("Value", Napi::[Type]::New(env, value)),
  });

  constructor = Napi::Persistent(ctor);
  constructor .SuppressDestruct();
  exports.Set("[ClassName]", ctor);
}
  1. In function where you need to Unwrap the ObjectWrap in NAN like [ClassName]* native = Nan::ObjectWrap::Unwrap<[ClassName]>(info.This());, use this pointer directly as the unwrapped object as each ObjectWrap instance is associated with a unique object instance.

If you still find issues after following this guide, please leave us an issue describing your problem and we will try to resolve it.