@social.dev/server-sdk 0.0.1-alpha.8 → 0.0.1-alpha.81

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 (345) hide show
  1. package/README.md +696 -40
  2. package/dist/__mocks__/kafka.mock.d.ts +11 -0
  3. package/dist/__mocks__/kafka.mock.js +15 -0
  4. package/dist/__mocks__/kafka.mock.js.map +1 -0
  5. package/dist/app.module.d.ts +4 -4
  6. package/dist/app.module.js +17 -7
  7. package/dist/app.module.js.map +1 -1
  8. package/dist/auth/auth.controller.d.ts +7 -1
  9. package/dist/auth/auth.controller.js +28 -3
  10. package/dist/auth/auth.controller.js.map +1 -1
  11. package/dist/auth/auth.middleware.d.ts +3 -5
  12. package/dist/auth/auth.middleware.js +7 -15
  13. package/dist/auth/auth.middleware.js.map +1 -1
  14. package/dist/auth/auth.module.js +4 -1
  15. package/dist/auth/auth.module.js.map +1 -1
  16. package/dist/auth/auth.service.d.ts +9 -1
  17. package/dist/auth/auth.service.js +34 -2
  18. package/dist/auth/auth.service.js.map +1 -1
  19. package/dist/auth/constants.js +2 -1
  20. package/dist/auth/constants.js.map +1 -1
  21. package/dist/auth/dto/login-success.dto.d.ts +1 -1
  22. package/dist/auth/dto/login-success.dto.js +6 -3
  23. package/dist/auth/dto/login-success.dto.js.map +1 -1
  24. package/dist/auth/dto/register-success.dto.d.ts +3 -0
  25. package/dist/auth/dto/register-success.dto.js +12 -0
  26. package/dist/auth/dto/register-success.dto.js.map +1 -0
  27. package/dist/auth/dto/register.dto.d.ts +6 -0
  28. package/dist/auth/dto/register.dto.js +45 -0
  29. package/dist/auth/dto/register.dto.js.map +1 -0
  30. package/dist/auth/oidc/dto/requests.d.ts +6 -0
  31. package/dist/auth/oidc/dto/requests.js +47 -0
  32. package/dist/auth/oidc/dto/requests.js.map +1 -0
  33. package/dist/auth/oidc/dto/responses.js +1 -1
  34. package/dist/auth/oidc/oidc.controller.d.ts +7 -2
  35. package/dist/auth/oidc/oidc.controller.js +31 -17
  36. package/dist/auth/oidc/oidc.controller.js.map +1 -1
  37. package/dist/auth/oidc/oidc.service.d.ts +9 -4
  38. package/dist/auth/oidc/oidc.service.js +64 -38
  39. package/dist/auth/oidc/oidc.service.js.map +1 -1
  40. package/dist/auth/session/session.controller.js +8 -3
  41. package/dist/auth/session/session.controller.js.map +1 -1
  42. package/dist/auth/session/session.service.d.ts +2 -2
  43. package/dist/auth/session/session.service.js +14 -7
  44. package/dist/auth/session/session.service.js.map +1 -1
  45. package/dist/bootstrap.d.ts +2 -1
  46. package/dist/bootstrap.js +7 -1
  47. package/dist/bootstrap.js.map +1 -1
  48. package/dist/chat/chat.acl.d.ts +3 -0
  49. package/dist/chat/chat.acl.js +50 -0
  50. package/dist/chat/chat.acl.js.map +1 -0
  51. package/dist/chat/chat.controller.d.ts +15 -6
  52. package/dist/chat/chat.controller.js +153 -14
  53. package/dist/chat/chat.controller.js.map +1 -1
  54. package/dist/chat/chat.module.d.ts +3 -0
  55. package/dist/chat/chat.module.js +30 -4
  56. package/dist/chat/chat.module.js.map +1 -1
  57. package/dist/chat/chat.service.d.ts +63 -12
  58. package/dist/chat/chat.service.js +468 -36
  59. package/dist/chat/chat.service.js.map +1 -1
  60. package/dist/chat/dto/add-reaction.dto.d.ts +5 -0
  61. package/dist/chat/dto/add-reaction.dto.js +42 -0
  62. package/dist/chat/dto/add-reaction.dto.js.map +1 -0
  63. package/dist/chat/dto/create-message.dto.d.ts +4 -1
  64. package/dist/chat/dto/create-message.dto.js +23 -1
  65. package/dist/chat/dto/create-message.dto.js.map +1 -1
  66. package/dist/chat/dto/edit-message.dto.d.ts +5 -0
  67. package/dist/chat/dto/edit-message.dto.js +31 -0
  68. package/dist/chat/dto/edit-message.dto.js.map +1 -0
  69. package/dist/chat/dto/responses.dto.d.ts +27 -5
  70. package/dist/chat/dto/responses.dto.js +177 -18
  71. package/dist/chat/dto/responses.dto.js.map +1 -1
  72. package/dist/chat/dto/update-cursor.dto.d.ts +5 -0
  73. package/dist/chat/dto/update-cursor.dto.js +36 -0
  74. package/dist/chat/dto/update-cursor.dto.js.map +1 -0
  75. package/dist/chat/entities/conversation-member.entity.js +1 -1
  76. package/dist/chat/entities/conversation-member.entity.js.map +1 -1
  77. package/dist/chat/entities/conversation.entity.d.ts +4 -0
  78. package/dist/chat/entities/conversation.entity.js +13 -1
  79. package/dist/chat/entities/conversation.entity.js.map +1 -1
  80. package/dist/chat/entities/message.entity.d.ts +8 -0
  81. package/dist/chat/entities/message.entity.js +32 -2
  82. package/dist/chat/entities/message.entity.js.map +1 -1
  83. package/dist/chat/entities/reaction.entity.d.ts +10 -0
  84. package/dist/chat/entities/reaction.entity.js +62 -0
  85. package/dist/chat/entities/reaction.entity.js.map +1 -0
  86. package/dist/chat/entities/read-cursor.entity.d.ts +10 -0
  87. package/dist/chat/entities/read-cursor.entity.js +64 -0
  88. package/dist/chat/entities/read-cursor.entity.js.map +1 -0
  89. package/dist/chat/enums/conversation-type.enum.d.ts +2 -1
  90. package/dist/chat/enums/conversation-type.enum.js +1 -0
  91. package/dist/chat/enums/conversation-type.enum.js.map +1 -1
  92. package/dist/common/decorators/api-paginated-response.d.ts +1 -1
  93. package/dist/common/decorators/api-paginated-response.js +2 -2
  94. package/dist/common/decorators/api-paginated-response.js.map +1 -1
  95. package/dist/common/dto/paginated-response.dto.d.ts +2 -0
  96. package/dist/common/dto/paginated-response.dto.js +14 -3
  97. package/dist/common/dto/paginated-response.dto.js.map +1 -1
  98. package/dist/common/injection-tokens.d.ts +2 -0
  99. package/dist/common/injection-tokens.js +3 -1
  100. package/dist/common/injection-tokens.js.map +1 -1
  101. package/dist/common/utils/cursor.d.ts +2 -0
  102. package/dist/common/utils/cursor.js +12 -0
  103. package/dist/common/utils/cursor.js.map +1 -0
  104. package/dist/community/avatar/avatar.controller.d.ts +11 -0
  105. package/dist/community/avatar/avatar.controller.js +90 -0
  106. package/dist/community/avatar/avatar.controller.js.map +1 -0
  107. package/dist/community/avatar/avatar.service.d.ts +13 -0
  108. package/dist/community/avatar/avatar.service.js +78 -0
  109. package/dist/community/avatar/avatar.service.js.map +1 -0
  110. package/dist/community/community.acl.d.ts +6 -3
  111. package/dist/community/community.acl.js +58 -35
  112. package/dist/community/community.acl.js.map +1 -1
  113. package/dist/community/community.controller.d.ts +8 -5
  114. package/dist/community/community.controller.js +102 -17
  115. package/dist/community/community.controller.js.map +1 -1
  116. package/dist/community/community.module.d.ts +3 -0
  117. package/dist/community/community.module.js +17 -7
  118. package/dist/community/community.module.js.map +1 -1
  119. package/dist/community/community.service.d.ts +26 -6
  120. package/dist/community/community.service.js +152 -23
  121. package/dist/community/community.service.js.map +1 -1
  122. package/dist/community/dto/community-response.dto.d.ts +5 -1
  123. package/dist/community/dto/community-response.dto.js +30 -1
  124. package/dist/community/dto/community-response.dto.js.map +1 -1
  125. package/dist/community/dto/create-community.dto.d.ts +2 -0
  126. package/dist/community/dto/create-community.dto.js +14 -2
  127. package/dist/community/dto/create-community.dto.js.map +1 -1
  128. package/dist/community/dto/update-community.dto.d.ts +2 -0
  129. package/dist/community/dto/update-community.dto.js +15 -1
  130. package/dist/community/dto/update-community.dto.js.map +1 -1
  131. package/dist/community/entities/community-member.entity.js +1 -0
  132. package/dist/community/entities/community-member.entity.js.map +1 -1
  133. package/dist/community/entities/community.entity.d.ts +2 -0
  134. package/dist/community/entities/community.entity.js +11 -1
  135. package/dist/community/entities/community.entity.js.map +1 -1
  136. package/dist/configs/configs.service.d.ts +12 -2
  137. package/dist/configs/configs.service.js.map +1 -1
  138. package/dist/core/context/context.d.ts +3 -0
  139. package/dist/core/context/context.js +15 -0
  140. package/dist/core/context/context.js.map +1 -1
  141. package/dist/core/context/context.store.d.ts +2 -0
  142. package/dist/core/core.module.js +2 -1
  143. package/dist/core/core.module.js.map +1 -1
  144. package/dist/core/event-stream/event-stream-processor.interface.d.ts +8 -0
  145. package/dist/core/event-stream/event-stream-processor.interface.js +3 -0
  146. package/dist/core/event-stream/event-stream-processor.interface.js.map +1 -0
  147. package/dist/core/event-stream/event-stream-processor.service.d.ts +13 -0
  148. package/dist/core/event-stream/event-stream-processor.service.js +60 -0
  149. package/dist/core/event-stream/event-stream-processor.service.js.map +1 -0
  150. package/dist/core/event-stream/event-stream.module.d.ts +11 -0
  151. package/dist/core/event-stream/event-stream.module.js +50 -0
  152. package/dist/core/event-stream/event-stream.module.js.map +1 -0
  153. package/dist/core/event-stream/event-stream.service.d.ts +18 -0
  154. package/dist/core/event-stream/event-stream.service.js +107 -0
  155. package/dist/core/event-stream/event-stream.service.js.map +1 -0
  156. package/dist/core/event-stream/types.d.ts +3 -0
  157. package/dist/core/event-stream/types.js +3 -0
  158. package/dist/core/event-stream/types.js.map +1 -0
  159. package/dist/core/hook/hook.module.d.ts +4 -0
  160. package/dist/core/hook/hook.module.js +30 -0
  161. package/dist/core/hook/hook.module.js.map +1 -0
  162. package/dist/core/hook/hook.service.d.ts +7 -0
  163. package/dist/core/{plugin/plugin-hook.service.js → hook/hook.service.js} +10 -10
  164. package/dist/core/hook/hook.service.js.map +1 -0
  165. package/dist/core/plugin/plugin.module.js +5 -6
  166. package/dist/core/plugin/plugin.module.js.map +1 -1
  167. package/dist/core/websocket/gateway.service.d.ts +24 -0
  168. package/dist/core/websocket/gateway.service.js +150 -0
  169. package/dist/core/websocket/gateway.service.js.map +1 -0
  170. package/dist/core/websocket/websocket.module.d.ts +2 -0
  171. package/dist/core/websocket/websocket.module.js +24 -0
  172. package/dist/core/websocket/websocket.module.js.map +1 -0
  173. package/dist/db.js +2 -1
  174. package/dist/db.js.map +1 -1
  175. package/dist/file-storage/file-storage.service.d.ts +1 -1
  176. package/dist/file-storage/file-storage.service.js +6 -6
  177. package/dist/file-storage/file-storage.service.js.map +1 -1
  178. package/dist/file-storage/utils.d.ts +2 -0
  179. package/dist/file-storage/utils.js +9 -2
  180. package/dist/file-storage/utils.js.map +1 -1
  181. package/dist/index.d.ts +0 -1
  182. package/dist/index.js +1 -3
  183. package/dist/index.js.map +1 -1
  184. package/dist/manage-db.d.ts +1 -0
  185. package/dist/manage-db.js +10 -0
  186. package/dist/manage-db.js.map +1 -0
  187. package/dist/media/dto/media-response.dto.d.ts +2 -0
  188. package/dist/media/dto/media-response.dto.js +15 -2
  189. package/dist/media/dto/media-response.dto.js.map +1 -1
  190. package/dist/media/entities/audio.entity.d.ts +2 -2
  191. package/dist/media/entities/audio.entity.js +2 -2
  192. package/dist/media/entities/audio.entity.js.map +1 -1
  193. package/dist/media/entities/image.entity.d.ts +5 -0
  194. package/dist/media/entities/{post-media.entity.js → image.entity.js} +16 -12
  195. package/dist/media/entities/image.entity.js.map +1 -0
  196. package/dist/media/entities/media.entity.d.ts +6 -0
  197. package/dist/media/entities/media.entity.js +25 -2
  198. package/dist/media/entities/media.entity.js.map +1 -1
  199. package/dist/media/media.acl.d.ts +2 -4
  200. package/dist/media/media.acl.js +22 -1
  201. package/dist/media/media.acl.js.map +1 -1
  202. package/dist/media/media.controller.d.ts +2 -0
  203. package/dist/media/media.controller.js +58 -0
  204. package/dist/media/media.controller.js.map +1 -1
  205. package/dist/media/media.module.js +2 -1
  206. package/dist/media/media.module.js.map +1 -1
  207. package/dist/media/media.service.d.ts +6 -3
  208. package/dist/media/media.service.js +118 -19
  209. package/dist/media/media.service.js.map +1 -1
  210. package/dist/migrations/1757061785934-PushNotificationTokens.d.ts +6 -0
  211. package/dist/migrations/1757061785934-PushNotificationTokens.js +20 -0
  212. package/dist/migrations/1757061785934-PushNotificationTokens.js.map +1 -0
  213. package/dist/migrations/1758623241397-AddUserTimestamps.d.ts +6 -0
  214. package/dist/migrations/1758623241397-AddUserTimestamps.js +16 -0
  215. package/dist/migrations/1758623241397-AddUserTimestamps.js.map +1 -0
  216. package/dist/migrations/1758704603161-UserFollows.d.ts +6 -0
  217. package/dist/migrations/1758704603161-UserFollows.js +18 -0
  218. package/dist/migrations/1758704603161-UserFollows.js.map +1 -0
  219. package/dist/migrations/1759757532702-UpdateCommunityCascades.d.ts +6 -0
  220. package/dist/migrations/1759757532702-UpdateCommunityCascades.js +20 -0
  221. package/dist/migrations/1759757532702-UpdateCommunityCascades.js.map +1 -0
  222. package/dist/migrations/1759766474808-UpdateCommunityTimestamps.d.ts +6 -0
  223. package/dist/migrations/1759766474808-UpdateCommunityTimestamps.js +16 -0
  224. package/dist/migrations/1759766474808-UpdateCommunityTimestamps.js.map +1 -0
  225. package/dist/migrations/1759919335188-CommunityChats.d.ts +6 -0
  226. package/dist/migrations/1759919335188-CommunityChats.js +28 -0
  227. package/dist/migrations/1759919335188-CommunityChats.js.map +1 -0
  228. package/dist/migrations/1760363804673-ChatVoiceNotes.d.ts +6 -0
  229. package/dist/migrations/1760363804673-ChatVoiceNotes.js +24 -0
  230. package/dist/migrations/1760363804673-ChatVoiceNotes.js.map +1 -0
  231. package/dist/migrations/1760444646328-ChatReadCursor.d.ts +6 -0
  232. package/dist/migrations/1760444646328-ChatReadCursor.js +18 -0
  233. package/dist/migrations/1760444646328-ChatReadCursor.js.map +1 -0
  234. package/dist/migrations/1761598291629-AddChatImages.d.ts +6 -0
  235. package/dist/migrations/1761598291629-AddChatImages.js +16 -0
  236. package/dist/migrations/1761598291629-AddChatImages.js.map +1 -0
  237. package/dist/migrations/1761648419807-ChatReactions.d.ts +6 -0
  238. package/dist/migrations/1761648419807-ChatReactions.js +18 -0
  239. package/dist/migrations/1761648419807-ChatReactions.js.map +1 -0
  240. package/dist/migrations/1762953835109-AddChatReplies.d.ts +6 -0
  241. package/dist/migrations/1762953835109-AddChatReplies.js +22 -0
  242. package/dist/migrations/1762953835109-AddChatReplies.js.map +1 -0
  243. package/dist/network/entities/network.entity.js +1 -3
  244. package/dist/network/entities/network.entity.js.map +1 -1
  245. package/dist/network/network.middleware.d.ts +3 -1
  246. package/dist/network/network.middleware.js +12 -4
  247. package/dist/network/network.middleware.js.map +1 -1
  248. package/dist/network/network.module.js +2 -1
  249. package/dist/network/network.module.js.map +1 -1
  250. package/dist/network/network.service.d.ts +4 -2
  251. package/dist/network/network.service.js +16 -6
  252. package/dist/network/network.service.js.map +1 -1
  253. package/dist/notification/dto/delete-push-token.dto.d.ts +3 -0
  254. package/dist/notification/dto/delete-push-token.dto.js +26 -0
  255. package/dist/notification/dto/delete-push-token.dto.js.map +1 -0
  256. package/dist/notification/dto/register-push-token.dto.d.ts +5 -0
  257. package/dist/notification/dto/register-push-token.dto.js +38 -0
  258. package/dist/notification/dto/register-push-token.dto.js.map +1 -0
  259. package/dist/notification/entities/push-token.entity.d.ts +11 -0
  260. package/dist/notification/entities/push-token.entity.js +60 -0
  261. package/dist/notification/entities/push-token.entity.js.map +1 -0
  262. package/dist/notification/enums/push-service.enum.d.ts +6 -0
  263. package/dist/notification/enums/push-service.enum.js +11 -0
  264. package/dist/notification/enums/push-service.enum.js.map +1 -0
  265. package/dist/notification/hook-listener.service.d.ts +13 -0
  266. package/dist/notification/hook-listener.service.js +58 -0
  267. package/dist/notification/hook-listener.service.js.map +1 -0
  268. package/dist/notification/notification.module.d.ts +2 -0
  269. package/dist/notification/notification.module.js +24 -0
  270. package/dist/notification/notification.module.js.map +1 -0
  271. package/dist/notification/push-notification.controller.d.ts +9 -0
  272. package/dist/notification/push-notification.controller.js +69 -0
  273. package/dist/notification/push-notification.controller.js.map +1 -0
  274. package/dist/notification/push-notification.module.d.ts +2 -0
  275. package/dist/notification/push-notification.module.js +27 -0
  276. package/dist/notification/push-notification.module.js.map +1 -0
  277. package/dist/notification/push-notification.service.d.ts +23 -0
  278. package/dist/notification/push-notification.service.js +89 -0
  279. package/dist/notification/push-notification.service.js.map +1 -0
  280. package/dist/post/entities/post.entity.js +3 -3
  281. package/dist/post/entities/post.entity.js.map +1 -1
  282. package/dist/post/post.controller.d.ts +3 -2
  283. package/dist/post/post.controller.js +28 -8
  284. package/dist/post/post.controller.js.map +1 -1
  285. package/dist/post/post.module.js +2 -0
  286. package/dist/post/post.module.js.map +1 -1
  287. package/dist/post/post.service.d.ts +7 -3
  288. package/dist/post/post.service.js +18 -8
  289. package/dist/post/post.service.js.map +1 -1
  290. package/dist/tsconfig.build.tsbuildinfo +1 -1
  291. package/dist/user/avatar/avatar.controller.d.ts +10 -0
  292. package/dist/user/avatar/avatar.controller.js +89 -0
  293. package/dist/user/avatar/avatar.controller.js.map +1 -0
  294. package/dist/user/avatar/avatar.service.d.ts +12 -0
  295. package/dist/user/avatar/avatar.service.js +72 -0
  296. package/dist/user/avatar/avatar.service.js.map +1 -0
  297. package/dist/user/constants.d.ts +1 -0
  298. package/dist/user/constants.js +5 -0
  299. package/dist/user/constants.js.map +1 -0
  300. package/dist/user/dto/update-profile.dto.d.ts +3 -0
  301. package/dist/user/dto/update-profile.dto.js +26 -0
  302. package/dist/user/dto/update-profile.dto.js.map +1 -0
  303. package/dist/user/dto/user-response.dto.d.ts +6 -0
  304. package/dist/user/dto/user-response.dto.js +37 -1
  305. package/dist/user/dto/user-response.dto.js.map +1 -1
  306. package/dist/user/dto/user.dto.d.ts +8 -0
  307. package/dist/user/dto/user.dto.js +21 -0
  308. package/dist/user/dto/user.dto.js.map +1 -0
  309. package/dist/user/entities/user.entity.d.ts +4 -0
  310. package/dist/user/entities/user.entity.js +19 -1
  311. package/dist/user/entities/user.entity.js.map +1 -1
  312. package/dist/user/follow/dto/follow-response.dto.d.ts +4 -0
  313. package/dist/user/follow/dto/follow-response.dto.js +38 -0
  314. package/dist/user/follow/dto/follow-response.dto.js.map +1 -0
  315. package/dist/user/follow/dto/follow.dto.d.ts +4 -0
  316. package/dist/user/follow/dto/follow.dto.js +26 -0
  317. package/dist/user/follow/dto/follow.dto.js.map +1 -0
  318. package/dist/user/follow/entities/follow.entity.d.ts +10 -0
  319. package/dist/user/follow/entities/follow.entity.js +60 -0
  320. package/dist/user/follow/entities/follow.entity.js.map +1 -0
  321. package/dist/user/follow/follow.controller.d.ts +9 -0
  322. package/dist/user/follow/follow.controller.js +56 -0
  323. package/dist/user/follow/follow.controller.js.map +1 -0
  324. package/dist/user/follow/follow.module.d.ts +2 -0
  325. package/dist/user/follow/follow.module.js +26 -0
  326. package/dist/user/follow/follow.module.js.map +1 -0
  327. package/dist/user/follow/follow.service.d.ts +11 -0
  328. package/dist/user/follow/follow.service.js +56 -0
  329. package/dist/user/follow/follow.service.js.map +1 -0
  330. package/dist/user/user.controller.d.ts +4 -1
  331. package/dist/user/user.controller.js +38 -4
  332. package/dist/user/user.controller.js.map +1 -1
  333. package/dist/user/user.module.js +12 -3
  334. package/dist/user/user.module.js.map +1 -1
  335. package/dist/user/user.service.d.ts +12 -5
  336. package/dist/user/user.service.js +49 -11
  337. package/dist/user/user.service.js.map +1 -1
  338. package/package.json +16 -5
  339. package/dist/core/plugin/plugin-hook.service.d.ts +0 -7
  340. package/dist/core/plugin/plugin-hook.service.js.map +0 -1
  341. package/dist/media/entities/post-media.entity.d.ts +0 -5
  342. package/dist/media/entities/post-media.entity.js.map +0 -1
  343. package/dist/user/dto/update-user.dto.d.ts +0 -5
  344. package/dist/user/dto/update-user.dto.js +0 -13
  345. package/dist/user/dto/update-user.dto.js.map +0 -1
