2.6.1 • Published 2 months ago

active-connect v2.6.1

Weekly downloads
3
License
MIT
Repository
github
Last release
2 months ago

Active-Connect

Tests

Active-Connect is a powerful connection framework designed for smart web-based projects using Node.js, Angular, and WebSockets. It provides decorators and utilities to simplify the integration of Angular with a WebSocket server, making it easier to handle real-time communication between clients and the server.

Features

  • HTTP Server with Decorators: In addition to WebSocket support, Active-Connect allows developers to handle regular HTTP requests with ease. The framework provides decorators for various HTTP methods such as GET, POST, PUT, DELETE, making it simple to define custom routes and functionalities.

  • WebSocket Communication: Active-Connect offers a powerful connection framework that enables real-time communication between clients and the server in smart web-based projects. When a connection accesses data for the first time, a subscription is automatically created. Any modifications to the data are then sent to all subscribing clients, ensuring efficient and automatic updates.

  • Serve Images and Files via HTTP: Active-Connect supports efficient serving of images and files via HTTP. Developers can create custom providers for serving files and images, allowing for dynamic and structured delivery to clients. For instance, developers can generate and serve auto-generated images.

  • Customizable Authenticators: Developers can easily implement their own authenticators by extending the abstract WebsocketAuthenticator class. Within the authenticate method, access to the connection and request objects allows for easy permission checking. Additionally, clients can store session tokens to facilitate secure authentication.

  • Outbound Methods with Subscription Management: Active-Connect provides outbound methods that automatically handle subscription management. Developers can easily send data to clients using the @Outbound(...) decorator. Subscribing clients receive updates whenever relevant data changes, optimizing data distribution and minimizing unnecessary network traffic.

  • Integration Testing: Active-Connect facilitates integration testing for both WebSocket and HTTP functionalities. Developers can thoroughly test the server-side implementation of their application's communication process, primarily using Jest and potentially other testing frameworks. Integration testing is also possible for HTTP methods, further ensuring the reliability of the application.

  • Optimized Real-Time Updates: Active-Connect's WebSocket-based communication reduces the need for frequent polling, resulting in more efficient API requests and real-time data updates. This optimization significantly improves the application's responsiveness and overall user experience.

  • Node-Cron Integration: Active-Connect internally uses the popular Node-Cron library for scheduling cronjobs. Developers can create cronjobs using the @Cron decorator, facilitating the execution of scheduled tasks at specific intervals.

These features collectively empower developers to create smart and efficient web-based projects, handle real-time communication with clients, and optimize data distribution for improved user experiences.

Setup Instructions

To start using Active-Connect in your Node.js project, follow these steps:

  1. Install Active-Connect via npm:
npm install active-connect --save
  1. You can now import the necessary classes and decorators to use Active-Connect in your application:
import { HttpServer, Route, Outbound, GET } from 'active-connect';
  1. Define WebSocket routes, authenticators, filters, and outbound methods using the provided decorators and utilities.

  2. Optionally, implement custom authenticators by extending the WebsocketAuthenticator class. Within the authenticate method, perform permission checks and handle client authentication.

  3. To handle regular HTTP requests, use decorators like @GET, @POST, etc., to define routes and functionalities for the HTTP server.

  4. If you want to serve images or files via HTTP, implement custom providers for serving files and images using decorators like @ProvideFile and @ProvideImage.

  5. Additionally, you can create cronjobs using the @Cron decorator to execute scheduled tasks at specific intervals.

  6. For integration testing, utilize the testing functionalities provided by Active-Connect, primarily using Jest. This ensures thorough testing of both WebSocket and HTTP functionalities.

Details on how Http or Websocket Services can be started can be found within the documentation.

Authenticators

Authenticators are used to verify whether a client has sufficient permissions to perform a specific action. They can be applied to routes, outbounds, or when serving files/images. For example, the @Auth decorator in the provided example is used to enforce authentication for the user.save route.

Filters

Filters are used to associate connections and data with subscription groups. They facilitate efficient data updates by sending data only to clients matching the filter when the associated data changes. Filters are not used for data validation but rather for efficient data distribution.

Outbounds

The @Outbound(...) decorator enables easy sending of data to clients. Outbounds automatically handle updates and send them to subscribing clients whenever a subscription is created.

Regular HTTP Requests

In addition to WebSocket support, Active-Connect allows you to handle regular HTTP requests using decorators. These decorators let you define routes for HTTP methods such as GET, POST, PUT, DELETE.

FileProviders and ImageProviders

