@venizia/ignis-docs 0.0.5-0 → 0.0.6-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/package.json +2 -2
  2. package/wiki/best-practices/architecture-decisions.md +0 -8
  3. package/wiki/best-practices/code-style-standards/control-flow.md +1 -1
  4. package/wiki/best-practices/performance-optimization.md +3 -3
  5. package/wiki/best-practices/security-guidelines.md +2 -2
  6. package/wiki/best-practices/troubleshooting-tips.md +1 -1
  7. package/wiki/guides/core-concepts/components-guide.md +1 -1
  8. package/wiki/guides/core-concepts/components.md +2 -2
  9. package/wiki/guides/core-concepts/dependency-injection.md +1 -1
  10. package/wiki/guides/core-concepts/services.md +1 -1
  11. package/wiki/guides/tutorials/building-a-crud-api.md +1 -1
  12. package/wiki/guides/tutorials/ecommerce-api.md +2 -2
  13. package/wiki/guides/tutorials/realtime-chat.md +725 -461
  14. package/wiki/guides/tutorials/testing.md +1 -1
  15. package/wiki/references/base/bootstrapping.md +0 -2
  16. package/wiki/references/base/components.md +2 -2
  17. package/wiki/references/base/controllers.md +0 -1
  18. package/wiki/references/base/datasources.md +1 -1
  19. package/wiki/references/base/dependency-injection.md +1 -1
  20. package/wiki/references/base/filter-system/quick-reference.md +0 -14
  21. package/wiki/references/base/middlewares.md +24 -80
  22. package/wiki/references/base/providers.md +0 -9
  23. package/wiki/references/base/services.md +0 -1
  24. package/wiki/references/components/authentication/api.md +444 -0
  25. package/wiki/references/components/authentication/errors.md +177 -0
  26. package/wiki/references/components/authentication/index.md +571 -0
  27. package/wiki/references/components/authentication/usage.md +781 -0
  28. package/wiki/references/components/health-check.md +292 -103
  29. package/wiki/references/components/index.md +14 -12
  30. package/wiki/references/components/mail/api.md +505 -0
  31. package/wiki/references/components/mail/errors.md +176 -0
  32. package/wiki/references/components/mail/index.md +535 -0
  33. package/wiki/references/components/mail/usage.md +404 -0
  34. package/wiki/references/components/request-tracker.md +229 -25
  35. package/wiki/references/components/socket-io/api.md +1051 -0
  36. package/wiki/references/components/socket-io/errors.md +119 -0
  37. package/wiki/references/components/socket-io/index.md +410 -0
  38. package/wiki/references/components/socket-io/usage.md +322 -0
  39. package/wiki/references/components/static-asset/api.md +261 -0
  40. package/wiki/references/components/static-asset/errors.md +89 -0
  41. package/wiki/references/components/static-asset/index.md +617 -0
  42. package/wiki/references/components/static-asset/usage.md +364 -0
  43. package/wiki/references/components/swagger.md +390 -110
  44. package/wiki/references/components/template/api-page.md +125 -0
  45. package/wiki/references/components/template/errors-page.md +100 -0
  46. package/wiki/references/components/template/index.md +104 -0
  47. package/wiki/references/components/template/setup-page.md +134 -0
  48. package/wiki/references/components/template/single-page.md +132 -0
  49. package/wiki/references/components/template/usage-page.md +127 -0
  50. package/wiki/references/components/websocket/api.md +508 -0
  51. package/wiki/references/components/websocket/errors.md +123 -0
  52. package/wiki/references/components/websocket/index.md +453 -0
  53. package/wiki/references/components/websocket/usage.md +475 -0
  54. package/wiki/references/helpers/cron/index.md +224 -0
  55. package/wiki/references/helpers/crypto/index.md +537 -0
  56. package/wiki/references/helpers/env/index.md +214 -0
  57. package/wiki/references/helpers/error/index.md +232 -0
  58. package/wiki/references/helpers/index.md +16 -15
  59. package/wiki/references/helpers/inversion/index.md +608 -0
  60. package/wiki/references/helpers/logger/index.md +600 -0
  61. package/wiki/references/helpers/network/api.md +986 -0
  62. package/wiki/references/helpers/network/index.md +620 -0
  63. package/wiki/references/helpers/queue/index.md +589 -0
  64. package/wiki/references/helpers/redis/index.md +495 -0
  65. package/wiki/references/helpers/socket-io/api.md +497 -0
  66. package/wiki/references/helpers/socket-io/index.md +513 -0
  67. package/wiki/references/helpers/storage/api.md +705 -0
  68. package/wiki/references/helpers/storage/index.md +583 -0
  69. package/wiki/references/helpers/template/index.md +66 -0
  70. package/wiki/references/helpers/template/single-page.md +126 -0
  71. package/wiki/references/helpers/testing/index.md +510 -0
  72. package/wiki/references/helpers/types/index.md +512 -0
  73. package/wiki/references/helpers/uid/index.md +272 -0
  74. package/wiki/references/helpers/websocket/api.md +736 -0
  75. package/wiki/references/helpers/websocket/index.md +574 -0
  76. package/wiki/references/helpers/worker-thread/index.md +470 -0
  77. package/wiki/references/quick-reference.md +6 -23
  78. package/wiki/references/src-details/core.md +1 -2
  79. package/wiki/references/utilities/jsx.md +1 -8
  80. package/wiki/references/utilities/statuses.md +4 -9
  81. package/wiki/references/components/authentication.md +0 -476
  82. package/wiki/references/components/mail.md +0 -687
  83. package/wiki/references/components/socket-io.md +0 -145
  84. package/wiki/references/components/static-asset.md +0 -1277
  85. package/wiki/references/helpers/cron.md +0 -108
  86. package/wiki/references/helpers/crypto.md +0 -132
  87. package/wiki/references/helpers/env.md +0 -83
  88. package/wiki/references/helpers/error.md +0 -97
  89. package/wiki/references/helpers/inversion.md +0 -176
  90. package/wiki/references/helpers/logger.md +0 -296
  91. package/wiki/references/helpers/network.md +0 -396
  92. package/wiki/references/helpers/queue.md +0 -150
  93. package/wiki/references/helpers/redis.md +0 -142
  94. package/wiki/references/helpers/socket-io.md +0 -122
  95. package/wiki/references/helpers/storage.md +0 -665
  96. package/wiki/references/helpers/testing.md +0 -133
  97. package/wiki/references/helpers/types.md +0 -167
  98. package/wiki/references/helpers/uid.md +0 -167
  99. package/wiki/references/helpers/worker-thread.md +0 -178