package/README.md CHANGED
@@ -1,73 +1,729 @@
1
- ## Social.Dev server
1
+ # @social.dev/server-sdk
2
2
 
3
- ## Project setup
3
+ Server SDK for Social.dev - A comprehensive NestJS-based framework for building scalable social media server applications.
4
+
5
+ ## Overview
6
+
7
+ The `@social.dev/server-sdk` package provides:
8
+
9
+ - 🏗️ **NestJS Framework** - Built on top of NestJS 11 for enterprise-grade applications
10
+ - 🔐 **Authentication System** - Multiple auth methods including OIDC, JWT, and cookie-based sessions
11
+ - 💾 **Database Integration** - TypeORM with PostgreSQL support and migration tools
12
+ - 🔌 **Plugin Architecture** - Extensible plugin system for custom functionality
13
+ - 💬 **Chat System** - Real-time messaging with conversation management
14
+ - 👥 **Community Features** - Sub-communities with member management
15
+ - 📝 **Post Management** - Content creation and interaction system
16
+ - 🔔 **Notifications** - Push notification support with device management
17
+ - 📁 **File Storage** - S3-compatible file storage integration
18
+ - 📊 **API Documentation** - Auto-generated Swagger/OpenAPI documentation
19
+ - 🌐 **Multi-Network Support** - Domain-based network isolation
20
+
21
+ ## Installation
4
22
 
