@stone-js/starters 0.8.3

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 (352) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +101 -0
  3. package/basic-react-declarative/LICENSE +21 -0
  4. package/basic-react-declarative/README.md +39 -0
  5. package/basic-react-declarative/app/Application.tsx +89 -0
  6. package/basic-react-declarative/assets/css/index.css +26 -0
  7. package/basic-react-declarative/package.json +39 -0
  8. package/basic-react-declarative/public/logo.png +0 -0
  9. package/basic-react-declarative/tests/Application.spec.ts +96 -0
  10. package/basic-react-declarative/tests/__snapshots__/Application.spec.ts.snap +3 -0
  11. package/basic-react-declarative/tsconfig.json +33 -0
  12. package/basic-react-declarative/vitest.config.ts +24 -0
  13. package/basic-react-imperative/LICENSE +21 -0
  14. package/basic-react-imperative/README.md +39 -0
  15. package/basic-react-imperative/app/Application.tsx +89 -0
  16. package/basic-react-imperative/assets/css/index.css +26 -0
  17. package/basic-react-imperative/package.json +39 -0
  18. package/basic-react-imperative/public/logo.png +0 -0
  19. package/basic-react-imperative/tests/Application.spec.ts +80 -0
  20. package/basic-react-imperative/tests/__snapshots__/Application.spec.ts.snap +3 -0
  21. package/basic-react-imperative/tsconfig.json +33 -0
  22. package/basic-react-imperative/vitest.config.ts +24 -0
  23. package/basic-service-declarative/LICENSE +21 -0
  24. package/basic-service-declarative/README.md +39 -0
  25. package/basic-service-declarative/app/Application.ts +56 -0
  26. package/basic-service-declarative/package.json +34 -0
  27. package/basic-service-declarative/tests/Application.spec.ts +60 -0
  28. package/basic-service-declarative/tsconfig.json +25 -0
  29. package/basic-service-declarative/vitest.config.ts +24 -0
  30. package/basic-service-imperative/LICENSE +21 -0
  31. package/basic-service-imperative/README.md +39 -0
  32. package/basic-service-imperative/app/Application.ts +60 -0
  33. package/basic-service-imperative/package.json +34 -0
  34. package/basic-service-imperative/tests/Application.spec.ts +52 -0
  35. package/basic-service-imperative/tsconfig.json +25 -0
  36. package/basic-service-imperative/vitest.config.ts +24 -0
  37. package/continuum-showcase/README.md +44 -0
  38. package/continuum-showcase/app/env.d.ts +34 -0
  39. package/continuum-showcase/app/layouts/MainLayout.tsx +20 -0
  40. package/continuum-showcase/app/pages/BlogPostPage.tsx +62 -0
  41. package/continuum-showcase/app/pages/HomePage.tsx +58 -0
  42. package/continuum-showcase/package.json +25 -0
  43. package/continuum-showcase/stone.config.mjs +20 -0
  44. package/full-react-declarative/.env.example +1 -0
  45. package/full-react-declarative/.env.public.example +1 -0
  46. package/full-react-declarative/LICENSE +21 -0
  47. package/full-react-declarative/README.md +39 -0
  48. package/full-react-declarative/app/Application.ts +85 -0
  49. package/full-react-declarative/app/clients/AxiosClient.ts +136 -0
  50. package/full-react-declarative/app/clients/CommentClient.ts +61 -0
  51. package/full-react-declarative/app/clients/PostClient.ts +90 -0
  52. package/full-react-declarative/app/clients/SecurityClient.ts +66 -0
  53. package/full-react-declarative/app/clients/UserClient.ts +97 -0
  54. package/full-react-declarative/app/components/ChangePasswordForm/ChangePasswordForm.tsx +50 -0
  55. package/full-react-declarative/app/components/CommentForm/CommentForm.tsx +37 -0
  56. package/full-react-declarative/app/components/CommentItem/CommentItem.tsx +42 -0
  57. package/full-react-declarative/app/components/CommentWidget/CommentWidget.tsx +95 -0
  58. package/full-react-declarative/app/components/LoginForm/LoginForm.css +0 -0
  59. package/full-react-declarative/app/components/LoginForm/LoginForm.tsx +71 -0
  60. package/full-react-declarative/app/components/PostDetails/PostDetails.tsx +44 -0
  61. package/full-react-declarative/app/components/PostForm/PostForm.css +0 -0
  62. package/full-react-declarative/app/components/PostForm/PostForm.tsx +47 -0
  63. package/full-react-declarative/app/components/PostItem/PostItem.css +0 -0
  64. package/full-react-declarative/app/components/PostItem/PostItem.tsx +34 -0
  65. package/full-react-declarative/app/components/RegisterForm/RegisterForm.tsx +110 -0
  66. package/full-react-declarative/app/components/UserForm/UserForm.tsx +47 -0
  67. package/full-react-declarative/app/configurations/AppConfiguration.ts +17 -0
  68. package/full-react-declarative/app/error-pages/DefaultErrorPage/DefaultErrorPage.css +0 -0
  69. package/full-react-declarative/app/error-pages/DefaultErrorPage/DefaultErrorPage.tsx +52 -0
  70. package/full-react-declarative/app/error-pages/ForbiddenErrorPage/ForbiddenErrorPage.css +0 -0
  71. package/full-react-declarative/app/error-pages/ForbiddenErrorPage/ForbiddenErrorPage.tsx +53 -0
  72. package/full-react-declarative/app/error-pages/NotFoundErrorPage/NotFoundErrorPage.css +0 -0
  73. package/full-react-declarative/app/error-pages/NotFoundErrorPage/NotFoundErrorPage.tsx +54 -0
  74. package/full-react-declarative/app/error-pages/UnauthorizedErrorPage/UnauthorizedErrorPage.css +0 -0
  75. package/full-react-declarative/app/error-pages/UnauthorizedErrorPage/UnauthorizedErrorPage.tsx +53 -0
  76. package/full-react-declarative/app/errors/ForbiddenError.ts +11 -0
  77. package/full-react-declarative/app/errors/PostNotFoundError.ts +11 -0
  78. package/full-react-declarative/app/errors/UnauthorizedError.ts +11 -0
  79. package/full-react-declarative/app/errors/UserNotFoundError.ts +11 -0
  80. package/full-react-declarative/app/events/UserEvent.ts +18 -0
  81. package/full-react-declarative/app/layout/AppLayout/AppLayout.css +20 -0
  82. package/full-react-declarative/app/layout/AppLayout/AppLayout.tsx +101 -0
  83. package/full-react-declarative/app/layout/ErrorLayout/ErrorLayout.css +0 -0
  84. package/full-react-declarative/app/layout/ErrorLayout/ErrorLayout.tsx +41 -0
  85. package/full-react-declarative/app/layout/SecurityLayout/SecurityLayout.css +0 -0
  86. package/full-react-declarative/app/layout/SecurityLayout/SecurityLayout.tsx +39 -0
  87. package/full-react-declarative/app/middleware/AuthMiddleware.ts +85 -0
  88. package/full-react-declarative/app/models/Comment.ts +31 -0
  89. package/full-react-declarative/app/models/Post.ts +22 -0
  90. package/full-react-declarative/app/models/User.ts +62 -0
  91. package/full-react-declarative/app/pages/home/HomePage.tsx +44 -0
  92. package/full-react-declarative/app/pages/login/LoginPage.css +0 -0
  93. package/full-react-declarative/app/pages/login/LoginPage.tsx +73 -0
  94. package/full-react-declarative/app/pages/posts/CreatePostPage/CreatePostPage.css +0 -0
  95. package/full-react-declarative/app/pages/posts/CreatePostPage/CreatePostPage.tsx +67 -0
  96. package/full-react-declarative/app/pages/posts/PostPage/PostPage.tsx +60 -0
  97. package/full-react-declarative/app/pages/posts/ShowPostPage/ShowPostPage.tsx +83 -0
  98. package/full-react-declarative/app/pages/posts/UpdatePostPage/UpdatePostPage.tsx +77 -0
  99. package/full-react-declarative/app/pages/register/RegisterPage.tsx +68 -0
  100. package/full-react-declarative/app/pages/users/CreateUserPage.tsx +48 -0
  101. package/full-react-declarative/app/pages/users/ShowUserPage.tsx +62 -0
  102. package/full-react-declarative/app/pages/users/UpdateUserPage.tsx +57 -0
  103. package/full-react-declarative/app/pages/users/UserPage.tsx +57 -0
  104. package/full-react-declarative/app/providers/AppServiceProvider.ts +43 -0
  105. package/full-react-declarative/app/services/CommentService.ts +59 -0
  106. package/full-react-declarative/app/services/PostService.ts +108 -0
  107. package/full-react-declarative/app/services/SecurityService.ts +80 -0
  108. package/full-react-declarative/app/services/TokenService.ts +116 -0
  109. package/full-react-declarative/app/services/UserService.ts +126 -0
  110. package/full-react-declarative/app/utils.ts +17 -0
  111. package/full-react-declarative/assets/css/index.css +301 -0
  112. package/full-react-declarative/assets/img/logo.png +0 -0
  113. package/full-react-declarative/package.json +46 -0
  114. package/full-react-declarative/public/logo.png +0 -0
  115. package/full-react-declarative/public/vite.svg +1 -0
  116. package/full-react-declarative/stone.config.mjs +12 -0
  117. package/full-react-declarative/tsconfig.json +29 -0
  118. package/full-react-declarative/vitest.config.ts +24 -0
  119. package/full-react-imperative/.env.example +1 -0
  120. package/full-react-imperative/.env.public.example +1 -0
  121. package/full-react-imperative/LICENSE +21 -0
  122. package/full-react-imperative/README.md +39 -0
  123. package/full-react-imperative/app/Application.ts +79 -0
  124. package/full-react-imperative/app/clients/AxiosClient.ts +124 -0
  125. package/full-react-imperative/app/clients/CommentClient.ts +57 -0
  126. package/full-react-imperative/app/clients/PostClient.ts +86 -0
  127. package/full-react-imperative/app/clients/SecurityClient.ts +60 -0
  128. package/full-react-imperative/app/clients/UserClient.ts +93 -0
  129. package/full-react-imperative/app/clients/contracts/IAxiosClient.ts +97 -0
  130. package/full-react-imperative/app/clients/contracts/ICommentClient.ts +31 -0
  131. package/full-react-imperative/app/clients/contracts/IPostClient.ts +55 -0
  132. package/full-react-imperative/app/clients/contracts/ISecurityClient.ts +33 -0
  133. package/full-react-imperative/app/clients/contracts/IUserClient.ts +61 -0
  134. package/full-react-imperative/app/components/ChangePasswordForm/ChangePasswordForm.tsx +50 -0
  135. package/full-react-imperative/app/components/CommentForm/CommentForm.css +35 -0
  136. package/full-react-imperative/app/components/CommentForm/CommentForm.tsx +45 -0
  137. package/full-react-imperative/app/components/CommentItem/CommentItem.css +74 -0
  138. package/full-react-imperative/app/components/CommentItem/CommentItem.tsx +62 -0
  139. package/full-react-imperative/app/components/CommentWidget/CommentWidget.css +25 -0
  140. package/full-react-imperative/app/components/CommentWidget/CommentWidget.tsx +119 -0
  141. package/full-react-imperative/app/components/Dropdown/Dropdown.css +52 -0
  142. package/full-react-imperative/app/components/Dropdown/Dropdown.tsx +40 -0
  143. package/full-react-imperative/app/components/LayoutHeader/LayoutHeader.css +62 -0
  144. package/full-react-imperative/app/components/LayoutHeader/LayoutHeader.tsx +61 -0
  145. package/full-react-imperative/app/components/LayoutLeftMenu/LayoutLeftMenu.css +25 -0
  146. package/full-react-imperative/app/components/LayoutLeftMenu/LayoutLeftMenu.tsx +32 -0
  147. package/full-react-imperative/app/components/LoginForm/LoginForm.css +0 -0
  148. package/full-react-imperative/app/components/LoginForm/LoginForm.tsx +71 -0
  149. package/full-react-imperative/app/components/NotificationBadge/NotificationBadge.css +41 -0
  150. package/full-react-imperative/app/components/NotificationBadge/NotificationBadge.tsx +63 -0
  151. package/full-react-imperative/app/components/PostCard/PostCard.css +129 -0
  152. package/full-react-imperative/app/components/PostCard/PostCard.tsx +65 -0
  153. package/full-react-imperative/app/components/PostForm/PostForm.css +92 -0
  154. package/full-react-imperative/app/components/PostForm/PostForm.tsx +76 -0
  155. package/full-react-imperative/app/components/PostSkeleton/PostSkeleton.css +65 -0
  156. package/full-react-imperative/app/components/PostSkeleton/PostSkeleton.tsx +25 -0
  157. package/full-react-imperative/app/components/PostWidget/PostWidget.tsx +95 -0
  158. package/full-react-imperative/app/components/ProfileForm/ProfileForm.css +84 -0
  159. package/full-react-imperative/app/components/ProfileForm/ProfileForm.tsx +79 -0
  160. package/full-react-imperative/app/components/RegisterForm/RegisterForm.tsx +110 -0
  161. package/full-react-imperative/app/components/RightAsidePanel/RightAsidePanel.css +32 -0
  162. package/full-react-imperative/app/components/RightAsidePanel/RightAsidePanel.tsx +62 -0
  163. package/full-react-imperative/app/components/SettingsForm/SettingsForm.css +126 -0
  164. package/full-react-imperative/app/components/SettingsForm/SettingsForm.tsx +86 -0
  165. package/full-react-imperative/app/components/UserAvatar/UserAvatar.css +18 -0
  166. package/full-react-imperative/app/components/UserAvatar/UserAvatar.tsx +60 -0
  167. package/full-react-imperative/app/components/UserBadge/UserBadge.css +33 -0
  168. package/full-react-imperative/app/components/UserBadge/UserBadge.tsx +49 -0
  169. package/full-react-imperative/app/components/UserCard/UserCard.css +70 -0
  170. package/full-react-imperative/app/components/UserCard/UserCard.tsx +43 -0
  171. package/full-react-imperative/app/configurations/AppConfiguration.ts +19 -0
  172. package/full-react-imperative/app/error-pages/DefaultErrorPage/DefaultErrorPage.css +0 -0
  173. package/full-react-imperative/app/error-pages/DefaultErrorPage/DefaultErrorPage.tsx +41 -0
  174. package/full-react-imperative/app/error-pages/ForbiddenErrorPage/ForbiddenErrorPage.css +0 -0
  175. package/full-react-imperative/app/error-pages/ForbiddenErrorPage/ForbiddenErrorPage.tsx +42 -0
  176. package/full-react-imperative/app/error-pages/NotFoundErrorPage/NotFoundErrorPage.css +0 -0
  177. package/full-react-imperative/app/error-pages/NotFoundErrorPage/NotFoundErrorPage.tsx +49 -0
  178. package/full-react-imperative/app/error-pages/UnauthorizedErrorPage/UnauthorizedErrorPage.css +0 -0
  179. package/full-react-imperative/app/error-pages/UnauthorizedErrorPage/UnauthorizedErrorPage.tsx +42 -0
  180. package/full-react-imperative/app/errors/ForbiddenError.ts +11 -0
  181. package/full-react-imperative/app/errors/PostNotFoundError.ts +11 -0
  182. package/full-react-imperative/app/errors/UnauthorizedError.ts +11 -0
  183. package/full-react-imperative/app/errors/UserNotFoundError.ts +11 -0
  184. package/full-react-imperative/app/events/UserEvent.ts +18 -0
  185. package/full-react-imperative/app/layout/AppLayout/AppLayout.css +106 -0
  186. package/full-react-imperative/app/layout/AppLayout/AppLayout.tsx +48 -0
  187. package/full-react-imperative/app/layout/ErrorLayout/ErrorLayout.css +0 -0
  188. package/full-react-imperative/app/layout/ErrorLayout/ErrorLayout.tsx +45 -0
  189. package/full-react-imperative/app/layout/SecurityLayout/SecurityLayout.css +0 -0
  190. package/full-react-imperative/app/layout/SecurityLayout/SecurityLayout.tsx +43 -0
  191. package/full-react-imperative/app/layout/SettingsLayout/SettingsLayout.css +99 -0
  192. package/full-react-imperative/app/layout/SettingsLayout/SettingsLayout.tsx +44 -0
  193. package/full-react-imperative/app/middleware/AuthMiddleware.ts +56 -0
  194. package/full-react-imperative/app/models/Comment.ts +35 -0
  195. package/full-react-imperative/app/models/Post.ts +27 -0
  196. package/full-react-imperative/app/models/User.ts +68 -0
  197. package/full-react-imperative/app/pages/Settings/SettingsPage.tsx +23 -0
  198. package/full-react-imperative/app/pages/home/HomePage.tsx +58 -0
  199. package/full-react-imperative/app/pages/login/LoginPage.css +0 -0
  200. package/full-react-imperative/app/pages/login/LoginPage.tsx +65 -0
  201. package/full-react-imperative/app/pages/posts/ShowPostPage/ShowPostPage.tsx +64 -0
  202. package/full-react-imperative/app/pages/posts/UpdatePostPage/UpdatePostPage.tsx +56 -0
  203. package/full-react-imperative/app/pages/register/RegisterPage.tsx +71 -0
  204. package/full-react-imperative/app/pages/users/ShowUserPage/ShowUserPage.css +64 -0
  205. package/full-react-imperative/app/pages/users/ShowUserPage/ShowUserPage.tsx +104 -0
  206. package/full-react-imperative/app/pages/users/UpdateUserPage/UpdateUserPage.css +0 -0
  207. package/full-react-imperative/app/pages/users/UpdateUserPage/UpdateUserPage.tsx +43 -0
  208. package/full-react-imperative/app/pages/users/UserPage/UserPage.css +31 -0
  209. package/full-react-imperative/app/pages/users/UserPage/UserPage.tsx +59 -0
  210. package/full-react-imperative/app/pages/utils.ts +67 -0
  211. package/full-react-imperative/app/providers/AppServiceProvider.ts +40 -0
  212. package/full-react-imperative/app/services/CommentService.ts +53 -0
  213. package/full-react-imperative/app/services/PostService.ts +102 -0
  214. package/full-react-imperative/app/services/SecurityService.ts +72 -0
  215. package/full-react-imperative/app/services/TokenService.ts +108 -0
  216. package/full-react-imperative/app/services/UserService.ts +115 -0
  217. package/full-react-imperative/app/services/contracts/ICommentService.ts +30 -0
  218. package/full-react-imperative/app/services/contracts/IPostService.ts +65 -0
  219. package/full-react-imperative/app/services/contracts/ISecurityService.ts +39 -0
  220. package/full-react-imperative/app/services/contracts/ITokenService.ts +44 -0
  221. package/full-react-imperative/app/services/contracts/IUserService.ts +70 -0
  222. package/full-react-imperative/app/utils.ts +31 -0
  223. package/full-react-imperative/assets/css/index.css +301 -0
  224. package/full-react-imperative/assets/img/logo.png +0 -0
  225. package/full-react-imperative/package.json +48 -0
  226. package/full-react-imperative/public/logo.png +0 -0
  227. package/full-react-imperative/public/vite.svg +1 -0
  228. package/full-react-imperative/stone.config.mjs +12 -0
  229. package/full-react-imperative/tsconfig.json +29 -0
  230. package/full-react-imperative/vitest.config.ts +24 -0
  231. package/full-service-declarative/.env.example +2 -0
  232. package/full-service-declarative/LICENSE +21 -0
  233. package/full-service-declarative/README.md +65 -0
  234. package/full-service-declarative/app/Application.ts +327 -0
  235. package/full-service-declarative/app/commands/ListSessionsCommand.ts +70 -0
  236. package/full-service-declarative/app/commands/ListUsersCommand.ts +56 -0
  237. package/full-service-declarative/app/configurations/AppConfiguration.ts +52 -0
  238. package/full-service-declarative/app/configurations/UserLiveConfiguration.ts +28 -0
  239. package/full-service-declarative/app/database/DatabaseClient.ts +43 -0
  240. package/full-service-declarative/app/database/schema.ts +43 -0
  241. package/full-service-declarative/app/error-handlers/SecurityErrorHandler.ts +61 -0
  242. package/full-service-declarative/app/errors/CredentialsError.ts +12 -0
  243. package/full-service-declarative/app/events/UserEvent.ts +17 -0
  244. package/full-service-declarative/app/handlers/CommentEventHandler.ts +103 -0
  245. package/full-service-declarative/app/handlers/PostEventHandler.ts +104 -0
  246. package/full-service-declarative/app/handlers/SecurityEventHandler.ts +108 -0
  247. package/full-service-declarative/app/handlers/UserEventHandler.ts +159 -0
  248. package/full-service-declarative/app/listeners/UserEventListener.ts +35 -0
  249. package/full-service-declarative/app/middleware/AuthMiddleware.ts +54 -0
  250. package/full-service-declarative/app/models/Comment.ts +38 -0
  251. package/full-service-declarative/app/models/Post.ts +50 -0
  252. package/full-service-declarative/app/models/Session.ts +14 -0
  253. package/full-service-declarative/app/models/User.ts +77 -0
  254. package/full-service-declarative/app/providers/DrizzleServiceProvider.ts +59 -0
  255. package/full-service-declarative/app/repositories/CommentRepository.ts +155 -0
  256. package/full-service-declarative/app/repositories/PostRepository.ts +138 -0
  257. package/full-service-declarative/app/repositories/SessionRepository.ts +123 -0
  258. package/full-service-declarative/app/repositories/UserRepository.ts +99 -0
  259. package/full-service-declarative/app/services/CommentService.ts +112 -0
  260. package/full-service-declarative/app/services/PostService.ts +100 -0
  261. package/full-service-declarative/app/services/SecurityService.ts +232 -0
  262. package/full-service-declarative/app/services/SessionService.ts +130 -0
  263. package/full-service-declarative/app/services/UserService.ts +110 -0
  264. package/full-service-declarative/app/subscribers/UserEventSubscriber.ts +38 -0
  265. package/full-service-declarative/drizzle.config.ts +13 -0
  266. package/full-service-declarative/package.json +48 -0
  267. package/full-service-declarative/stone.config.mjs +12 -0
  268. package/full-service-declarative/tsconfig.json +25 -0
  269. package/full-service-declarative/vitest.config.ts +24 -0
  270. package/full-service-imperative/.env.example +2 -0
  271. package/full-service-imperative/LICENSE +21 -0
  272. package/full-service-imperative/README.md +65 -0
  273. package/full-service-imperative/app/Application.ts +317 -0
  274. package/full-service-imperative/app/commands/ListSessionsCommand.ts +54 -0
  275. package/full-service-imperative/app/commands/ListUsersCommand.ts +42 -0
  276. package/full-service-imperative/app/configurations/AppConfiguration.ts +44 -0
  277. package/full-service-imperative/app/configurations/UserLiveConfiguration.ts +26 -0
  278. package/full-service-imperative/app/database/DatabaseClient.ts +39 -0
  279. package/full-service-imperative/app/database/schema.ts +43 -0
  280. package/full-service-imperative/app/error-handlers/SecurityErrorHandler.ts +58 -0
  281. package/full-service-imperative/app/errors/CredentialsError.ts +12 -0
  282. package/full-service-imperative/app/events/UserEvent.ts +17 -0
  283. package/full-service-imperative/app/handlers/CommentEventHandler.ts +99 -0
  284. package/full-service-imperative/app/handlers/PostEventHandler.ts +99 -0
  285. package/full-service-imperative/app/handlers/SecurityEventHandler.ts +83 -0
  286. package/full-service-imperative/app/handlers/UserEventHandler.ts +132 -0
  287. package/full-service-imperative/app/listeners/UserEventListener.ts +23 -0
  288. package/full-service-imperative/app/middleware/AuthMiddleware.ts +44 -0
  289. package/full-service-imperative/app/models/Comment.ts +38 -0
  290. package/full-service-imperative/app/models/Post.ts +50 -0
  291. package/full-service-imperative/app/models/Session.ts +14 -0
  292. package/full-service-imperative/app/models/User.ts +77 -0
  293. package/full-service-imperative/app/providers/DrizzleServiceProvider.ts +56 -0
  294. package/full-service-imperative/app/repositories/CommentRepository.ts +148 -0
  295. package/full-service-imperative/app/repositories/PostRepository.ts +130 -0
  296. package/full-service-imperative/app/repositories/SessionRepository.ts +115 -0
  297. package/full-service-imperative/app/repositories/UserRepository.ts +91 -0
  298. package/full-service-imperative/app/repositories/contracts/ICommentRepository.ts +72 -0
  299. package/full-service-imperative/app/repositories/contracts/IPostRepository.ts +63 -0
  300. package/full-service-imperative/app/repositories/contracts/ISessionRepository.ts +65 -0
  301. package/full-service-imperative/app/repositories/contracts/IUserRepository.ts +55 -0
  302. package/full-service-imperative/app/services/CommentService.ts +109 -0
  303. package/full-service-imperative/app/services/PostService.ts +97 -0
  304. package/full-service-imperative/app/services/SecurityService.ts +224 -0
  305. package/full-service-imperative/app/services/SessionService.ts +124 -0
  306. package/full-service-imperative/app/services/UserService.ts +105 -0
  307. package/full-service-imperative/app/services/contracts/ICommentService.ts +62 -0
  308. package/full-service-imperative/app/services/contracts/IPostService.ts +53 -0
  309. package/full-service-imperative/app/services/contracts/ISecurityService.ts +97 -0
  310. package/full-service-imperative/app/services/contracts/ISessionService.ts +73 -0
  311. package/full-service-imperative/app/services/contracts/IUserService.ts +57 -0
  312. package/full-service-imperative/app/subscribers/UserEventSubscriber.ts +28 -0
  313. package/full-service-imperative/drizzle.config.ts +13 -0
  314. package/full-service-imperative/package.json +48 -0
  315. package/full-service-imperative/stone.config.mjs +12 -0
  316. package/full-service-imperative/tsconfig.json +25 -0
  317. package/full-service-imperative/vitest.config.ts +24 -0
  318. package/package.json +225 -0
  319. package/standard-react-declarative/LICENSE +21 -0
  320. package/standard-react-declarative/README.md +39 -0
  321. package/standard-react-declarative/app/Application.ts +45 -0
  322. package/standard-react-declarative/app/pages/welcome/WelcomePage.tsx +57 -0
  323. package/standard-react-declarative/app/services/WelcomeService.ts +38 -0
  324. package/standard-react-declarative/assets/css/index.css +26 -0
  325. package/standard-react-declarative/package.json +42 -0
  326. package/standard-react-declarative/tsconfig.json +33 -0
  327. package/standard-react-declarative/vitest.config.ts +24 -0
  328. package/standard-react-imperative/LICENSE +21 -0
  329. package/standard-react-imperative/README.md +39 -0
  330. package/standard-react-imperative/app/Application.ts +41 -0
  331. package/standard-react-imperative/app/pages/welcome/WelcomePage.tsx +50 -0
  332. package/standard-react-imperative/app/services/WelcomeService.ts +38 -0
  333. package/standard-react-imperative/assets/css/index.css +26 -0
  334. package/standard-react-imperative/package.json +42 -0
  335. package/standard-react-imperative/tsconfig.json +33 -0
  336. package/standard-react-imperative/vitest.config.ts +24 -0
  337. package/standard-service-declarative/LICENSE +21 -0
  338. package/standard-service-declarative/README.md +39 -0
  339. package/standard-service-declarative/app/Application.ts +39 -0
  340. package/standard-service-declarative/app/handlers/WelcomeEventHandler.ts +45 -0
  341. package/standard-service-declarative/app/services/WelcomeService.ts +38 -0
  342. package/standard-service-declarative/package.json +36 -0
  343. package/standard-service-declarative/tsconfig.json +25 -0
  344. package/standard-service-declarative/vitest.config.ts +24 -0
  345. package/standard-service-imperative/LICENSE +21 -0
  346. package/standard-service-imperative/README.md +39 -0
  347. package/standard-service-imperative/app/Application.ts +11 -0
  348. package/standard-service-imperative/app/handlers/welcomeEventHandler.ts +31 -0
  349. package/standard-service-imperative/app/services/welcomeService.ts +38 -0
  350. package/standard-service-imperative/package.json +35 -0
  351. package/standard-service-imperative/tsconfig.json +25 -0
  352. package/standard-service-imperative/vitest.config.ts +24 -0