@@ -1,145 +0,0 @@
1
- # Socket.IO Component
2
-
3
- Real-time, bidirectional, event-based communication using Socket.IO.
4
-
5
- ## Quick Reference
6
-
7
- | Component | Purpose |
8
- |-----------|---------|
9
- | **SocketIOComponent** | Sets up Socket.IO server and bindings |
10
- | **SocketIOServerHelper** | Encapsulates Socket.IO server instance |
11
- | **Redis Adapter** | Enables horizontal scaling with Redis |
12
- | **Redis Emitter** | Emit events from other processes/services |
13
-
14
- ### Required Bindings
15
-
16
- | Binding Key | Type | Purpose |
17
- |-------------|------|---------|
18
- | `SERVER_OPTIONS` | `ISocketIOOptions` | Socket.IO server configuration (optional) |
19
- | `REDIS_CONNECTION` | `DefaultRedisHelper` | Redis instance for scaling |
20
- | `AUTHENTICATE_HANDLER` | `Function` | Authenticate socket connections |
21
- | `CLIENT_CONNECTED_HANDLER` | `Function` | Handle successful connections (optional) |
22
-
23
- ### Use Cases
24
-
25
- - Live notifications
26
- - Real-time chat
27
- - Collaborative editing
28
- - Live data streams
29
-
30
- ## Architecture Components
31
-
32
- - **`SocketIOComponent`**: Sets up Socket.IO server, binds `SocketIOServerHelper` to DI
33
- - **`SocketIOServerHelper`**: Wraps Socket.IO server, provides interaction methods
34
- - **`@socket.io/redis-adapter`**: Scales Socket.IO with Redis
35
- - **`@socket.io/redis-emitter`**: Emits events from external processes
36
- - **Integration**: Works with HTTP server and authentication system
37
-
38
- ## Implementation Details
39
-
40
- ### Tech Stack
41
-
42
- - **Socket.IO**
43
- - **`@socket.io/redis-adapter`**
44
- - **`@socket.io/redis-emitter`**
45
- - **`ioredis`** (if using Redis)
46
-
47
- ### Configuration
48
-
49
- To use the Socket.IO component, you need to provide a few things in your application's DI container:
50
-
51
- - **`SocketIOBindingKeys.SERVER_OPTIONS`**: (Optional) Custom options for the Socket.IO server.
52
- - **`SocketIOBindingKeys.REDIS_CONNECTION`**: An instance of `DefaultRedisHelper` (or a compatible class) for the Redis adapter.
53
- - **`SocketIOBindingKeys.AUTHENTICATE_HANDLER`**: A function to handle the authentication of new socket connections.
54
- - **`SocketIOBindingKeys.CLIENT_CONNECTED_HANDLER`**: (Optional) A function to be called when a client is successfully connected and authenticated.
55
-
56
- ### Code Samples
57
-
58
- #### 1. Setting up the Socket.IO Component
59
-
60
- In your `src/application.ts`:
61
-
62
- ```typescript
63
- import {
64
- SocketIOComponent,
65
- SocketIOBindingKeys,
66
- RedisHelper, // Your Redis helper
67
- BaseApplication,
68
- ValueOrPromise,
69
- IHandshake,
70
- } from '@venizia/ignis';
71
-
72
- // ...
73
-
74
- export class Application extends BaseApplication {
75
- // ...
76
-
77
- preConfigure(): ValueOrPromise<void> {
78
- // ...
79
-
80
- // 1. Bind Redis connection
81
- const redis = new RedisHelper({
82
- name: 'redis',
83
- host: 'localhost',
84
- port: 6379,
85
- password: 'password',
86
- });
87
- this.bind({ key: SocketIOBindingKeys.REDIS_CONNECTION }).toValue(redis);
88
-
89
- // 2. Bind authentication handler
90
- const authenticateFn = async (handshake: IHandshake) => {
91
- const { token } = handshake.auth;
92
- // Your custom authentication logic here
93
- // e.g., verify a JWT
94
- return !!token;
95
- };
96
- this.bind({ key: SocketIOBindingKeys.AUTHENTICATE_HANDLER }).toValue(authenticateFn);
97
-
98
- // 3. Register the component
99
- this.component(SocketIOComponent);
100
- }
101
-
102
- // ...
103
- }
104
- ```
105
-
106
- #### 2. Emitting Events
107
-
108
- You can get the `SocketIOServerHelper` instance from the container and use it to emit events.
109
-
110
- ```typescript
111
- import { SocketIOServerHelper, SocketIOBindingKeys, inject } from '@venizia/ignis';
112
-
113
- // ... in a service or controller
114
-
115
- @inject({ key: SocketIOBindingKeys.SOCKET_IO_INSTANCE })
116
- private io: SocketIOServerHelper;
117
-
118
- sendNotification(userId: string, message: string) {
119
- this.io.send({
120
- destination: userId, // Room or socket ID
121
- payload: {
122
- topic: 'notification',
123
- data: { message },
124
- },
125
- });
126
- }
127
- ```
128
-
129
- ## See Also
130
-
131
- - **Related Concepts:**
132
- - [Components Overview](/guides/core-concepts/components) - Component system basics
133
- - [Application](/guides/core-concepts/application/) - Registering components
134
-
135
- - **Other Components:**
136
- - [Components Index](./index) - All built-in components
137
-
138
- - **References:**
139
- - [Socket.IO Helper](/references/helpers/socket-io) - Socket.IO utilities
140
-
141
- - **External Resources:**
142
- - [Socket.IO Documentation](https://socket.io/docs/) - WebSocket library
143
-
144
- - **Tutorials:**
145
- - [Real-Time Chat](/guides/tutorials/realtime-chat) - Building a chat app with Socket.IO