5
23
  ```bash
6
- $ npm install
24
+ # Using pnpm (recommended)
25
+ pnpm add @social.dev/server-sdk
26
+
27
+ # Using npm
28
+ npm install @social.dev/server-sdk
29
+
30
+ # Using yarn
31
+ yarn add @social.dev/server-sdk
32
+ ```
33
+
34
+ ### Prerequisites
35
+
36
+ - Node.js 18 or higher
37
+ - PostgreSQL 14 or higher
38
+ - Redis (optional, for caching)
39
+ - S3-compatible storage (optional, for file uploads)
40
+
41
+ ## Quick Start
42
+
43
+ ### Basic Setup
44
+
45
+ Create a new file `index.ts` in your server application:
46
+
47
+ ```typescript
48
+ import { bootstrap } from '@social.dev/server-sdk/bootstrap';
49
+
50
+ // Initialize the server with minimal configuration
51
+ bootstrap({
52
+ auth: {
53
+ methods: ['password'], // Enable password authentication
54
+ },
55
+ });
56
+ ```
57
+
58
+ ### Advanced Setup with OIDC and Plugins
59
+
60
+ ```typescript
61
+ import { bootstrap } from '@social.dev/server-sdk/bootstrap';
62
+ import { AuthMethodEnum } from '@social.dev/server-sdk/auth/enums/auth-method.enum';
63
+ import { PluginFactory } from '@social.dev/server-sdk/core/plugin/plugin.factory';
64
+ import SocialDevAiPlugin from '@social.dev/plugin-ai';
65
+
66
+ // Register plugins before bootstrap
67
+ PluginFactory.addPlugin(
68
+ SocialDevAiPlugin.forRoot({
69
+ userIds: [3], // User IDs that can access AI features
70
+ }),
71
+ );
72
+
73
+ // Bootstrap the server with comprehensive configuration
74
+ bootstrap({
75
+ auth: {
76
+ methods: [AuthMethodEnum.Oidc, AuthMethodEnum.Password],
77
+ oidc: {
78
+ providers: [
79
+ {
80
+ id: 'keycloak',
81
+ name: 'Company Keycloak',
82
+ issuer: 'https://keycloak.example.com/auth/realms/company',
83
+ clientId: 'social-dev-app',
84
+ clientSecret: process.env.OIDC_CLIENT_SECRET,
85
+ },
86
+ ],
87
+ },
88
+ },
89
+ network: {
90
+ domainAliasMap: {
91
+ localhost: 1,
92
+ 'dev.example.com': 2,
93
+ 'staging.example.com': 3,
94
+ },
95
+ },
96
+ });
97
+ ```
98
+
99
+ ## Configuration
100
+
101
+ ### Environment Variables
102
+
103
+ Create a `.env` file in your project root:
104
+
105
+ ```env
106
+ # Server Configuration
107
+ SOCIAL_DEV_SERVER_PORT=3000
108
+ NODE_ENV=development
109
+
110
+ # Database Configuration
111
+ POSTGRES_HOST=localhost
112
+ POSTGRES_PORT=5432
113
+ POSTGRES_USER=socialdev
114
+ POSTGRES_PASSWORD=yourpassword
115
+ POSTGRES_DB=socialdev_db
116
+
117
+ # Authentication
118
+ JWT_SECRET=your-super-secret-jwt-key
119
+ JWT_EXPIRES_IN=7d
120
+
121
+ # OIDC Configuration (optional)
122
+ OIDC_CLIENT_SECRET=your-oidc-secret
123
+
124
+ # S3 Storage (optional)
125
+ AWS_ACCESS_KEY_ID=your-access-key
126
+ AWS_SECRET_ACCESS_KEY=your-secret-key
127
+ AWS_REGION=us-east-1
128
+ S3_BUCKET_NAME=socialdev-uploads
129
+
130
+ # Push Notifications (optional)
131
+ FCM_SERVER_KEY=your-fcm-server-key
132
+ APNS_KEY_ID=your-apns-key-id
133
+ APNS_TEAM_ID=your-apns-team-id
134
+ ```
135
+
136
+ ### Bootstrap Configuration Options
137
+
138
+ ```typescript
139
+ interface BootstrapConfig {
140
+ auth?: {
141
+ // Available authentication methods
142
+ methods: AuthMethodEnum[];
143
+
144
+ // OIDC provider configuration
145
+ oidc?: {
146
+ providers: OidcProvider[];
147
+ };
148
+
149
+ // JWT configuration
150
+ jwt?: {
151
+ secret?: string;
152
+ expiresIn?: string;
153
+ };
154
+ };
155
+
156
+ network?: {
157
+ // Map domains to network IDs for multi-tenant support
158
+ domainAliasMap: { [domain: string]: number };
159
+ };
160
+
161
+ database?: {
162
+ // Override default database configuration
163
+ host?: string;
164
+ port?: number;
165
+ username?: string;
166
+ password?: string;
167
+ database?: string;
168
+ synchronize?: boolean; // Auto-sync schema (dev only!)
169
+ };
170
+
171
+ storage?: {
172
+ // S3 configuration
173
+ accessKeyId?: string;
174
+ secretAccessKey?: string;
175
+ region?: string;
176
+ bucket?: string;
177
+ };
178
+ }
179
+ ```
180
+
181
+ ## Core Modules
182
+
183
+ ### Authentication Module
184
+
185
+ The SDK supports multiple authentication methods:
186
+
187
+ ```typescript
188
+ // Available authentication methods
189
+ enum AuthMethodEnum {
190
+ Password = 'password',
191
+ Oidc = 'oidc',
192
+ Magic = 'magic', // Magic link via email
193
+ }
194
+
195
+ // OIDC Provider configuration
196
+ interface OidcProvider {
197
+ id: string; // Unique identifier
198
+ name: string; // Display name
199
+ issuer: string; // OIDC issuer URL
200
+ clientId: string; // OAuth client ID
201
+ clientSecret: string; // OAuth client secret
202
+ scope?: string; // OAuth scopes (default: 'openid profile email')
203
+ }
204
+ ```
205
+
206
+ ### User Module
207
+
208
+ User management with profiles and authentication:
209
+
210
+ ```typescript
211
+ // User entity structure
212
+ interface User {
213
+ id: number;
214
+ username: string;
215
+ email: string;
216
+ name?: string;
217
+ bio?: string;
218
+ avatar?: string;
219
+ verified: boolean;
220
+ createdAt: Date;
221
+ updatedAt: Date;
222
+ }
223
+ ```
224
+
225
+ ### Post Module
226
+
227
+ Content creation and management:
228
+
229
+ ```typescript
230
+ // Post entity structure
231
+ interface Post {
232
+ id: number;
233
+ content: string;
234
+ authorId: number;
235
+ parentId?: number; // For replies
236
+ attachments?: MediaAsset[];
237
+ likes: number;
238
+ comments: number;
239
+ shares: number;
240
+ createdAt: Date;
241
+ updatedAt: Date;
242
+ }
243
+ ```
244
+
245
+ ### Chat Module
246
+
247
+ Real-time messaging system:
248
+
249
+ ```typescript
250
+ // Conversation management
251
+ interface Conversation {
252
+ id: number;
253
+ participants: User[];
254
+ lastMessage?: Message;
255
+ unreadCount: number;
256
+ createdAt: Date;
257
+ updatedAt: Date;
258
+ }
259
+
260
+ // Message structure
261
+ interface Message {
262
+ id: number;
263
+ conversationId: number;
264
+ senderId: number;
265
+ content: string;
266
+ attachments?: MediaAsset[];
267
+ readBy: number[];
268
+ createdAt: Date;
269
+ }
270
+ ```
271
+
272
+ ### Community Module
273
+
274
+ Sub-communities (subs) management:
275
+
276
+ ```typescript
277
+ // Sub entity structure
278
+ interface Sub {
279
+ id: number;
280
+ name: string;
281
+ description?: string;
282
+ avatar?: string;
283
+ banner?: string;
284
+ memberCount: number;
285
+ postCount: number;
286
+ createdAt: Date;
287
+ }
288
+
289
+ // Member management
290
+ interface SubMember {
291
+ subId: number;
292
+ userId: number;
293
+ role: 'owner' | 'moderator' | 'member';
294
+ joinedAt: Date;
295
+ }
296
+ ```
297
+
298
+ ### Notification Module
299
+
300
+ Push notification management:
301
+
302
+ ```typescript
303
+ // Device registration
304
+ interface NotificationDevice {
305
+ id: number;
306
+ userId: number;
307
+ token: string;
308
+ platform: 'ios' | 'android' | 'web';
309
+ active: boolean;
310
+ }
311
+
312
+ // Notification sending
313
+ interface Notification {
314
+ userId: number;
315
+ title: string;
316
+ body: string;
317
+ data?: Record<string, any>;
318
+ priority?: 'high' | 'normal';
319
+ }
7
320
  ```
8
321
 
9
- ## Compile and run the project
322
+ ## Plugin System
323
+
324
+ The SDK supports a powerful plugin architecture for extending functionality:
325
+
326
+ ### Creating a Custom Plugin
327
+
328
+ ```typescript
329
+ // plugins/my-plugin/index.ts
330
+ import { Injectable, Module } from '@nestjs/common';
331
+ import { PluginInterface } from '@social.dev/server-sdk/core/plugin/plugin.interface';
332
+
333
+ @Injectable()
334
+ class MyPluginService {
335
+ async processContent(content: string): Promise<string> {
336
+ // Your plugin logic here
337
+ return content.toUpperCase();
338
+ }
339
+ }
340
+
341
+ @Module({
342
+ providers: [MyPluginService],
343
+ exports: [MyPluginService],
344
+ })
345
+ export class MyPlugin implements PluginInterface {
346
+ static forRoot(options?: { enabled?: boolean }) {
347
+ return {
348
+ module: MyPlugin,
349
+ providers: [
350
+ {
351
+ provide: 'MY_PLUGIN_OPTIONS',
352
+ useValue: options || {},
353
+ },
354
+ ],
355
+ };
356
+ }
357
+ }
358
+ ```
359
+
360
+ ### Registering Plugins
361
+
362
+ ```typescript
363
+ import { PluginFactory } from '@social.dev/server-sdk/core/plugin/plugin.factory';
364
+ import { MyPlugin } from './plugins/my-plugin';
365
+
366
+ // Register plugin before bootstrap
367
+ PluginFactory.addPlugin(
368
+ MyPlugin.forRoot({
369
+ enabled: true,
370
+ }),
371
+ );
372
+
373
+ // Then bootstrap the server
374
+ bootstrap({
375
+ /* ... */
376
+ });
377
+ ```
378
+
379
+ ## Database Migrations
380
+
381
+ ### Generating Migrations
382
+
383
+ ```bash
384
+ # Build the SDK first
385
+ pnpm build
386
+
387
+ # Generate a new migration based on entity changes
388
+ npx typeorm migration:generate \
389
+ -d ./dist/manage-db.js \
390
+ ./src/migrations/NewMigration
391
+ ```
392
+
393
+ ### Running Migrations
394
+
395
+ ```bash
396
+ # Run all pending migrations
397
+ npx typeorm migration:run \
398
+ -d ./node_modules/@social.dev/server-sdk/dist/manage-db.js
399
+
400
+ # Revert the last migration
401
+ npx typeorm migration:revert \
402
+ -d ./node_modules/@social.dev/server-sdk/dist/manage-db.js
403
+ ```
404
+
405
+ ### Creating Custom Migrations
406
+
407
+ ```typescript
408
+ // migrations/1234567890-CustomMigration.ts
409
+ import { MigrationInterface, QueryRunner, Table } from 'typeorm';
410
+
411
+ export class CustomMigration1234567890 implements MigrationInterface {
412
+ async up(queryRunner: QueryRunner): Promise<void> {
413
+ await queryRunner.createTable(
414
+ new Table({
415
+ name: 'custom_table',
416
+ columns: [
417
+ {
418
+ name: 'id',
419
+ type: 'int',
420
+ isPrimary: true,
421
+ isGenerated: true,
422
+ generationStrategy: 'increment',
423
+ },
424
+ {
425
+ name: 'name',
426
+ type: 'varchar',
427
+ },
428
+ ],
429
+ }),
430
+ true,
431
+ );
432
+ }
433
+
434
+ async down(queryRunner: QueryRunner): Promise<void> {
435
+ await queryRunner.dropTable('custom_table');
436
+ }
437
+ }
438
+ ```
439
+
440
+ ## API Documentation
441
+
442
+ The SDK automatically generates Swagger/OpenAPI documentation:
10
443
 
11
444
  ```bash
12
- # development
13
- $ npm run start
445
+ # Start your server
446
+ pnpm dev
447
+
448
+ # Access the documentation
449
+ open http://localhost:3000/schema
450
+ ```
451
+
452
+ ### Custom API Endpoints
453
+
454
+ You can add custom endpoints by creating NestJS controllers:
14
455
 
15
- # watch mode
16
- $ npm run start:dev
456
+ ```typescript
457
+ // src/custom/custom.controller.ts
458
+ import { Controller, Get, Post, Body, UseGuards } from '@nestjs/common';
459
+ import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
460
+ import { AuthGuard } from '@social.dev/server-sdk/auth/auth.guard';
17
461
 
18
- # production mode
19
- $ npm run start:prod
462
+ @ApiTags('custom')
463
+ @Controller('custom')
464
+ export class CustomController {
465
+ @Get('public')
466
+ getPublicData() {
467
+ return { message: 'This is public' };
468
+ }
469
+
470
+ @Post('protected')
471
+ @UseGuards(AuthGuard)
472
+ @ApiBearerAuth()
473
+ createProtectedResource(@Body() data: any) {
474
+ return { success: true, data };
475
+ }
476
+ }
477
+
478
+ // Register in a module
479
+ @Module({
480
+ controllers: [CustomController],
481
+ })
482
+ export class CustomModule {}
20
483
  ```
21
484
 
22
- ## Run tests
485
+ ## Development Scripts
23
486
 
24
487
  ```bash
25
- # unit tests
26
- $ npm run test
488
+ # Install dependencies
489
+ pnpm install
490
+
491
+ # Development mode with hot reload
492
+ pnpm dev
493
+
494
+ # Build for production
495
+ pnpm build
496
+
497
+ # Start production server
498
+ pnpm start:prod
27
499
 
28
- # e2e tests
29
- $ npm run test:e2e
500
+ # Run tests
501
+ pnpm test
30
502
 
31
- # test coverage
32
- $ npm run test:cov
503
+ # Run tests with coverage
504
+ pnpm test:cov
505
+
506
+ # Lint code
507
+ pnpm lint
508
+
509
+ # Format code
510
+ pnpm format
33
511
  ```
34
512
 
35
- ## Deployment
513
+ ## Production Deployment
36
514
 
37
- When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
515
+ ### Using PM2
38
516
 
39
- If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
517
+ ```javascript
518
+ // ecosystem.config.js
519
+ module.exports = {
520
+ apps: [
521
+ {
522
+ name: 'social-dev-server',
523
+ script: './dist/index.js',
524
+ instances: 'max',
525
+ exec_mode: 'cluster',
526
+ env: {
527
+ NODE_ENV: 'production',
528
+ SOCIAL_DEV_SERVER_PORT: 3000,
529
+ },
530
+ },
531
+ ],
532
+ };
533
+ ```
40
534
 
41
535
  ```bash
42
- $ npm install -g @nestjs/mau
43
- $ mau deploy
536
+ # Build and start with PM2
537
+ pnpm build
538
+ pm2 start ecosystem.config.js
44
539
  ```
45
540
 
46
- With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
541
+ ### Using Docker
47
542
 
48
- ## Resources
543
+ ```dockerfile
544
+ # Dockerfile
545
+ FROM node:18-alpine AS builder
49
546
 
50
- Check out a few resources that may come in handy when working with NestJS:
547
+ WORKDIR /app
548
+ COPY package*.json pnpm-lock.yaml ./
549
+ RUN npm install -g pnpm
550
+ RUN pnpm install --frozen-lockfile
51
551
 
52
- - Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
53
- - For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
54
- - To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
55
- - Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
56
- - Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
57
- - Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
58
- - To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
59
- - Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
552
+ COPY . .
553
+ RUN pnpm build
60
554
 
61
- ## Support
555
+ FROM node:18-alpine
62
556
 
63
- Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
557
+ WORKDIR /app
558
+ COPY --from=builder /app/dist ./dist
559
+ COPY --from=builder /app/node_modules ./node_modules
560
+ COPY --from=builder /app/package.json ./
64
561
 
65
- ## Stay in touch
562
+ EXPOSE 3000
563
+ CMD ["node", "dist/index.js"]
564
+ ```
565
+
566
+ ### Using Vercel
567
+
568
+ ```json
569
+ // vercel.json
570
+ {
571
+ "version": 2,
572
+ "builds": [
573
+ {
574
+ "src": "api/index.ts",
575
+ "use": "@vercel/node"
576
+ }
577
+ ],
578
+ "routes": [
579
+ {
580
+ "src": "/(.*)",
581
+ "dest": "/api"
582
+ }
583
+ ]
584
+ }
585
+ ```
586
+
587
+ ```typescript
588
+ // api/index.ts
589
+ import { bootstrap } from '@social.dev/server-sdk/bootstrap';
590
+
591
+ export default async function handler(req, res) {
592
+ const app = await bootstrap({
593
+ // Your configuration
594
+ });
595
+ return app.getHttpAdapter().getInstance()(req, res);
596
+ }
597
+ ```
598
+
599
+ ## Multi-Network Support
600
+
601
+ The SDK supports running multiple isolated networks on a single server instance:
602
+
603
+ ```typescript
604
+ bootstrap({
605
+ network: {
606
+ domainAliasMap: {
607
+ 'network1.example.com': 1,
608
+ 'network2.example.com': 2,
609
+ 'api.company.com': 3,
610
+ },
611
+ },
612
+ });
613
+
614
+ // Each domain will have isolated:
615
+ // - Users and authentication
616
+ // - Posts and content
617
+ // - Communities
618
+ // - Chat conversations
619
+ // - Notifications
620
+ ```
621
+
622
+ ## Security Best Practices
623
+
624
+ 1. **Environment Variables**: Never commit `.env` files to version control
625
+ 2. **Database**: Always disable `synchronize` in production
626
+ 3. **CORS**: Configure allowed origins in production
627
+ 4. **Rate Limiting**: Implement rate limiting for API endpoints
628
+ 5. **Input Validation**: Use DTOs with class-validator for all inputs
629
+ 6. **Authentication**: Use strong JWT secrets and appropriate expiration times
630
+ 7. **HTTPS**: Always use HTTPS in production
631
+
632
+ ## TypeScript Support
633
+
634
+ The SDK is written in TypeScript and provides full type definitions:
635
+
636
+ ```typescript
637
+ import type {
638
+ User,
639
+ Post,
640
+ Sub,
641
+ Message,
642
+ Conversation,
643
+ AuthMethodEnum,
644
+ OidcProvider,
645
+ Configs,
646
+ } from '@social.dev/server-sdk';
647
+ ```
66
648
 
67
- - Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
68
- - Website - [https://nestjs.com](https://nestjs.com/)
69
- - Twitter - [@nestframework](https://twitter.com/nestframework)
649
+ ## Examples
650
+
651
+ Check out the [apps/server](../../apps/server) directory for a complete implementation example using the SDK.
652
+
653
+ ### Example Server Implementation
654
+
655
+ ```typescript
656
+ // apps/server/index.ts
657
+ import SocialDevAiPlugin from '@social.dev/plugin-ai';
658
+ import { AuthMethodEnum } from '@social.dev/server-sdk/auth/enums/auth-method.enum';
659
+ import { PluginFactory } from '@social.dev/server-sdk/core/plugin/plugin.factory';
660
+
661
+ // Initialize plugins
662
+ PluginFactory.addPlugin(
663
+ SocialDevAiPlugin.forRoot({
664
+ userIds: [3],
665
+ }),
666
+ );
667
+
668
+ // Initialize the server
669
+ import('@social.dev/server-sdk/bootstrap').then(({ bootstrap }) => {
670
+ bootstrap({
671
+ auth: {
672
+ methods: [AuthMethodEnum.Oidc],
673
+ oidc: {
674
+ providers: [
675
+ {
676
+ id: 'minds-inc',
677
+ name: 'Minds Keycloak',
678
+ issuer: 'https://keycloak.minds.com/auth/realms/minds-inc',
679
+ clientId: 'demo-social-dev',
680
+ clientSecret: process.env.SOCIAL_DEV_OIDC_SECRET,
681
+ },
682
+ ],
683
+ },
684
+ },
685
+ network: {
686
+ domainAliasMap: {
687
+ localhost: 2,
688
+ },
689
+ },
690
+ });
691
+ });
692
+ ```
693
+
694
+ ## Troubleshooting
695
+
696
+ ### Common Issues
697
+
698
+ 1. **Database Connection Failed**
699
+ - Check PostgreSQL is running
700
+ - Verify database credentials in `.env`
701
+ - Ensure database exists
702
+
703
+ 2. **Port Already in Use**
704
+ - Change `SOCIAL_DEV_SERVER_PORT` in `.env`
705
+ - Kill existing process: `lsof -i :3000`
706
+
707
+ 3. **Migration Errors**
708
+ - Build the SDK first: `pnpm build`
709
+ - Check database permissions
710
+ - Review migration SQL for conflicts
711
+
712
+ 4. **OIDC Authentication Failed**
713
+ - Verify issuer URL is accessible
714
+ - Check client ID and secret
715
+ - Ensure redirect URIs are configured
716
+
717
+ ## Contributing
718
+
719
+ Contributions are welcome! Please read our contributing guidelines before submitting PRs.
70
720
 
71
721
  ## License
72
722
 
73
- Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
723
+ MIT
724
+
725
+ ## Support
726
+
727
+ - [Documentation](https://docs.social.dev)
728
+ - [GitHub Issues](https://github.com/socialdotdev/social.dev/issues)
729
+ - [Discord Community](https://discord.gg/socialdev)