@@ -0,0 +1,73 @@
1
+ import { UserModel } from '../../models/User'
2
+ import { Session } from '../../models/Session'
3
+
4
+ /**
5
+ * Session Service contract
6
+ */
7
+ export interface ISessionService {
8
+ /**
9
+ * Finds all sessions.
10
+ *
11
+ * @param limit - The limit of sessions to list.
12
+ * @returns The list of sessions.
13
+ */
14
+ list: (limit: number) => Promise<Session[]>
15
+
16
+ /**
17
+ * Finds sessions by user.
18
+ *
19
+ * @param user - The user to look up.
20
+ * @param limit - The limit of sessions to list.
21
+ * @returns The list of sessions.
22
+ */
23
+ getByUser: (user: UserModel, limit: number) => Promise<Session[]>
24
+
25
+ /**
26
+ * Finds a session by ID.
27
+ *
28
+ * @param id - The session ID to look up.
29
+ * @returns The session or `undefined` if not found.
30
+ */
31
+ getById: (id: number) => Promise<Session | undefined>
32
+
33
+ /**
34
+ * Finds the latest session of a user.
35
+ *
36
+ * @param user - The user to look up.
37
+ * @returns The latest session or `undefined`.
38
+ */
39
+ getLatest: (user: UserModel) => Promise<Session | undefined>
40
+
41
+ /**
42
+ * Creates a new session for a user.
43
+ *
44
+ * @param user - The user to create the session for.
45
+ * @param ip - The user's IP address.
46
+ * @param userAgent - Optional user agent string.
47
+ * @returns The created session.
48
+ */
49
+ createForUser: (user: UserModel, ip: string, userAgent?: string) => Promise<Session>
50
+
51
+ /**
52
+ * Updates the last activity timestamp of a session.
53
+ *
54
+ * @param session - The session to update.
55
+ */
56
+ updateLastActivity: (session: Session) => Promise<void>
57
+
58
+ /**
59
+ * Extends the expiration time of a session.
60
+ *
61
+ * @param session - The session to extend.
62
+ * @param additionalTime - The additional time in milliseconds.
63
+ * @returns The updated session.
64
+ */
65
+ extend: (session: Session, additionalTime: number) => Promise<Session>
66
+
67
+ /**
68
+ * Closes a session.
69
+ *
70
+ * @param session - The session to close.
71
+ */
72
+ close: (session: Session) => Promise<void>
73
+ }
@@ -0,0 +1,57 @@
1
+ import { UserModel } from '../../models/User'
2
+
3
+ /**
4
+ * User Service contract
5
+ */
6
+ export interface IUserService {
7
+ /**
8
+ * List users.
9
+ *
10
+ * @param limit - The limit of users to list.
11
+ * @returns A list of users.
12
+ */
13
+ list: (limit?: number) => Promise<UserModel[]>
14
+
15
+ /**
16
+ * Find a user by conditions.
17
+ *
18
+ * @param conditions - The conditions to find the user (e.g., by ID).
19
+ * @returns The found user.
20
+ * @throws NotFoundError if user is not found.
21
+ */
22
+ findBy: (conditions: Record<string, any>) => Promise<UserModel>
23
+
24
+ /**
25
+ * Find a user by email or other unique field.
26
+ *
27
+ * @param conditions - The conditions (typically email).
28
+ * @returns The user or `undefined` if not found.
29
+ */
30
+ findByEmail: (conditions: Record<string, any>) => Promise<UserModel | undefined>
31
+
32
+ /**
33
+ * Create a new user.
34
+ *
35
+ * @param payload - The user data to create.
36
+ * @returns The ID of the created user.
37
+ */
38
+ create: (payload: Omit<UserModel, 'id'>) => Promise<bigint | undefined>
39
+
40
+ /**
41
+ * Update a user.
42
+ *
43
+ * @param id - The user ID.
44
+ * @param payload - The updated user data.
45
+ * @returns The updated user.
46
+ * @throws NotFoundError if the user is not found.
47
+ */
48
+ update: (id: number, payload: UserModel) => Promise<UserModel>
49
+
50
+ /**
51
+ * Delete a user.
52
+ *
53
+ * @param id - The user ID.
54
+ * @returns `true` if the user was deleted, `false` otherwise.
55
+ */
56
+ delete: (id: number) => Promise<boolean>
57
+ }
@@ -0,0 +1,28 @@
1
+ import { UserEvent } from '../events/UserEvent'
2
+ import { defineEventSubscriber, EventEmitter, FunctionalEventSubscriber, ILogger } from '@stone-js/core'
3
+
4
+ /**
5
+ * User Event Subscriber Options
6
+ */
7
+ export interface UserEventSubscriberOptions {
8
+ logger: ILogger
9
+ }
10
+
11
+ /**
12
+ * Subscribe to user events
13
+ *
14
+ * @param eventEmitter - The event emitter
15
+ */
16
+ export function FactoryUserEventSubscriber ({ logger }: UserEventSubscriberOptions): FunctionalEventSubscriber {
17
+ return (eventEmitter: EventEmitter): void => {
18
+ eventEmitter
19
+ .on(UserEvent.USER_CREATED, (event: UserEvent) => {
20
+ logger.info('User event subscriber', event.user)
21
+ })
22
+ }
23
+ }
24
+
25
+ /**
26
+ * User event subscriber
27
+ */
28
+ export const UserEventSubscriber = defineEventSubscriber(FactoryUserEventSubscriber, { isFactory: true })
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from 'drizzle-kit';
2
+
3
+ /**
4
+ * Drizzle Configuration
5
+ */
6
+ export default defineConfig({
7
+ out: './drizzle',
8
+ dialect: 'sqlite',
9
+ schema: './app/database/schema.ts',
10
+ dbCredentials: {
11
+ url: process.env.DB_FILE_NAME ?? 'file:local.db'
12
+ },
13
+ })
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "full-service-imperative",
3
+ "private": true,
4
+ "version": "1.0.0",
5
+ "description": "Stone.js's full starter to create web app using imperative API.",
6
+ "author": "Mr. Stone <evensstone@gmail.com>",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "engines": {
10
+ "node": ">=20.0.0"
11
+ },
12
+ "scripts": {
13
+ "dev": "stone dev",
14
+ "build": "stone build",
15
+ "preview": "stone preview dist/server.mjs",
16
+ "typings": "stone typings",
17
+ "db:setup": "drizzle-kit push",
18
+ "db:generate": "drizzle-kit generate",
19
+ "db:migrate": "drizzle-kit migrate",
20
+ "test": "vitest run",
21
+ "test:cvg": "npm run test -- --coverage"
22
+ },
23
+ "dependencies": {
24
+ "@libsql/client": "^0.14.0",
25
+ "@stone-js/core": "^0.8.3",
26
+ "@stone-js/env": "^0.8.3",
27
+ "@stone-js/filesystem": "^0.8.3",
28
+ "@stone-js/http-core": "^0.8.3",
29
+ "@stone-js/node-cli-adapter": "^0.8.3",
30
+ "@stone-js/node-http-adapter": "^0.8.3",
31
+ "@stone-js/pipeline": "^0.8.3",
32
+ "@stone-js/router": "^0.8.3",
33
+ "bcryptjs": "^3.0.2",
34
+ "drizzle-orm": "^0.44.2",
35
+ "jsonwebtoken": "^9.0.2"
36
+ },
37
+ "devDependencies": {
38
+ "@babel/plugin-proposal-decorators": "^7.25.9",
39
+ "@babel/preset-env": "^7.26.9",
40
+ "@babel/preset-typescript": "^7.27.0",
41
+ "@stone-js/cli": "^0.8.3",
42
+ "@types/jsonwebtoken": "^9.0.8",
43
+ "@types/node": "^24.0.3",
44
+ "@vitest/coverage-v8": "^3.0.9",
45
+ "drizzle-kit": "^0.31.1",
46
+ "vitest": "^3.0.9"
47
+ }
48
+ }
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from '@stone-js/cli'
2
+
3
+ /**
4
+ * Stone build configuration.
5
+ */
6
+ export default defineConfig({
7
+ rollup: {
8
+ bundle: {
9
+ external: ['@libsql/client'],
10
+ }
11
+ }
12
+ })
@@ -0,0 +1,25 @@
1
+ {
2
+ "include": [
3
+ "app",
4
+ "tests",
5
+ ".stone",
6
+ "vitest.config.ts"
7
+ ],
8
+ "exclude": [
9
+ "node_modules"
10
+ ],
11
+ "compilerOptions": {
12
+ "strict": true,
13
+ "allowJs": false,
14
+ "target": "esnext",
15
+ "module": "ESNext",
16
+ "sourceMap": true,
17
+ "skipLibCheck": true,
18
+ "esModuleInterop": true,
19
+ "isolatedModules": true,
20
+ "resolveJsonModule": true,
21
+ "moduleResolution": "bundler",
22
+ "experimentalDecorators": true,
23
+ "types": ["node", "vitest/globals"],
24
+ }
25
+ }
@@ -0,0 +1,24 @@
1
+ import { defineConfig } from 'vitest/config.js'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'node',
7
+ include: ['./tests/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
8
+ coverage: {
9
+ provider: 'v8',
10
+ include: ['app/**/*.ts'],
11
+ reporter: ['text', 'html'],
12
+ reportsDirectory: './coverage',
13
+ thresholds: {
14
+ 100: true
15
+ },
16
+ watermarks: {
17
+ statements: [60, 80],
18
+ functions: [60, 80],
19
+ branches: [60, 80],
20
+ lines: [60, 80]
21
+ }
22
+ },
23
+ }
24
+ });
package/package.json ADDED
@@ -0,0 +1,225 @@
1
+ {
2
+ "name": "@stone-js/starters",
3
+ "version": "0.8.3",
4
+ "description": "This repository contains official **starter templates** for Stone.js applications.",
5
+ "author": "Mr. Stone <evensstone@gmail.com>",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/stone-foundation/stone-js-framework.git",
10
+ "directory": "stone-js-starters"
11
+ },
12
+ "homepage": "https://stonejs.dev",
13
+ "bugs": {
14
+ "url": "https://github.com/stone-foundation/stone-js-framework/issues"
15
+ },
16
+ "keywords": [
17
+ "Starters",
18
+ "Scaffolding",
19
+ "Stone.js"
20
+ ],
21
+ "type": "module",
22
+ "engines": {
23
+ "node": ">=18.17.0"
24
+ },
25
+ "stone": {
26
+ "starters": [
27
+ {
28
+ "value": "basic-service-declarative",
29
+ "title": "Basic · service · declarative",
30
+ "description": "Minimal HTTP/service API, decorator API.",
31
+ "tags": [
32
+ "api",
33
+ "service",
34
+ "basic",
35
+ "declarative"
36
+ ],
37
+ "path": "basic-service-declarative"
38
+ },
39
+ {
40
+ "value": "basic-service-imperative",
41
+ "title": "Basic · service · imperative",
42
+ "description": "Minimal HTTP/service API, imperative API.",
43
+ "tags": [
44
+ "api",
45
+ "service",
46
+ "basic",
47
+ "imperative"
48
+ ],
49
+ "path": "basic-service-imperative"
50
+ },
51
+ {
52
+ "value": "basic-react-declarative",
53
+ "title": "Basic · React · declarative",
54
+ "description": "Minimal React SPA, decorator API.",
55
+ "tags": [
56
+ "react",
57
+ "spa",
58
+ "basic",
59
+ "declarative"
60
+ ],
61
+ "path": "basic-react-declarative"
62
+ },
63
+ {
64
+ "value": "basic-react-imperative",
65
+ "title": "Basic · React · imperative",
66
+ "description": "Minimal React SPA, imperative API.",
67
+ "tags": [
68
+ "react",
69
+ "spa",
70
+ "basic",
71
+ "imperative"
72
+ ],
73
+ "path": "basic-react-imperative"
74
+ },
75
+ {
76
+ "value": "standard-service-declarative",
77
+ "title": "Standard · service · declarative",
78
+ "description": "Common service setup, decorator API.",
79
+ "tags": [
80
+ "api",
81
+ "service",
82
+ "standard",
83
+ "declarative"
84
+ ],
85
+ "path": "standard-service-declarative"
86
+ },
87
+ {
88
+ "value": "standard-service-imperative",
89
+ "title": "Standard · service · imperative",
90
+ "description": "Common service setup, imperative API.",
91
+ "tags": [
92
+ "api",
93
+ "service",
94
+ "standard",
95
+ "imperative"
96
+ ],
97
+ "path": "standard-service-imperative"
98
+ },
99
+ {
100
+ "value": "standard-react-declarative",
101
+ "title": "Standard · React · declarative (SSR)",
102
+ "description": "React with SSR, decorator API.",
103
+ "tags": [
104
+ "react",
105
+ "ssr",
106
+ "standard",
107
+ "declarative"
108
+ ],
109
+ "path": "standard-react-declarative"
110
+ },
111
+ {
112
+ "value": "standard-react-imperative",
113
+ "title": "Standard · React · imperative (SSR)",
114
+ "description": "React with SSR, imperative API.",
115
+ "tags": [
116
+ "react",
117
+ "ssr",
118
+ "standard",
119
+ "imperative"
120
+ ],
121
+ "path": "standard-react-imperative"
122
+ },
123
+ {
124
+ "value": "full-service-declarative",
125
+ "title": "Full · service · declarative",
126
+ "description": "Full-featured service, decorator API.",
127
+ "tags": [
128
+ "api",
129
+ "service",
130
+ "full",
131
+ "declarative"
132
+ ],
133
+ "path": "full-service-declarative"
134
+ },
135
+ {
136
+ "value": "full-service-imperative",
137
+ "title": "Full · service · imperative",
138
+ "description": "Full-featured service, imperative API.",
139
+ "tags": [
140
+ "api",
141
+ "service",
142
+ "full",
143
+ "imperative"
144
+ ],
145
+ "path": "full-service-imperative"
146
+ },
147
+ {
148
+ "value": "full-react-declarative",
149
+ "title": "Full · React · declarative (SSR/SSG)",
150
+ "description": "Full React with SSR & SSG, decorator API.",
151
+ "tags": [
152
+ "react",
153
+ "ssr",
154
+ "ssg",
155
+ "full",
156
+ "declarative"
157
+ ],
158
+ "path": "full-react-declarative"
159
+ },
160
+ {
161
+ "value": "full-react-imperative",
162
+ "title": "Full · React · imperative (SSR/SSG)",
163
+ "description": "Full React with SSR & SSG, imperative API.",
164
+ "tags": [
165
+ "react",
166
+ "ssr",
167
+ "ssg",
168
+ "full",
169
+ "imperative"
170
+ ],
171
+ "path": "full-react-imperative"
172
+ },
173
+ {
174
+ "value": "continuum-showcase",
175
+ "title": "Continuum showcase",
176
+ "description": "One domain served over HTTP, edge, CLI and agent tools, both paradigms side by side.",
177
+ "tags": [
178
+ "showcase",
179
+ "continuum",
180
+ "full"
181
+ ],
182
+ "path": "continuum-showcase"
183
+ }
184
+ ]
185
+ },
186
+ "scripts": {
187
+ "lint": "ts-standard **/app",
188
+ "lint:fix": "ts-standard --fix **/app",
189
+ "prepare": "husky"
190
+ },
191
+ "devDependencies": {
192
+ "@commitlint/cli": "^19.8.1",
193
+ "@commitlint/config-conventional": "^19.8.1",
194
+ "husky": "^9.1.7",
195
+ "ts-standard": "^12.0.2",
196
+ "tslib": "^2.8.1",
197
+ "typescript": "^5.6.3"
198
+ },
199
+ "ts-standard": {
200
+ "globals": [
201
+ "it",
202
+ "expect",
203
+ "describe",
204
+ "beforeEach"
205
+ ]
206
+ },
207
+ "files": [
208
+ "basic-service-declarative",
209
+ "basic-service-imperative",
210
+ "basic-react-declarative",
211
+ "basic-react-imperative",
212
+ "standard-service-declarative",
213
+ "standard-service-imperative",
214
+ "standard-react-declarative",
215
+ "standard-react-imperative",
216
+ "full-service-declarative",
217
+ "full-service-imperative",
218
+ "full-react-declarative",
219
+ "full-react-imperative",
220
+ "continuum-showcase"
221
+ ],
222
+ "publishConfig": {
223
+ "access": "public"
224
+ }
225
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright © 2026 Stone Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # Stone.js - Standard starter
2
+
3
+ Stone.js's standard starter to create react app using declarative API.
4
+
5
+ ## Project Setup
6
+
7
+ ```sh
8
+ npm install
9
+ ```
10
+
11
+ ### Compile and Hot-Reload for Development
12
+
13
+ ```sh
14
+ npm run dev
15
+ ```
16
+
17
+ ### Compile and Bundle for Production
18
+
19
+ ```sh
20
+ npm run build
21
+ ```
22
+
23
+ ### Run the Production build
24
+
25
+ ```sh
26
+ npm run preview
27
+ ```
28
+
29
+ ### Run tests
30
+
31
+ ```sh
32
+ npm run test
33
+ ```
34
+
35
+ ### Run tests with coverage
36
+
37
+ ```sh
38
+ npm run test:cvg
39
+ ```
@@ -0,0 +1,45 @@
1
+ import { Routing } from '@stone-js/router'
2
+ import { UseReact } from '@stone-js/use-react'
3
+ import { Browser } from '@stone-js/browser-adapter'
4
+ import { NodeHttp } from '@stone-js/node-http-adapter'
5
+ import { StoneApp, AdapterHookListenerContext, Hook, LogLevel, Logger } from '@stone-js/core'
6
+
7
+ /**
8
+ * Application
9
+ *
10
+ * This is the main application entry point.
11
+ *
12
+ * @UseReact() is used to enable the React.
13
+ * @Browser() is used to enable the Browser adapter.
14
+ * @Routing() is used to enable the routing feature.
15
+ * @NodeHttp() is used to enable the Node HTTP adapter.
16
+ * @StoneApp() is used to enable the Stone application, it is required.
17
+ *
18
+ * Lifecycle hooks are used here just for demonstration purposes.
19
+ */
20
+ @Routing()
21
+ @Browser()
22
+ @UseReact()
23
+ @NodeHttp({ default: true })
24
+ @StoneApp({ name: 'MyApp', logger: { level: LogLevel.INFO } })
25
+ export class Application {
26
+ /**
27
+ * Run before the application starts
28
+ *
29
+ * @param blueprint - The blueprint
30
+ */
31
+ @Hook('onStart')
32
+ onStart ({ blueprint }: AdapterHookListenerContext): void {
33
+ Logger.log(`${String(blueprint.get('stone.name', 'Stone App'))} is starting...`)
34
+ }
35
+
36
+ /**
37
+ * Run just before the application stops
38
+ *
39
+ * @param blueprint - The blueprint
40
+ */
41
+ @Hook('onStop')
42
+ onStop ({ blueprint }: AdapterHookListenerContext): void {
43
+ Logger.log(`${String(blueprint.get('stone.name', 'Stone App'))} is stopping...`)
44
+ }
45
+ }
@@ -0,0 +1,57 @@
1
+ import { JSX } from 'react'
2
+ import { WelcomeService } from '../../services/WelcomeService'
3
+ import { Page, ReactIncomingEvent, PageRenderContext, IPage } from '@stone-js/use-react'
4
+
5
+ /**
6
+ * WelcomePage Options
7
+ */
8
+ export interface WelcomePageOptions {
9
+ welcomeService: WelcomeService
10
+ }
11
+
12
+ /**
13
+ * Response data
14
+ */
15
+ export interface ResponseData {
16
+ message: string
17
+ }
18
+
19
+ /**
20
+ * Welcome Page component.
21
+ */
22
+ @Page('/:name?')
23
+ export class WelcomePage implements IPage<ReactIncomingEvent> {
24
+ private readonly welcomeService: WelcomeService
25
+
26
+ /**
27
+ * Create a new instance of WelcomePage
28
+ *
29
+ * @param welcomeService
30
+ */
31
+ constructor ({ welcomeService }: WelcomePageOptions) {
32
+ this.welcomeService = welcomeService
33
+ }
34
+
35
+ /**
36
+ * Handle the incoming event.
37
+ *
38
+ * @param event - The incoming event.
39
+ * @returns A welcome message
40
+ */
41
+ handle (event: ReactIncomingEvent): ResponseData {
42
+ return this.welcomeService.welcome(event.get<string>('name', 'World'))
43
+ }
44
+
45
+ /**
46
+ * Render the component.
47
+ *
48
+ * @returns The rendered component.
49
+ */
50
+ render ({ data }: PageRenderContext<ResponseData>): JSX.Element {
51
+ return (
52
+ <section className='container'>
53
+ <h1 className='h1 text-center mt-64'>{data?.message}</h1>
54
+ </section>
55
+ )
56
+ }
57
+ }