@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.
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/basic-react-declarative/LICENSE +21 -0
- package/basic-react-declarative/README.md +39 -0
- package/basic-react-declarative/app/Application.tsx +89 -0
- package/basic-react-declarative/assets/css/index.css +26 -0
- package/basic-react-declarative/package.json +39 -0
- package/basic-react-declarative/public/logo.png +0 -0
- package/basic-react-declarative/tests/Application.spec.ts +96 -0
- package/basic-react-declarative/tests/__snapshots__/Application.spec.ts.snap +3 -0
- package/basic-react-declarative/tsconfig.json +33 -0
- package/basic-react-declarative/vitest.config.ts +24 -0
- package/basic-react-imperative/LICENSE +21 -0
- package/basic-react-imperative/README.md +39 -0
- package/basic-react-imperative/app/Application.tsx +89 -0
- package/basic-react-imperative/assets/css/index.css +26 -0
- package/basic-react-imperative/package.json +39 -0
- package/basic-react-imperative/public/logo.png +0 -0
- package/basic-react-imperative/tests/Application.spec.ts +80 -0
- package/basic-react-imperative/tests/__snapshots__/Application.spec.ts.snap +3 -0
- package/basic-react-imperative/tsconfig.json +33 -0
- package/basic-react-imperative/vitest.config.ts +24 -0
- package/basic-service-declarative/LICENSE +21 -0
- package/basic-service-declarative/README.md +39 -0
- package/basic-service-declarative/app/Application.ts +56 -0
- package/basic-service-declarative/package.json +34 -0
- package/basic-service-declarative/tests/Application.spec.ts +60 -0
- package/basic-service-declarative/tsconfig.json +25 -0
- package/basic-service-declarative/vitest.config.ts +24 -0
- package/basic-service-imperative/LICENSE +21 -0
- package/basic-service-imperative/README.md +39 -0
- package/basic-service-imperative/app/Application.ts +60 -0
- package/basic-service-imperative/package.json +34 -0
- package/basic-service-imperative/tests/Application.spec.ts +52 -0
- package/basic-service-imperative/tsconfig.json +25 -0
- package/basic-service-imperative/vitest.config.ts +24 -0
- package/continuum-showcase/README.md +44 -0
- package/continuum-showcase/app/env.d.ts +34 -0
- package/continuum-showcase/app/layouts/MainLayout.tsx +20 -0
- package/continuum-showcase/app/pages/BlogPostPage.tsx +62 -0
- package/continuum-showcase/app/pages/HomePage.tsx +58 -0
- package/continuum-showcase/package.json +25 -0
- package/continuum-showcase/stone.config.mjs +20 -0
- package/full-react-declarative/.env.example +1 -0
- package/full-react-declarative/.env.public.example +1 -0
- package/full-react-declarative/LICENSE +21 -0
- package/full-react-declarative/README.md +39 -0
- package/full-react-declarative/app/Application.ts +85 -0
- package/full-react-declarative/app/clients/AxiosClient.ts +136 -0
- package/full-react-declarative/app/clients/CommentClient.ts +61 -0
- package/full-react-declarative/app/clients/PostClient.ts +90 -0
- package/full-react-declarative/app/clients/SecurityClient.ts +66 -0
- package/full-react-declarative/app/clients/UserClient.ts +97 -0
- package/full-react-declarative/app/components/ChangePasswordForm/ChangePasswordForm.tsx +50 -0
- package/full-react-declarative/app/components/CommentForm/CommentForm.tsx +37 -0
- package/full-react-declarative/app/components/CommentItem/CommentItem.tsx +42 -0
- package/full-react-declarative/app/components/CommentWidget/CommentWidget.tsx +95 -0
- package/full-react-declarative/app/components/LoginForm/LoginForm.css +0 -0
- package/full-react-declarative/app/components/LoginForm/LoginForm.tsx +71 -0
- package/full-react-declarative/app/components/PostDetails/PostDetails.tsx +44 -0
- package/full-react-declarative/app/components/PostForm/PostForm.css +0 -0
- package/full-react-declarative/app/components/PostForm/PostForm.tsx +47 -0
- package/full-react-declarative/app/components/PostItem/PostItem.css +0 -0
- package/full-react-declarative/app/components/PostItem/PostItem.tsx +34 -0
- package/full-react-declarative/app/components/RegisterForm/RegisterForm.tsx +110 -0
- package/full-react-declarative/app/components/UserForm/UserForm.tsx +47 -0
- package/full-react-declarative/app/configurations/AppConfiguration.ts +17 -0
- package/full-react-declarative/app/error-pages/DefaultErrorPage/DefaultErrorPage.css +0 -0
- package/full-react-declarative/app/error-pages/DefaultErrorPage/DefaultErrorPage.tsx +52 -0
- package/full-react-declarative/app/error-pages/ForbiddenErrorPage/ForbiddenErrorPage.css +0 -0
- package/full-react-declarative/app/error-pages/ForbiddenErrorPage/ForbiddenErrorPage.tsx +53 -0
- package/full-react-declarative/app/error-pages/NotFoundErrorPage/NotFoundErrorPage.css +0 -0
- package/full-react-declarative/app/error-pages/NotFoundErrorPage/NotFoundErrorPage.tsx +54 -0
- package/full-react-declarative/app/error-pages/UnauthorizedErrorPage/UnauthorizedErrorPage.css +0 -0
- package/full-react-declarative/app/error-pages/UnauthorizedErrorPage/UnauthorizedErrorPage.tsx +53 -0
- package/full-react-declarative/app/errors/ForbiddenError.ts +11 -0
- package/full-react-declarative/app/errors/PostNotFoundError.ts +11 -0
- package/full-react-declarative/app/errors/UnauthorizedError.ts +11 -0
- package/full-react-declarative/app/errors/UserNotFoundError.ts +11 -0
- package/full-react-declarative/app/events/UserEvent.ts +18 -0
- package/full-react-declarative/app/layout/AppLayout/AppLayout.css +20 -0
- package/full-react-declarative/app/layout/AppLayout/AppLayout.tsx +101 -0
- package/full-react-declarative/app/layout/ErrorLayout/ErrorLayout.css +0 -0
- package/full-react-declarative/app/layout/ErrorLayout/ErrorLayout.tsx +41 -0
- package/full-react-declarative/app/layout/SecurityLayout/SecurityLayout.css +0 -0
- package/full-react-declarative/app/layout/SecurityLayout/SecurityLayout.tsx +39 -0
- package/full-react-declarative/app/middleware/AuthMiddleware.ts +85 -0
- package/full-react-declarative/app/models/Comment.ts +31 -0
- package/full-react-declarative/app/models/Post.ts +22 -0
- package/full-react-declarative/app/models/User.ts +62 -0
- package/full-react-declarative/app/pages/home/HomePage.tsx +44 -0
- package/full-react-declarative/app/pages/login/LoginPage.css +0 -0
- package/full-react-declarative/app/pages/login/LoginPage.tsx +73 -0
- package/full-react-declarative/app/pages/posts/CreatePostPage/CreatePostPage.css +0 -0
- package/full-react-declarative/app/pages/posts/CreatePostPage/CreatePostPage.tsx +67 -0
- package/full-react-declarative/app/pages/posts/PostPage/PostPage.tsx +60 -0
- package/full-react-declarative/app/pages/posts/ShowPostPage/ShowPostPage.tsx +83 -0
- package/full-react-declarative/app/pages/posts/UpdatePostPage/UpdatePostPage.tsx +77 -0
- package/full-react-declarative/app/pages/register/RegisterPage.tsx +68 -0
- package/full-react-declarative/app/pages/users/CreateUserPage.tsx +48 -0
- package/full-react-declarative/app/pages/users/ShowUserPage.tsx +62 -0
- package/full-react-declarative/app/pages/users/UpdateUserPage.tsx +57 -0
- package/full-react-declarative/app/pages/users/UserPage.tsx +57 -0
- package/full-react-declarative/app/providers/AppServiceProvider.ts +43 -0
- package/full-react-declarative/app/services/CommentService.ts +59 -0
- package/full-react-declarative/app/services/PostService.ts +108 -0
- package/full-react-declarative/app/services/SecurityService.ts +80 -0
- package/full-react-declarative/app/services/TokenService.ts +116 -0
- package/full-react-declarative/app/services/UserService.ts +126 -0
- package/full-react-declarative/app/utils.ts +17 -0
- package/full-react-declarative/assets/css/index.css +301 -0
- package/full-react-declarative/assets/img/logo.png +0 -0
- package/full-react-declarative/package.json +46 -0
- package/full-react-declarative/public/logo.png +0 -0
- package/full-react-declarative/public/vite.svg +1 -0
- package/full-react-declarative/stone.config.mjs +12 -0
- package/full-react-declarative/tsconfig.json +29 -0
- package/full-react-declarative/vitest.config.ts +24 -0
- package/full-react-imperative/.env.example +1 -0
- package/full-react-imperative/.env.public.example +1 -0
- package/full-react-imperative/LICENSE +21 -0
- package/full-react-imperative/README.md +39 -0
- package/full-react-imperative/app/Application.ts +79 -0
- package/full-react-imperative/app/clients/AxiosClient.ts +124 -0
- package/full-react-imperative/app/clients/CommentClient.ts +57 -0
- package/full-react-imperative/app/clients/PostClient.ts +86 -0
- package/full-react-imperative/app/clients/SecurityClient.ts +60 -0
- package/full-react-imperative/app/clients/UserClient.ts +93 -0
- package/full-react-imperative/app/clients/contracts/IAxiosClient.ts +97 -0
- package/full-react-imperative/app/clients/contracts/ICommentClient.ts +31 -0
- package/full-react-imperative/app/clients/contracts/IPostClient.ts +55 -0
- package/full-react-imperative/app/clients/contracts/ISecurityClient.ts +33 -0
- package/full-react-imperative/app/clients/contracts/IUserClient.ts +61 -0
- package/full-react-imperative/app/components/ChangePasswordForm/ChangePasswordForm.tsx +50 -0
- package/full-react-imperative/app/components/CommentForm/CommentForm.css +35 -0
- package/full-react-imperative/app/components/CommentForm/CommentForm.tsx +45 -0
- package/full-react-imperative/app/components/CommentItem/CommentItem.css +74 -0
- package/full-react-imperative/app/components/CommentItem/CommentItem.tsx +62 -0
- package/full-react-imperative/app/components/CommentWidget/CommentWidget.css +25 -0
- package/full-react-imperative/app/components/CommentWidget/CommentWidget.tsx +119 -0
- package/full-react-imperative/app/components/Dropdown/Dropdown.css +52 -0
- package/full-react-imperative/app/components/Dropdown/Dropdown.tsx +40 -0
- package/full-react-imperative/app/components/LayoutHeader/LayoutHeader.css +62 -0
- package/full-react-imperative/app/components/LayoutHeader/LayoutHeader.tsx +61 -0
- package/full-react-imperative/app/components/LayoutLeftMenu/LayoutLeftMenu.css +25 -0
- package/full-react-imperative/app/components/LayoutLeftMenu/LayoutLeftMenu.tsx +32 -0
- package/full-react-imperative/app/components/LoginForm/LoginForm.css +0 -0
- package/full-react-imperative/app/components/LoginForm/LoginForm.tsx +71 -0
- package/full-react-imperative/app/components/NotificationBadge/NotificationBadge.css +41 -0
- package/full-react-imperative/app/components/NotificationBadge/NotificationBadge.tsx +63 -0
- package/full-react-imperative/app/components/PostCard/PostCard.css +129 -0
- package/full-react-imperative/app/components/PostCard/PostCard.tsx +65 -0
- package/full-react-imperative/app/components/PostForm/PostForm.css +92 -0
- package/full-react-imperative/app/components/PostForm/PostForm.tsx +76 -0
- package/full-react-imperative/app/components/PostSkeleton/PostSkeleton.css +65 -0
- package/full-react-imperative/app/components/PostSkeleton/PostSkeleton.tsx +25 -0
- package/full-react-imperative/app/components/PostWidget/PostWidget.tsx +95 -0
- package/full-react-imperative/app/components/ProfileForm/ProfileForm.css +84 -0
- package/full-react-imperative/app/components/ProfileForm/ProfileForm.tsx +79 -0
- package/full-react-imperative/app/components/RegisterForm/RegisterForm.tsx +110 -0
- package/full-react-imperative/app/components/RightAsidePanel/RightAsidePanel.css +32 -0
- package/full-react-imperative/app/components/RightAsidePanel/RightAsidePanel.tsx +62 -0
- package/full-react-imperative/app/components/SettingsForm/SettingsForm.css +126 -0
- package/full-react-imperative/app/components/SettingsForm/SettingsForm.tsx +86 -0
- package/full-react-imperative/app/components/UserAvatar/UserAvatar.css +18 -0
- package/full-react-imperative/app/components/UserAvatar/UserAvatar.tsx +60 -0
- package/full-react-imperative/app/components/UserBadge/UserBadge.css +33 -0
- package/full-react-imperative/app/components/UserBadge/UserBadge.tsx +49 -0
- package/full-react-imperative/app/components/UserCard/UserCard.css +70 -0
- package/full-react-imperative/app/components/UserCard/UserCard.tsx +43 -0
- package/full-react-imperative/app/configurations/AppConfiguration.ts +19 -0
- package/full-react-imperative/app/error-pages/DefaultErrorPage/DefaultErrorPage.css +0 -0
- package/full-react-imperative/app/error-pages/DefaultErrorPage/DefaultErrorPage.tsx +41 -0
- package/full-react-imperative/app/error-pages/ForbiddenErrorPage/ForbiddenErrorPage.css +0 -0
- package/full-react-imperative/app/error-pages/ForbiddenErrorPage/ForbiddenErrorPage.tsx +42 -0
- package/full-react-imperative/app/error-pages/NotFoundErrorPage/NotFoundErrorPage.css +0 -0
- package/full-react-imperative/app/error-pages/NotFoundErrorPage/NotFoundErrorPage.tsx +49 -0
- package/full-react-imperative/app/error-pages/UnauthorizedErrorPage/UnauthorizedErrorPage.css +0 -0
- package/full-react-imperative/app/error-pages/UnauthorizedErrorPage/UnauthorizedErrorPage.tsx +42 -0
- package/full-react-imperative/app/errors/ForbiddenError.ts +11 -0
- package/full-react-imperative/app/errors/PostNotFoundError.ts +11 -0
- package/full-react-imperative/app/errors/UnauthorizedError.ts +11 -0
- package/full-react-imperative/app/errors/UserNotFoundError.ts +11 -0
- package/full-react-imperative/app/events/UserEvent.ts +18 -0
- package/full-react-imperative/app/layout/AppLayout/AppLayout.css +106 -0
- package/full-react-imperative/app/layout/AppLayout/AppLayout.tsx +48 -0
- package/full-react-imperative/app/layout/ErrorLayout/ErrorLayout.css +0 -0
- package/full-react-imperative/app/layout/ErrorLayout/ErrorLayout.tsx +45 -0
- package/full-react-imperative/app/layout/SecurityLayout/SecurityLayout.css +0 -0
- package/full-react-imperative/app/layout/SecurityLayout/SecurityLayout.tsx +43 -0
- package/full-react-imperative/app/layout/SettingsLayout/SettingsLayout.css +99 -0
- package/full-react-imperative/app/layout/SettingsLayout/SettingsLayout.tsx +44 -0
- package/full-react-imperative/app/middleware/AuthMiddleware.ts +56 -0
- package/full-react-imperative/app/models/Comment.ts +35 -0
- package/full-react-imperative/app/models/Post.ts +27 -0
- package/full-react-imperative/app/models/User.ts +68 -0
- package/full-react-imperative/app/pages/Settings/SettingsPage.tsx +23 -0
- package/full-react-imperative/app/pages/home/HomePage.tsx +58 -0
- package/full-react-imperative/app/pages/login/LoginPage.css +0 -0
- package/full-react-imperative/app/pages/login/LoginPage.tsx +65 -0
- package/full-react-imperative/app/pages/posts/ShowPostPage/ShowPostPage.tsx +64 -0
- package/full-react-imperative/app/pages/posts/UpdatePostPage/UpdatePostPage.tsx +56 -0
- package/full-react-imperative/app/pages/register/RegisterPage.tsx +71 -0
- package/full-react-imperative/app/pages/users/ShowUserPage/ShowUserPage.css +64 -0
- package/full-react-imperative/app/pages/users/ShowUserPage/ShowUserPage.tsx +104 -0
- package/full-react-imperative/app/pages/users/UpdateUserPage/UpdateUserPage.css +0 -0
- package/full-react-imperative/app/pages/users/UpdateUserPage/UpdateUserPage.tsx +43 -0
- package/full-react-imperative/app/pages/users/UserPage/UserPage.css +31 -0
- package/full-react-imperative/app/pages/users/UserPage/UserPage.tsx +59 -0
- package/full-react-imperative/app/pages/utils.ts +67 -0
- package/full-react-imperative/app/providers/AppServiceProvider.ts +40 -0
- package/full-react-imperative/app/services/CommentService.ts +53 -0
- package/full-react-imperative/app/services/PostService.ts +102 -0
- package/full-react-imperative/app/services/SecurityService.ts +72 -0
- package/full-react-imperative/app/services/TokenService.ts +108 -0
- package/full-react-imperative/app/services/UserService.ts +115 -0
- package/full-react-imperative/app/services/contracts/ICommentService.ts +30 -0
- package/full-react-imperative/app/services/contracts/IPostService.ts +65 -0
- package/full-react-imperative/app/services/contracts/ISecurityService.ts +39 -0
- package/full-react-imperative/app/services/contracts/ITokenService.ts +44 -0
- package/full-react-imperative/app/services/contracts/IUserService.ts +70 -0
- package/full-react-imperative/app/utils.ts +31 -0
- package/full-react-imperative/assets/css/index.css +301 -0
- package/full-react-imperative/assets/img/logo.png +0 -0
- package/full-react-imperative/package.json +48 -0
- package/full-react-imperative/public/logo.png +0 -0
- package/full-react-imperative/public/vite.svg +1 -0
- package/full-react-imperative/stone.config.mjs +12 -0
- package/full-react-imperative/tsconfig.json +29 -0
- package/full-react-imperative/vitest.config.ts +24 -0
- package/full-service-declarative/.env.example +2 -0
- package/full-service-declarative/LICENSE +21 -0
- package/full-service-declarative/README.md +65 -0
- package/full-service-declarative/app/Application.ts +327 -0
- package/full-service-declarative/app/commands/ListSessionsCommand.ts +70 -0
- package/full-service-declarative/app/commands/ListUsersCommand.ts +56 -0
- package/full-service-declarative/app/configurations/AppConfiguration.ts +52 -0
- package/full-service-declarative/app/configurations/UserLiveConfiguration.ts +28 -0
- package/full-service-declarative/app/database/DatabaseClient.ts +43 -0
- package/full-service-declarative/app/database/schema.ts +43 -0
- package/full-service-declarative/app/error-handlers/SecurityErrorHandler.ts +61 -0
- package/full-service-declarative/app/errors/CredentialsError.ts +12 -0
- package/full-service-declarative/app/events/UserEvent.ts +17 -0
- package/full-service-declarative/app/handlers/CommentEventHandler.ts +103 -0
- package/full-service-declarative/app/handlers/PostEventHandler.ts +104 -0
- package/full-service-declarative/app/handlers/SecurityEventHandler.ts +108 -0
- package/full-service-declarative/app/handlers/UserEventHandler.ts +159 -0
- package/full-service-declarative/app/listeners/UserEventListener.ts +35 -0
- package/full-service-declarative/app/middleware/AuthMiddleware.ts +54 -0
- package/full-service-declarative/app/models/Comment.ts +38 -0
- package/full-service-declarative/app/models/Post.ts +50 -0
- package/full-service-declarative/app/models/Session.ts +14 -0
- package/full-service-declarative/app/models/User.ts +77 -0
- package/full-service-declarative/app/providers/DrizzleServiceProvider.ts +59 -0
- package/full-service-declarative/app/repositories/CommentRepository.ts +155 -0
- package/full-service-declarative/app/repositories/PostRepository.ts +138 -0
- package/full-service-declarative/app/repositories/SessionRepository.ts +123 -0
- package/full-service-declarative/app/repositories/UserRepository.ts +99 -0
- package/full-service-declarative/app/services/CommentService.ts +112 -0
- package/full-service-declarative/app/services/PostService.ts +100 -0
- package/full-service-declarative/app/services/SecurityService.ts +232 -0
- package/full-service-declarative/app/services/SessionService.ts +130 -0
- package/full-service-declarative/app/services/UserService.ts +110 -0
- package/full-service-declarative/app/subscribers/UserEventSubscriber.ts +38 -0
- package/full-service-declarative/drizzle.config.ts +13 -0
- package/full-service-declarative/package.json +48 -0
- package/full-service-declarative/stone.config.mjs +12 -0
- package/full-service-declarative/tsconfig.json +25 -0
- package/full-service-declarative/vitest.config.ts +24 -0
- package/full-service-imperative/.env.example +2 -0
- package/full-service-imperative/LICENSE +21 -0
- package/full-service-imperative/README.md +65 -0
- package/full-service-imperative/app/Application.ts +317 -0
- package/full-service-imperative/app/commands/ListSessionsCommand.ts +54 -0
- package/full-service-imperative/app/commands/ListUsersCommand.ts +42 -0
- package/full-service-imperative/app/configurations/AppConfiguration.ts +44 -0
- package/full-service-imperative/app/configurations/UserLiveConfiguration.ts +26 -0
- package/full-service-imperative/app/database/DatabaseClient.ts +39 -0
- package/full-service-imperative/app/database/schema.ts +43 -0
- package/full-service-imperative/app/error-handlers/SecurityErrorHandler.ts +58 -0
- package/full-service-imperative/app/errors/CredentialsError.ts +12 -0
- package/full-service-imperative/app/events/UserEvent.ts +17 -0
- package/full-service-imperative/app/handlers/CommentEventHandler.ts +99 -0
- package/full-service-imperative/app/handlers/PostEventHandler.ts +99 -0
- package/full-service-imperative/app/handlers/SecurityEventHandler.ts +83 -0
- package/full-service-imperative/app/handlers/UserEventHandler.ts +132 -0
- package/full-service-imperative/app/listeners/UserEventListener.ts +23 -0
- package/full-service-imperative/app/middleware/AuthMiddleware.ts +44 -0
- package/full-service-imperative/app/models/Comment.ts +38 -0
- package/full-service-imperative/app/models/Post.ts +50 -0
- package/full-service-imperative/app/models/Session.ts +14 -0
- package/full-service-imperative/app/models/User.ts +77 -0
- package/full-service-imperative/app/providers/DrizzleServiceProvider.ts +56 -0
- package/full-service-imperative/app/repositories/CommentRepository.ts +148 -0
- package/full-service-imperative/app/repositories/PostRepository.ts +130 -0
- package/full-service-imperative/app/repositories/SessionRepository.ts +115 -0
- package/full-service-imperative/app/repositories/UserRepository.ts +91 -0
- package/full-service-imperative/app/repositories/contracts/ICommentRepository.ts +72 -0
- package/full-service-imperative/app/repositories/contracts/IPostRepository.ts +63 -0
- package/full-service-imperative/app/repositories/contracts/ISessionRepository.ts +65 -0
- package/full-service-imperative/app/repositories/contracts/IUserRepository.ts +55 -0
- package/full-service-imperative/app/services/CommentService.ts +109 -0
- package/full-service-imperative/app/services/PostService.ts +97 -0
- package/full-service-imperative/app/services/SecurityService.ts +224 -0
- package/full-service-imperative/app/services/SessionService.ts +124 -0
- package/full-service-imperative/app/services/UserService.ts +105 -0
- package/full-service-imperative/app/services/contracts/ICommentService.ts +62 -0
- package/full-service-imperative/app/services/contracts/IPostService.ts +53 -0
- package/full-service-imperative/app/services/contracts/ISecurityService.ts +97 -0
- package/full-service-imperative/app/services/contracts/ISessionService.ts +73 -0
- package/full-service-imperative/app/services/contracts/IUserService.ts +57 -0
- package/full-service-imperative/app/subscribers/UserEventSubscriber.ts +28 -0
- package/full-service-imperative/drizzle.config.ts +13 -0
- package/full-service-imperative/package.json +48 -0
- package/full-service-imperative/stone.config.mjs +12 -0
- package/full-service-imperative/tsconfig.json +25 -0
- package/full-service-imperative/vitest.config.ts +24 -0
- package/package.json +225 -0
- package/standard-react-declarative/LICENSE +21 -0
- package/standard-react-declarative/README.md +39 -0
- package/standard-react-declarative/app/Application.ts +45 -0
- package/standard-react-declarative/app/pages/welcome/WelcomePage.tsx +57 -0
- package/standard-react-declarative/app/services/WelcomeService.ts +38 -0
- package/standard-react-declarative/assets/css/index.css +26 -0
- package/standard-react-declarative/package.json +42 -0
- package/standard-react-declarative/tsconfig.json +33 -0
- package/standard-react-declarative/vitest.config.ts +24 -0
- package/standard-react-imperative/LICENSE +21 -0
- package/standard-react-imperative/README.md +39 -0
- package/standard-react-imperative/app/Application.ts +41 -0
- package/standard-react-imperative/app/pages/welcome/WelcomePage.tsx +50 -0
- package/standard-react-imperative/app/services/WelcomeService.ts +38 -0
- package/standard-react-imperative/assets/css/index.css +26 -0
- package/standard-react-imperative/package.json +42 -0
- package/standard-react-imperative/tsconfig.json +33 -0
- package/standard-react-imperative/vitest.config.ts +24 -0
- package/standard-service-declarative/LICENSE +21 -0
- package/standard-service-declarative/README.md +39 -0
- package/standard-service-declarative/app/Application.ts +39 -0
- package/standard-service-declarative/app/handlers/WelcomeEventHandler.ts +45 -0
- package/standard-service-declarative/app/services/WelcomeService.ts +38 -0
- package/standard-service-declarative/package.json +36 -0
- package/standard-service-declarative/tsconfig.json +25 -0
- package/standard-service-declarative/vitest.config.ts +24 -0
- package/standard-service-imperative/LICENSE +21 -0
- package/standard-service-imperative/README.md +39 -0
- package/standard-service-imperative/app/Application.ts +11 -0
- package/standard-service-imperative/app/handlers/welcomeEventHandler.ts +31 -0
- package/standard-service-imperative/app/services/welcomeService.ts +38 -0
- package/standard-service-imperative/package.json +35 -0
- package/standard-service-imperative/tsconfig.json +25 -0
- package/standard-service-imperative/vitest.config.ts +24 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import './SettingsForm.css'
|
|
2
|
+
import { FC, FormEvent, useState } from 'react'
|
|
3
|
+
|
|
4
|
+
export const SettingsForm: FC = () => {
|
|
5
|
+
const [email] = useState('user@example.com')
|
|
6
|
+
const [newEmail, setNewEmail] = useState('')
|
|
7
|
+
const [currentPassword, setCurrentPassword] = useState('')
|
|
8
|
+
const [newPassword, setNewPassword] = useState('')
|
|
9
|
+
const [sessions] = useState([
|
|
10
|
+
{ id: 1, device: 'MacBook Pro', location: 'Canada', active: true },
|
|
11
|
+
{ id: 2, device: 'iPhone 14', location: 'Montreal', active: false }
|
|
12
|
+
])
|
|
13
|
+
|
|
14
|
+
const handleEmailChange = (e: FormEvent): void => {
|
|
15
|
+
e.preventDefault()
|
|
16
|
+
// Call backend to update email
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const handlePasswordChange = (e: FormEvent): void => {
|
|
20
|
+
e.preventDefault()
|
|
21
|
+
// Call backend to update password
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className='settings-page'>
|
|
26
|
+
<h1>Settings</h1>
|
|
27
|
+
|
|
28
|
+
<section className='settings-section'>
|
|
29
|
+
<h2>Change Email</h2>
|
|
30
|
+
<form onSubmit={handleEmailChange} className='settings-form'>
|
|
31
|
+
<input
|
|
32
|
+
type='email'
|
|
33
|
+
placeholder='New email'
|
|
34
|
+
value={newEmail}
|
|
35
|
+
onChange={(e) => setNewEmail(e.target.value)}
|
|
36
|
+
required
|
|
37
|
+
/>
|
|
38
|
+
<button type='submit'>Update Email</button>
|
|
39
|
+
</form>
|
|
40
|
+
<p className='current-email'>Current email: <strong>{email}</strong></p>
|
|
41
|
+
</section>
|
|
42
|
+
|
|
43
|
+
<section className='settings-section'>
|
|
44
|
+
<h2>Change Password</h2>
|
|
45
|
+
<form onSubmit={handlePasswordChange} className='settings-form'>
|
|
46
|
+
<input
|
|
47
|
+
type='password'
|
|
48
|
+
placeholder='Current password'
|
|
49
|
+
value={currentPassword}
|
|
50
|
+
onChange={(e) => setCurrentPassword(e.target.value)}
|
|
51
|
+
required
|
|
52
|
+
/>
|
|
53
|
+
<input
|
|
54
|
+
type='password'
|
|
55
|
+
placeholder='New password'
|
|
56
|
+
value={newPassword}
|
|
57
|
+
onChange={(e) => setNewPassword(e.target.value)}
|
|
58
|
+
required
|
|
59
|
+
/>
|
|
60
|
+
<button type='submit'>Update Password</button>
|
|
61
|
+
</form>
|
|
62
|
+
</section>
|
|
63
|
+
|
|
64
|
+
<section className='settings-section'>
|
|
65
|
+
<h2>Active Sessions</h2>
|
|
66
|
+
<ul className='sessions-list'>
|
|
67
|
+
{sessions.map((s) => (
|
|
68
|
+
<li key={s.id}>
|
|
69
|
+
<div>
|
|
70
|
+
<strong>{s.device}</strong> — {s.location}
|
|
71
|
+
</div>
|
|
72
|
+
<span className={`session-status ${s.active ? 'active' : 'inactive'}`}>
|
|
73
|
+
{s.active ? 'Active' : 'Logged out'}
|
|
74
|
+
</span>
|
|
75
|
+
</li>
|
|
76
|
+
))}
|
|
77
|
+
</ul>
|
|
78
|
+
</section>
|
|
79
|
+
|
|
80
|
+
<section className='settings-section danger-zone'>
|
|
81
|
+
<h2>Danger Zone</h2>
|
|
82
|
+
<button className='delete-account-btn'>Delete My Account</button>
|
|
83
|
+
</section>
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.user-avatar-img {
|
|
2
|
+
border-radius: 9999px;
|
|
3
|
+
object-fit: cover;
|
|
4
|
+
background-color: #e5e7eb;
|
|
5
|
+
display: inline-block;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.user-avatar-fallback {
|
|
9
|
+
border-radius: 9999px;
|
|
10
|
+
background-color: #6366f1; /* Indigo */
|
|
11
|
+
color: white;
|
|
12
|
+
font-weight: bold;
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
text-transform: uppercase;
|
|
17
|
+
user-select: none;
|
|
18
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import './UserAvatar.css'
|
|
2
|
+
import { FC, useState } from 'react'
|
|
3
|
+
import { User } from '../../models/User'
|
|
4
|
+
import { StoneLink } from '@stone-js/use-react'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* UserAvatar options.
|
|
8
|
+
*/
|
|
9
|
+
interface UserAvatarOptions {
|
|
10
|
+
user: User
|
|
11
|
+
withLink?: boolean
|
|
12
|
+
className?: string
|
|
13
|
+
size?: 'sm' | 'md' | 'lg' | number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* UserAvatar component.
|
|
18
|
+
*/
|
|
19
|
+
export const UserAvatar: FC<UserAvatarOptions> = ({
|
|
20
|
+
user,
|
|
21
|
+
size = 'md',
|
|
22
|
+
className = '',
|
|
23
|
+
withLink = true
|
|
24
|
+
}) => {
|
|
25
|
+
const [imgError, setImgError] = useState(false)
|
|
26
|
+
const fallback = user.name?.charAt(0).toUpperCase() ?? '?'
|
|
27
|
+
|
|
28
|
+
const getSize = (): number => {
|
|
29
|
+
if (typeof size === 'number') return size
|
|
30
|
+
const sizes = { sm: 28, md: 36, lg: 48 }
|
|
31
|
+
return sizes[size] ?? 36
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const dimension = getSize()
|
|
35
|
+
|
|
36
|
+
const shouldShowFallback = user.avatar === undefined || imgError
|
|
37
|
+
|
|
38
|
+
return shouldShowFallback
|
|
39
|
+
? (
|
|
40
|
+
<StoneLink to={withLink ? `/users/${user.id}` : undefined} href='#'>
|
|
41
|
+
<div
|
|
42
|
+
className={`user-avatar-fallback ${className}`}
|
|
43
|
+
style={{ width: dimension, height: dimension, fontSize: dimension / 2.2 }}
|
|
44
|
+
>
|
|
45
|
+
{fallback}
|
|
46
|
+
</div>
|
|
47
|
+
</StoneLink>
|
|
48
|
+
)
|
|
49
|
+
: (
|
|
50
|
+
<StoneLink to={withLink ? `/users/${user.id}` : undefined} href='#'>
|
|
51
|
+
<img
|
|
52
|
+
src={user.avatar}
|
|
53
|
+
alt={user.name}
|
|
54
|
+
className={`user-avatar-img ${className}`}
|
|
55
|
+
style={{ width: dimension, height: dimension }}
|
|
56
|
+
onError={() => setImgError(true)}
|
|
57
|
+
/>
|
|
58
|
+
</StoneLink>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.user-badge {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 0.5rem;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.user-badge button {
|
|
8
|
+
text-align: left;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.user-badge.vertical {
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-items: flex-start;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.user-badge-info {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
line-height: 1.2;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.user-badge-name {
|
|
24
|
+
font-weight: 600;
|
|
25
|
+
color: #111827;
|
|
26
|
+
font-size: 0.95rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.user-badge-details {
|
|
30
|
+
margin-top: 4px;
|
|
31
|
+
font-size: 0.75rem;
|
|
32
|
+
color: #6b7280;
|
|
33
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import './UserBadge.css'
|
|
2
|
+
import { FC } from 'react'
|
|
3
|
+
import { User } from '../../models/User'
|
|
4
|
+
import { dateTimeFromNow } from '../../utils'
|
|
5
|
+
import { StoneLink } from '@stone-js/use-react'
|
|
6
|
+
import { UserAvatar } from '../UserAvatar/UserAvatar'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* UserBadge options.
|
|
10
|
+
*/
|
|
11
|
+
interface UserBadgeOptions {
|
|
12
|
+
user: User
|
|
13
|
+
withLink?: boolean
|
|
14
|
+
createdAt?: number
|
|
15
|
+
className?: string
|
|
16
|
+
onClick?: () => void
|
|
17
|
+
size?: 'sm' | 'md' | 'lg' | number
|
|
18
|
+
direction?: 'horizontal' | 'vertical'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* UserBadge component.
|
|
23
|
+
*/
|
|
24
|
+
export const UserBadge: FC<UserBadgeOptions> = ({
|
|
25
|
+
user,
|
|
26
|
+
createdAt,
|
|
27
|
+
size = 'md',
|
|
28
|
+
direction = 'horizontal',
|
|
29
|
+
onClick,
|
|
30
|
+
withLink = true,
|
|
31
|
+
className = ''
|
|
32
|
+
}) => {
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
className={`user-badge ${direction} ${className}`}
|
|
36
|
+
onClick={onClick}
|
|
37
|
+
style={{ cursor: (onClick != null) ? 'pointer' : 'default' }}
|
|
38
|
+
>
|
|
39
|
+
<UserAvatar withLink={withLink} user={user} size={size} />
|
|
40
|
+
<div className='user-badge-info'>
|
|
41
|
+
<StoneLink to={withLink ? `/users/${user.id}` : undefined} href='#' className='user-badge-name'>
|
|
42
|
+
{user.name}
|
|
43
|
+
</StoneLink>
|
|
44
|
+
{createdAt !== undefined && <span className='user-badge-details'>{dateTimeFromNow(createdAt)}</span>}
|
|
45
|
+
{createdAt === undefined && user.email !== undefined && <span className='user-badge-details'>{user.email}</span>}
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
.user-card {
|
|
2
|
+
background: #ffffff;
|
|
3
|
+
border: 1px solid #e5e7eb;
|
|
4
|
+
border-radius: 12px;
|
|
5
|
+
padding: 1rem;
|
|
6
|
+
box-shadow: 0 2px 6px rgba(0,0,0,0.03);
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: 0.75rem;
|
|
10
|
+
transition: box-shadow 0.2s ease;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.user-card:hover {
|
|
14
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.user-card-header {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: 0.75rem;
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.user-card-info {
|
|
25
|
+
flex: 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.user-card-name {
|
|
29
|
+
display: block;
|
|
30
|
+
font-size: 1rem;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
color: #111827;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.user-card-email {
|
|
36
|
+
display: block;
|
|
37
|
+
margin-top: 4px;
|
|
38
|
+
font-size: 0.85rem;
|
|
39
|
+
color: #6b7280;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.user-status {
|
|
43
|
+
position: absolute;
|
|
44
|
+
right: 0.5rem;
|
|
45
|
+
top: 0.5rem;
|
|
46
|
+
width: 10px;
|
|
47
|
+
height: 10px;
|
|
48
|
+
border-radius: 50%;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.user-status.online {
|
|
52
|
+
background: #10b981;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.user-status.offline {
|
|
56
|
+
background: #d1d5db;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.user-card-meta {
|
|
60
|
+
display: flex;
|
|
61
|
+
gap: 1rem;
|
|
62
|
+
font-size: 0.85rem;
|
|
63
|
+
color: #4b5563;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.user-last-seen {
|
|
67
|
+
font-size: 0.75rem;
|
|
68
|
+
color: #9ca3af;
|
|
69
|
+
text-align: right;
|
|
70
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { FC } from 'react'
|
|
2
|
+
import { User } from '../../models/User'
|
|
3
|
+
import { dateTimeFromNow } from '../../utils'
|
|
4
|
+
import { StoneLink } from '@stone-js/use-react'
|
|
5
|
+
import { UserAvatar } from '../UserAvatar/UserAvatar'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* UserCard options.
|
|
9
|
+
*/
|
|
10
|
+
interface UserCardOptions {
|
|
11
|
+
user: User
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* UserCard component.
|
|
16
|
+
*/
|
|
17
|
+
export const UserCard: FC<UserCardOptions> = ({ user }) => {
|
|
18
|
+
return (
|
|
19
|
+
<div className='user-card'>
|
|
20
|
+
<div className='user-card-header'>
|
|
21
|
+
<StoneLink to={`/users/${user.id}`} className='user-card-link'>
|
|
22
|
+
<UserAvatar user={user} size='lg' />
|
|
23
|
+
</StoneLink>
|
|
24
|
+
<div className='user-card-info'>
|
|
25
|
+
<StoneLink to={`/users/${user.id}`} className='user-card-name'>{user.name}</StoneLink>
|
|
26
|
+
<StoneLink to={`/users/${user.id}`} className='user-card-email'>{user.email}</StoneLink>
|
|
27
|
+
</div>
|
|
28
|
+
<span className={`user-status ${user.isOnline ? 'online' : 'offline'}`} />
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div className='user-card-meta'>
|
|
32
|
+
<span>📝 {user.postCount} Posts</span>
|
|
33
|
+
<span>💬 {user.commentCount} Comments</span>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
{!user.isOnline && (
|
|
37
|
+
<div className='user-last-seen'>
|
|
38
|
+
Last seen {dateTimeFromNow(user.lastSeen)}
|
|
39
|
+
</div>
|
|
40
|
+
)}
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getString } from '@stone-js/env'
|
|
2
|
+
import { NODE_HTTP_PLATFORM } from '@stone-js/node-http-adapter'
|
|
3
|
+
import { defineConfig, IBlueprint, Promiseable } from '@stone-js/core'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* App Configuration
|
|
7
|
+
*/
|
|
8
|
+
export const AppConfig = defineConfig({
|
|
9
|
+
configure (blueprint: IBlueprint): Promiseable<void> {
|
|
10
|
+
blueprint
|
|
11
|
+
.set('stone.kernel.skipMiddleware', false)
|
|
12
|
+
.set('app.api.baseURL', getString('API_BASE_URL', 'http://localhost:8080'))
|
|
13
|
+
},
|
|
14
|
+
afterConfigure (blueprint: IBlueprint): Promiseable<void> {
|
|
15
|
+
if (blueprint.is('stone.adapter.platform', NODE_HTTP_PLATFORM)) {
|
|
16
|
+
blueprint.set('stone.adapter.url', 'http://localhost:3100')
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
})
|
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import './DefaultErrorPage.css'
|
|
2
|
+
import { JSX } from 'react'
|
|
3
|
+
import { ILogger } from '@stone-js/core'
|
|
4
|
+
import { IErrorPage, ReactIncomingEvent, ErrorPageRenderContext, defineErrorPage } from '@stone-js/use-react'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Default Error Page.
|
|
8
|
+
*/
|
|
9
|
+
export const DefaultErrorPage = ({ logger }: { logger: ILogger }): IErrorPage<ReactIncomingEvent> => ({
|
|
10
|
+
/**
|
|
11
|
+
* Handle the error.
|
|
12
|
+
*
|
|
13
|
+
* @param error - The error to handle.
|
|
14
|
+
* @returns The response.
|
|
15
|
+
*/
|
|
16
|
+
handle (error: any): { message: string } {
|
|
17
|
+
logger.error(error.message, { error })
|
|
18
|
+
return { message: 'Oops! Something went wrong!' }
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Render the component.
|
|
23
|
+
*
|
|
24
|
+
* @param options - The options for rendering the component.
|
|
25
|
+
* @returns The rendered component.
|
|
26
|
+
*/
|
|
27
|
+
render ({ data, statusCode }: ErrorPageRenderContext<Error>): JSX.Element {
|
|
28
|
+
return (
|
|
29
|
+
<div className='text-center'>
|
|
30
|
+
<h1 className='h1'>{statusCode}</h1>
|
|
31
|
+
<h2 className='h4'>An Error occured!</h2>
|
|
32
|
+
<p className='text-muted mt-24'>{data?.message}</p>
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Default Error Page Blueprint.
|
|
40
|
+
*/
|
|
41
|
+
export const DefaultErrorPageBlueprint = defineErrorPage(DefaultErrorPage, { layout: 'error', error: 'default' })
|
|
File without changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import './ForbiddenErrorPage.css'
|
|
2
|
+
import { JSX } from 'react'
|
|
3
|
+
import { ILogger } from '@stone-js/core'
|
|
4
|
+
import { ForbiddenError } from '../../errors/ForbiddenError'
|
|
5
|
+
import { IErrorPage, ReactIncomingEvent, ErrorPageRenderContext, defineErrorPage } from '@stone-js/use-react'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Forbidden Error Page.
|
|
9
|
+
*/
|
|
10
|
+
export const ForbiddenErrorPage = ({ logger }: { logger: ILogger }): IErrorPage<ReactIncomingEvent> => ({
|
|
11
|
+
/**
|
|
12
|
+
* Handle the error.
|
|
13
|
+
*
|
|
14
|
+
* @param error - The error to handle.
|
|
15
|
+
* @returns The response.
|
|
16
|
+
*/
|
|
17
|
+
handle (error: ForbiddenError): { message: string } {
|
|
18
|
+
logger.error(error.message, { error })
|
|
19
|
+
return { message: "I think you're not supposed to be here! Eh ?" }
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Render the component.
|
|
24
|
+
*
|
|
25
|
+
* @param options - The options for rendering the component.
|
|
26
|
+
* @returns The rendered component.
|
|
27
|
+
*/
|
|
28
|
+
render ({ data, statusCode }: ErrorPageRenderContext<ForbiddenError>): JSX.Element {
|
|
29
|
+
return (
|
|
30
|
+
<div className='text-center'>
|
|
31
|
+
<h1 className='h1'>{statusCode}</h1>
|
|
32
|
+
<h2 className='h4'>Are you in the right place?</h2>
|
|
33
|
+
<p className='text-muted mt-24'>{data?.message}</p>
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Forbidden Error Page Blueprint.
|
|
41
|
+
*/
|
|
42
|
+
export const ForbiddenErrorPageBlueprint = defineErrorPage(ForbiddenErrorPage, { layout: 'error', error: 'ForbiddenError' })
|
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import './NotFoundErrorPage.css'
|
|
2
|
+
import { JSX } from 'react'
|
|
3
|
+
import { ILogger } from '@stone-js/core'
|
|
4
|
+
import { RouteNotFoundError } from '@stone-js/router'
|
|
5
|
+
import { IErrorPage, ReactIncomingEvent, ErrorPageRenderContext, defineErrorPage } from '@stone-js/use-react'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* NotFound Error Page.
|
|
9
|
+
*/
|
|
10
|
+
export const NotFoundErrorPage = ({ logger }: { logger: ILogger }): IErrorPage<ReactIncomingEvent> => ({
|
|
11
|
+
/**
|
|
12
|
+
* Handle the error.
|
|
13
|
+
*
|
|
14
|
+
* @param error - The error to handle.
|
|
15
|
+
* @param event - The incoming event.
|
|
16
|
+
* @returns The response.
|
|
17
|
+
*/
|
|
18
|
+
handle (error: RouteNotFoundError, event: ReactIncomingEvent): { message: string } {
|
|
19
|
+
logger.error(error.message, { error })
|
|
20
|
+
return { message: `Page not found: ${event.pathname}` }
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Render the component.
|
|
25
|
+
*
|
|
26
|
+
* @param options - The options for rendering the component.
|
|
27
|
+
* @returns The rendered component.
|
|
28
|
+
*/
|
|
29
|
+
render ({ data, statusCode }: ErrorPageRenderContext<RouteNotFoundError>): JSX.Element {
|
|
30
|
+
return (
|
|
31
|
+
<div className='text-center'>
|
|
32
|
+
<h1 className='h1'>{statusCode}</h1>
|
|
33
|
+
<h2 className='h4'>OOps! It seems you are lost?</h2>
|
|
34
|
+
<p className='text-muted mt-24'>{data?.message}</p>
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* NotFound Error Page Blueprint.
|
|
42
|
+
*/
|
|
43
|
+
export const NotFoundErrorPageBlueprint = defineErrorPage(
|
|
44
|
+
NotFoundErrorPage,
|
|
45
|
+
{
|
|
46
|
+
layout: 'error',
|
|
47
|
+
error: ['RouteNotFoundError', 'PostNotFoundError', 'UserNotFoundError']
|
|
48
|
+
}
|
|
49
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import './UnauthorizedErrorPage.css'
|
|
2
|
+
import { JSX } from 'react'
|
|
3
|
+
import { ILogger } from '@stone-js/core'
|
|
4
|
+
import { UnauthorizedError } from '../../errors/UnauthorizedError'
|
|
5
|
+
import { IErrorPage, ReactIncomingEvent, ErrorPageRenderContext, defineErrorPage } from '@stone-js/use-react'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Unauthorized Error Handler component.
|
|
9
|
+
*/
|
|
10
|
+
export const UnauthorizedErrorPage = ({ logger }: { logger: ILogger }): IErrorPage<ReactIncomingEvent> => ({
|
|
11
|
+
/**
|
|
12
|
+
* Handle the error.
|
|
13
|
+
*
|
|
14
|
+
* @param error - The error to handle.
|
|
15
|
+
* @returns The response.
|
|
16
|
+
*/
|
|
17
|
+
handle (error: UnauthorizedError) {
|
|
18
|
+
logger.error(error.message, { error })
|
|
19
|
+
return { message: "I think you're an alien! Eh ?" }
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Render the component.
|
|
24
|
+
*
|
|
25
|
+
* @param options - The options for rendering the component.
|
|
26
|
+
* @returns The rendered component.
|
|
27
|
+
*/
|
|
28
|
+
render ({ data, statusCode }: ErrorPageRenderContext<UnauthorizedError>): JSX.Element {
|
|
29
|
+
return (
|
|
30
|
+
<div className='text-center'>
|
|
31
|
+
<h1 className='h1'>{statusCode}</h1>
|
|
32
|
+
<h2 className='h4'>Are you in the right place?</h2>
|
|
33
|
+
<p className='text-muted mt-24'>{data?.message}</p>
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Unauthorized Error Page Blueprint.
|
|
41
|
+
*/
|
|
42
|
+
export const UnauthorizedErrorPageBlueprint = defineErrorPage(UnauthorizedErrorPage, { layout: 'error', error: 'UnauthorizedError' })
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ErrorOptions, RuntimeError } from '@stone-js/core'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Not Forbidden Error
|
|
5
|
+
*/
|
|
6
|
+
export class ForbiddenError extends RuntimeError {
|
|
7
|
+
constructor (message: string, options?: ErrorOptions) {
|
|
8
|
+
super(message, options)
|
|
9
|
+
this.name = 'ForbiddenError'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ErrorOptions, RuntimeError } from '@stone-js/core'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Post Not found Error
|
|
5
|
+
*/
|
|
6
|
+
export class PostNotFoundError extends RuntimeError {
|
|
7
|
+
constructor (message: string, options: ErrorOptions = {}) {
|
|
8
|
+
super(message, options)
|
|
9
|
+
this.name = 'PostNotFoundError'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ErrorOptions, RuntimeError } from '@stone-js/core'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unauthorized Error
|
|
5
|
+
*/
|
|
6
|
+
export class UnauthorizedError extends RuntimeError {
|
|
7
|
+
constructor (message: string, options?: ErrorOptions) {
|
|
8
|
+
super(message, options)
|
|
9
|
+
this.name = 'UnauthorizedError'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ErrorOptions, RuntimeError } from '@stone-js/core'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* User Not found Error
|
|
5
|
+
*/
|
|
6
|
+
export class UserNotFoundError extends RuntimeError {
|
|
7
|
+
constructor (message: string, options: ErrorOptions = {}) {
|
|
8
|
+
super(message, options)
|
|
9
|
+
this.name = 'UserNotFoundError'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { User } from '../models/User'
|
|
2
|
+
import { Event } from '@stone-js/core'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* User Event
|
|
6
|
+
*/
|
|
7
|
+
export class UserEvent extends Event {
|
|
8
|
+
/**
|
|
9
|
+
* USER_CREATED Event name, fires after a user have been created.
|
|
10
|
+
*
|
|
11
|
+
* @event UserEvent#USER_CREATED
|
|
12
|
+
*/
|
|
13
|
+
static USER_CREATED: string = 'user.created'
|
|
14
|
+
|
|
15
|
+
constructor (public readonly user: Partial<User>) {
|
|
16
|
+
super({ type: UserEvent.USER_CREATED })
|
|
17
|
+
}
|
|
18
|
+
}
|