Active-Connect supports FileProviders and ImageProviders to efficiently serve files and images to clients. These providers allow you to customize the handling of file and image requests and deliver them in a structured manner.

Usage

Active-Connect is designed for the entire communication process, and this package contains the server-side implementation. To connect an Angular application with an Active-Connect server, developers can use the active-connect-ng2 framework available via npm.

Contributions

Contributions to Active-Connect are welcome! If you have any suggestions, bug fixes, or feature implementations, please feel free to fork the repository, make your changes, and submit a pull request.

Known Limitations

At present, Active-Connect requires the transmission of relatively large amounts of data between the server and clients. To address this, caching mechanisms and partial outbound updates are planned for future releases to optimize data transmission.

Documentation

Comprehensive documentation for Active-Connect can be found at hiptjo.github.io/active-connect. The documentation is split into different sections:

  • http: Contains details concerning HTTP connections, such as registering GET methods, etc.
  • websocket: Contains details about WebSocket connections, including route definitions and usage.
  • content: Contains details on serving images and other content.
  • integration-testing: Provides information about the integration testing process, primarily built for Jest, but other frameworks should work as well.
  • jest: Contains some Jest-specific methods to improve the process of creating tests.

Note: Decorators are generally found in the "Functions" section of each group.

Use Cases

Active-Connect is an ideal solution for any application where data changes frequently and requires real-time updates. Its WebSocket-based communication provides a quick way to implement API requests, reducing the need for frequent polling and improving efficiency.

Scalability

Active-Connect is currently designed to operate in a single container, and its decorator route configurations limit the service to hosting a single HTTP and WebSocket service on one port at a time. Scalability options are being considered for future development.

License

Active-Connect is open-source software licensed under the MIT License. You are free to use, modify, and distribute it in accordance with the terms of the license.

2.6.1

2 months ago

2.6.0

2 months ago

2.5.7

3 months ago

1.11.4

5 months ago

1.11.3

5 months ago

2.4.1

8 months ago

2.4.0

9 months ago

2.4.3

8 months ago

2.4.2

8 months ago

2.4.5

8 months ago

2.4.4

8 months ago

2.0.0

9 months ago

2.5.6

6 months ago

2.5.5

7 months ago

1.11.2

6 months ago

2.3.0

9 months ago

2.3.2

9 months ago

2.3.1

9 months ago

2.3.4

9 months ago

2.3.3

9 months ago

2.4.7

8 months ago

2.4.6

8 months ago

2.4.8

8 months ago

2.2.1

9 months ago

2.2.0

9 months ago

2.2.3

9 months ago

2.2.2

9 months ago

2.1.2

9 months ago

2.1.1

9 months ago

2.5.0

8 months ago

2.1.4

9 months ago

2.1.3

9 months ago

2.5.2

8 months ago

2.1.6

9 months ago

2.5.1

8 months ago

2.1.5

9 months ago

2.5.4

8 months ago

2.5.3

8 months ago

2.1.0

9 months ago

0.2.1

9 months ago

0.2.0

10 months ago

0.2.7

9 months ago

0.2.6

9 months ago

0.2.8

9 months ago

0.2.3

9 months ago

0.2.2

9 months ago

0.2.5

9 months ago

0.2.4

9 months ago

1.11.0

11 months ago

1.11.1

11 months ago

1.8.0

1 year ago

1.7.18

2 years ago

1.7.19

2 years ago

1.9.2

1 year ago

1.9.1

1 year ago

1.9.0

1 year ago

1.10.0

1 year ago

1.7.12

2 years ago

1.7.13

2 years ago

1.7.14

2 years ago

1.7.15

2 years ago

1.7.16

2 years ago

1.7.11

3 years ago

1.7.10

3 years ago

1.7.9

3 years ago

1.7.8

3 years ago

1.7.7

3 years ago

1.7.6

3 years ago

1.7.5

3 years ago

1.7.4

3 years ago

1.7.3

3 years ago

1.7.2

3 years ago

1.7.1

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.5

3 years ago

1.5.4

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.10

3 years ago

1.3.11

3 years ago

1.3.12

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.26

3 years ago

1.2.25

3 years ago

1.2.24

3 years ago

1.2.23

3 years ago

1.2.22

3 years ago

1.2.21

3 years ago

1.2.20

3 years ago

1.2.19

3 years ago

1.2.18

3 years ago

1.2.16

3 years ago

1.2.17

3 years ago

1.2.14

3 years ago

1.2.15

3 years ago

1.2.12

3 years ago

1.2.13

3 years ago

1.2.11

3 years ago

1.2.10

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago