@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,24 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config'
|
|
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
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# continuum-showcase
|
|
2
|
+
|
|
3
|
+
A small example app that exercises the frontend features added in the 2026-07 continuum pass.
|
|
4
|
+
It doubles as a manual test bed for the new APIs.
|
|
5
|
+
|
|
6
|
+
## What it demonstrates
|
|
7
|
+
|
|
8
|
+
| Feature | Where |
|
|
9
|
+
|---|---|
|
|
10
|
+
| Fluent head/meta API (`createHead()`) | `app/pages/HomePage.tsx`, `app/pages/BlogPostPage.tsx` |
|
|
11
|
+
| Title template (`%s — …`) | both pages |
|
|
12
|
+
| Open Graph (incl. structured `og:image`) | both pages |
|
|
13
|
+
| Twitter card | both pages |
|
|
14
|
+
| JSON-LD structured data | both pages |
|
|
15
|
+
| Canonical + robots | HomePage |
|
|
16
|
+
| Data-driven head from the loader (`handle → head`) | BlogPostPage |
|
|
17
|
+
| Static-asset import via `@img` alias | `HomePage.tsx` (`import logo from '@img/logo.png'`) |
|
|
18
|
+
| Asset alias config | `stone.config.mjs` (`assets.aliases`) |
|
|
19
|
+
| SSR head serialization | `rendering: 'ssr'` |
|
|
20
|
+
|
|
21
|
+
## Run
|
|
22
|
+
|
|
23
|
+
> Requires the monorepo workspace to be installed (`pnpm install` at the root) so the
|
|
24
|
+
> `@stone-js/*` workspace packages resolve.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pnpm --filter continuum-showcase dev # stone dev — SSR dev server
|
|
28
|
+
pnpm --filter continuum-showcase build # stone build
|
|
29
|
+
pnpm --filter continuum-showcase preview # serve the build
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Manual verification checklist
|
|
33
|
+
|
|
34
|
+
1. `stone dev`, open `/` → view source: `<title>Home — Stone.js Showcase</title>`, `og:*`,
|
|
35
|
+
`twitter:*` and a `<script type="application/ld+json">` are present in the SSR HTML.
|
|
36
|
+
2. The `@img/logo.png` import resolves (no build error) and the logo renders.
|
|
37
|
+
3. `/blog/hello-world` → head reflects the post data (`og:type=article`, per-post JSON-LD).
|
|
38
|
+
4. Put an actual `assets/images/logo.png` in place before running.
|
|
39
|
+
|
|
40
|
+
## Status
|
|
41
|
+
|
|
42
|
+
Reference example added in the continuum pass. End-to-end build/render still needs a run of
|
|
43
|
+
the CLI toolchain (Vite/browser) to be fully validated — it is correct against the current
|
|
44
|
+
`@stone-js/use-view` / `@stone-js/use-react` / `@stone-js/cli` APIs.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient module declarations so component imports of static assets type-check.
|
|
3
|
+
* The actual resolution is done by the CLI's Vite `resolve.alias` (see stone.config.mjs).
|
|
4
|
+
*/
|
|
5
|
+
declare module '*.png' {
|
|
6
|
+
const src: string
|
|
7
|
+
export default src
|
|
8
|
+
}
|
|
9
|
+
declare module '*.jpg' {
|
|
10
|
+
const src: string
|
|
11
|
+
export default src
|
|
12
|
+
}
|
|
13
|
+
declare module '*.svg' {
|
|
14
|
+
const src: string
|
|
15
|
+
export default src
|
|
16
|
+
}
|
|
17
|
+
declare module '*.webp' {
|
|
18
|
+
const src: string
|
|
19
|
+
export default src
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Asset alias namespaces (mirror stone.config.mjs `assets.aliases`).
|
|
23
|
+
declare module '@img/*' {
|
|
24
|
+
const src: string
|
|
25
|
+
export default src
|
|
26
|
+
}
|
|
27
|
+
declare module '@assets/*' {
|
|
28
|
+
const src: string
|
|
29
|
+
export default src
|
|
30
|
+
}
|
|
31
|
+
declare module '@css/*' {
|
|
32
|
+
const href: string
|
|
33
|
+
export default href
|
|
34
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { PageLayout } from '@stone-js/router'
|
|
3
|
+
import { IPageLayout, PageLayoutRenderContext } from '@stone-js/use-react'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The default layout. In a future iteration (hierarchical heads), a layout may also
|
|
7
|
+
* contribute a base head via `createHead().merge(...)`.
|
|
8
|
+
*/
|
|
9
|
+
@PageLayout({ name: 'default' })
|
|
10
|
+
export class MainLayout implements IPageLayout {
|
|
11
|
+
render ({ children }: PageLayoutRenderContext) {
|
|
12
|
+
return (
|
|
13
|
+
<div className="app">
|
|
14
|
+
<header><nav><a href="/">Home</a> · <a href="/blog/hello-world">Blog</a></nav></header>
|
|
15
|
+
{children}
|
|
16
|
+
<footer>◆ Stone.js — the continuum framework</footer>
|
|
17
|
+
</div>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Page } from '@stone-js/router'
|
|
3
|
+
import {
|
|
4
|
+
createHead,
|
|
5
|
+
IPage,
|
|
6
|
+
PageRenderContext,
|
|
7
|
+
PageHeadContext,
|
|
8
|
+
ReactIncomingEvent
|
|
9
|
+
} from '@stone-js/use-react'
|
|
10
|
+
|
|
11
|
+
interface Post {
|
|
12
|
+
slug: string
|
|
13
|
+
title: string
|
|
14
|
+
excerpt: string
|
|
15
|
+
cover: string
|
|
16
|
+
body: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Blog post page — demonstrates a fully dynamic, data-driven head built from the
|
|
21
|
+
* loader (`handle`) output, including an `article` Open Graph type and per-post JSON-LD.
|
|
22
|
+
*/
|
|
23
|
+
@Page({ path: '/blog/:slug' })
|
|
24
|
+
export class BlogPostPage implements IPage<ReactIncomingEvent> {
|
|
25
|
+
handle (event: ReactIncomingEvent): Post {
|
|
26
|
+
const slug = event.get<string>('slug', 'hello-world')
|
|
27
|
+
return {
|
|
28
|
+
slug,
|
|
29
|
+
title: 'Hello, Continuum',
|
|
30
|
+
excerpt: 'How Stone.js applies context to your domain at runtime.',
|
|
31
|
+
cover: `https://showcase.stonejs.dev/covers/${slug}.png`,
|
|
32
|
+
body: 'Full article content…'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
head ({ data }: PageHeadContext<Post>) {
|
|
37
|
+
const post = data as Post
|
|
38
|
+
return createHead()
|
|
39
|
+
.title(post.title)
|
|
40
|
+
.titleTemplate('%s — Stone.js Blog')
|
|
41
|
+
.description(post.excerpt)
|
|
42
|
+
.canonical(`https://showcase.stonejs.dev/blog/${post.slug}`)
|
|
43
|
+
.og({ type: 'article', image: post.cover, siteName: 'Stone.js Blog' })
|
|
44
|
+
.twitter({ card: 'summary_large_image', site: '@stonejs' })
|
|
45
|
+
.jsonLd({
|
|
46
|
+
'@context': 'https://schema.org',
|
|
47
|
+
'@type': 'Article',
|
|
48
|
+
headline: post.title,
|
|
49
|
+
description: post.excerpt
|
|
50
|
+
})
|
|
51
|
+
.toContext()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
render ({ data }: PageRenderContext<Post>) {
|
|
55
|
+
return (
|
|
56
|
+
<article>
|
|
57
|
+
<h1>{data?.title}</h1>
|
|
58
|
+
<p>{data?.body}</p>
|
|
59
|
+
</article>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Page } from '@stone-js/router'
|
|
3
|
+
import logo from '@img/logo.png'
|
|
4
|
+
import {
|
|
5
|
+
createHead,
|
|
6
|
+
IPage,
|
|
7
|
+
PageRenderContext,
|
|
8
|
+
ReactIncomingEvent
|
|
9
|
+
} from '@stone-js/use-react'
|
|
10
|
+
|
|
11
|
+
interface HomeData {
|
|
12
|
+
message: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Home page — demonstrates:
|
|
17
|
+
* - the fluent head/meta API (title template, description, canonical, Open Graph,
|
|
18
|
+
* Twitter card and JSON-LD structured data), all from `head()`;
|
|
19
|
+
* - importing a static asset via the `@img` alias (resolved by the CLI's Vite config).
|
|
20
|
+
*/
|
|
21
|
+
@Page({ path: '/' })
|
|
22
|
+
export class HomePage implements IPage<ReactIncomingEvent> {
|
|
23
|
+
handle (): HomeData {
|
|
24
|
+
return { message: 'Write your domain once. Stone.js applies the context.' }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
head () {
|
|
28
|
+
return createHead()
|
|
29
|
+
.title('Home')
|
|
30
|
+
.titleTemplate('%s — Stone.js Showcase')
|
|
31
|
+
.description('A Continuum Architecture showcase: universal pages, SSR head, static assets.')
|
|
32
|
+
.canonical('https://showcase.stonejs.dev/')
|
|
33
|
+
.og({
|
|
34
|
+
type: 'website',
|
|
35
|
+
siteName: 'Stone.js Showcase',
|
|
36
|
+
image: { url: 'https://showcase.stonejs.dev/og.png', width: 1200, height: 630, alt: 'Stone.js' }
|
|
37
|
+
})
|
|
38
|
+
.twitter({ card: 'summary_large_image', site: '@stonejs' })
|
|
39
|
+
.robots({ index: true, follow: true })
|
|
40
|
+
.jsonLd({
|
|
41
|
+
'@context': 'https://schema.org',
|
|
42
|
+
'@type': 'WebSite',
|
|
43
|
+
name: 'Stone.js Showcase',
|
|
44
|
+
url: 'https://showcase.stonejs.dev/'
|
|
45
|
+
})
|
|
46
|
+
.toContext()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
render ({ data }: PageRenderContext<HomeData>) {
|
|
50
|
+
return (
|
|
51
|
+
<main>
|
|
52
|
+
<img src={logo} alt="Stone.js" width={96} height={96} />
|
|
53
|
+
<h1>Stone.js Showcase</h1>
|
|
54
|
+
<p>{data?.message}</p>
|
|
55
|
+
</main>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "continuum-showcase",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Showcase app exercising the new head/OG API and static-asset aliases (2026-07 continuum pass).",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "stone dev",
|
|
9
|
+
"build": "stone build",
|
|
10
|
+
"preview": "stone preview"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@stone-js/browser-adapter": "^0.8.3",
|
|
14
|
+
"@stone-js/core": "^0.8.3",
|
|
15
|
+
"@stone-js/node-http-adapter": "^0.8.3",
|
|
16
|
+
"@stone-js/router": "^0.8.3",
|
|
17
|
+
"@stone-js/use-react": "^0.8.3",
|
|
18
|
+
"@stone-js/use-view": "^0.8.3",
|
|
19
|
+
"react": "^19.0.0",
|
|
20
|
+
"react-dom": "^19.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@stone-js/cli": "^0.8.3"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from '@stone-js/cli'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build configuration for the showcase.
|
|
5
|
+
*
|
|
6
|
+
* - `target: 'react'` + `rendering: 'ssr'` exercises the server-rendered head pipeline.
|
|
7
|
+
* - `assets` enables the `@img` / `@css` / `@assets` import aliases used in components.
|
|
8
|
+
*/
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
target: 'react',
|
|
11
|
+
rendering: 'ssr',
|
|
12
|
+
assets: {
|
|
13
|
+
dir: 'assets',
|
|
14
|
+
aliases: {
|
|
15
|
+
'@assets': '',
|
|
16
|
+
'@img': 'images',
|
|
17
|
+
'@css': 'css'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
BASE_URL=http://localhost:3100
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
API_BASE_URL=http://localhost:8080
|
|
@@ -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 - Full starter
|
|
2
|
+
|
|
3
|
+
Stone.js's full starter to create web 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,85 @@
|
|
|
1
|
+
import { Routing } from '@stone-js/router'
|
|
2
|
+
import { Browser } from '@stone-js/browser-adapter'
|
|
3
|
+
import { Hook, UseReact } from '@stone-js/use-react'
|
|
4
|
+
import { NodeHttp } from '@stone-js/node-http-adapter'
|
|
5
|
+
import { NodeConsole } from '@stone-js/node-cli-adapter'
|
|
6
|
+
import { IBlueprint, IContainer, ILogger, LogLevel, Promiseable, StoneApp } from '@stone-js/core'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Application
|
|
10
|
+
*
|
|
11
|
+
* This is the main application entry point.
|
|
12
|
+
*
|
|
13
|
+
* @StoneApp() is used to enable the Stone application, it is mandatory.
|
|
14
|
+
* @Routing() is used to enable the routing feature.
|
|
15
|
+
* @NodeHttp() is used to enable the Node HTTP adapter.
|
|
16
|
+
* @NodeConsole() is used to enable the Node Console adapter.
|
|
17
|
+
* @NodeConsole() requires the incoming event type.
|
|
18
|
+
* BodyEventMiddleware is used to parse the incoming event body.
|
|
19
|
+
* BodyEventMiddleware is imported because it is not installed by default.
|
|
20
|
+
*
|
|
21
|
+
* You have access to the Stone's application lifecycle hooks.
|
|
22
|
+
* You can also have access to them in the ServiceProviders.
|
|
23
|
+
* They are optional and you can remove them if you don't need them.
|
|
24
|
+
*/
|
|
25
|
+
@Routing()
|
|
26
|
+
@Browser()
|
|
27
|
+
@UseReact()
|
|
28
|
+
@NodeConsole()
|
|
29
|
+
@NodeHttp({ default: true, url: 'http://localhost:3100' })
|
|
30
|
+
@StoneApp({ name: 'My Stone', logger: { level: LogLevel.DEBUG } })
|
|
31
|
+
export class Application {
|
|
32
|
+
/**
|
|
33
|
+
* Start the application
|
|
34
|
+
* Run at each cold start.
|
|
35
|
+
* At this point, you only have access to the blueprint.
|
|
36
|
+
* Because the container is not yet created.
|
|
37
|
+
*/
|
|
38
|
+
@Hook('onStart')
|
|
39
|
+
onStart ({ blueprint }: { blueprint: IBlueprint }): void {
|
|
40
|
+
const AppName = blueprint.get<string>('stone.name')
|
|
41
|
+
console.log(`${String(AppName)}'s Application is starting`)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Prepare the application
|
|
46
|
+
* Run at each warm start in server context.
|
|
47
|
+
* And at each cold start in browser context.
|
|
48
|
+
*/
|
|
49
|
+
@Hook('onInit')
|
|
50
|
+
onInit ({ logger }: { logger: ILogger }): Promiseable<void> {
|
|
51
|
+
logger.info('Application is initializing')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Before handle the incoming event
|
|
56
|
+
*/
|
|
57
|
+
@Hook('onHandlingEvent')
|
|
58
|
+
onHandlingEvent ({ logger }: { logger: ILogger }): Promiseable<void> {
|
|
59
|
+
logger.info('Before handle incoming event')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Before prepare the react page
|
|
64
|
+
*/
|
|
65
|
+
@Hook('onPreparingPage')
|
|
66
|
+
onPreparingPage ({ container }: { container: IContainer }): Promiseable<void> {
|
|
67
|
+
container.make<ILogger>('logger').info('Before prepare the react page')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* After the incoming event has been processed
|
|
72
|
+
*/
|
|
73
|
+
@Hook('onProcessingKernelMiddleware')
|
|
74
|
+
onProcessingKernelMiddleware ({ pipe }: { pipe: any }): Promiseable<void> {
|
|
75
|
+
console.info('Kernel middleware is processing', pipe.module.name)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* After the platform event has been sent to the user
|
|
80
|
+
*/
|
|
81
|
+
@Hook('onTerminate')
|
|
82
|
+
onTerminate ({ logger }: { logger: ILogger }): Promiseable<void> {
|
|
83
|
+
logger.info('The event has been sent to the user')
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { isEmpty, isNotEmpty } from '@stone-js/core'
|
|
2
|
+
import { TokenService } from '../services/TokenService'
|
|
3
|
+
import { UnauthorizedError } from '../errors/UnauthorizedError'
|
|
4
|
+
import { isServer, ReactIncomingEvent } from '@stone-js/use-react'
|
|
5
|
+
import { AxiosError, Axios, AxiosRequestConfig, AxiosResponse } from 'axios'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Axios Client Options
|
|
9
|
+
*/
|
|
10
|
+
export interface AxiosClientOptions {
|
|
11
|
+
axios: Axios
|
|
12
|
+
event: ReactIncomingEvent
|
|
13
|
+
tokenService: TokenService
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Axios Client
|
|
18
|
+
*/
|
|
19
|
+
export class AxiosClient {
|
|
20
|
+
private readonly axios: Axios
|
|
21
|
+
private readonly event: ReactIncomingEvent
|
|
22
|
+
private readonly tokenService: TokenService
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create a new Axios Client
|
|
26
|
+
*
|
|
27
|
+
* @param options - The options to create the Axios Client.
|
|
28
|
+
*/
|
|
29
|
+
constructor ({ axios, event, tokenService }: AxiosClientOptions) {
|
|
30
|
+
this.axios = axios
|
|
31
|
+
this.event = event
|
|
32
|
+
this.tokenService = tokenService
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Make a request
|
|
37
|
+
*
|
|
38
|
+
* @param url - The URL to request
|
|
39
|
+
* @param data - The data to send
|
|
40
|
+
* @param options - The request options
|
|
41
|
+
* @returns The response data
|
|
42
|
+
* @throws NotAuthenticateError
|
|
43
|
+
* @throws AxiosError
|
|
44
|
+
*/
|
|
45
|
+
async request<T = any, R = AxiosResponse<T>, D = any>(url: string, payload?: D, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
46
|
+
try {
|
|
47
|
+
const headers: any = ((options?.headers) != null) || {}
|
|
48
|
+
const token = await this.getAccessToken()
|
|
49
|
+
// const validateStatus = (status: number) => status >= 200 && status < 500
|
|
50
|
+
|
|
51
|
+
if (isServer()) { headers['User-Agent'] = this.event.userAgent }
|
|
52
|
+
|
|
53
|
+
headers.Accept ??= 'application/json'
|
|
54
|
+
headers['Content-Type'] ??= 'application/json'
|
|
55
|
+
headers.Authorization = isEmpty(token) ? '' : `Bearer ${token}`
|
|
56
|
+
|
|
57
|
+
return (await this.axios.request({ ...options, url, data: payload, headers /* validateStatus */ })).data
|
|
58
|
+
} catch (error: any) {
|
|
59
|
+
if (isNotEmpty<AxiosError<R, D>>(error) && error.status === 401) {
|
|
60
|
+
throw new UnauthorizedError(error.message, { cause: error })
|
|
61
|
+
} else {
|
|
62
|
+
throw error
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Make a GET request
|
|
69
|
+
*
|
|
70
|
+
* @param url - The URL to request
|
|
71
|
+
* @param options - The request options
|
|
72
|
+
* @returns The response data
|
|
73
|
+
*/
|
|
74
|
+
async get<T = any, R = AxiosResponse<T>, D = any>(url: string, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
75
|
+
return await this.request<T, R, D>(url, undefined, { ...options, method: 'GET' })
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Make a POST request
|
|
80
|
+
*
|
|
81
|
+
* @param url - The URL to request
|
|
82
|
+
* @param data - The data to send
|
|
83
|
+
* @param options - The request options
|
|
84
|
+
* @returns The response data
|
|
85
|
+
*/
|
|
86
|
+
async post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
87
|
+
return await this.request<T, R, D>(url, data, { ...options, method: 'POST' })
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Make a PUT request
|
|
92
|
+
*
|
|
93
|
+
* @param url - The URL to request
|
|
94
|
+
* @param data - The data to send
|
|
95
|
+
* @param options - The request options
|
|
96
|
+
* @returns The response data
|
|
97
|
+
*/
|
|
98
|
+
async put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
99
|
+
return await this.request<T, R, D>(url, data, { ...options, method: 'PUT' })
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Make a PATCH request
|
|
104
|
+
*
|
|
105
|
+
* @param url - The URL to request
|
|
106
|
+
* @param data - The data to send
|
|
107
|
+
* @param options - The request options
|
|
108
|
+
* @returns The response data
|
|
109
|
+
*/
|
|
110
|
+
async patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
111
|
+
return await this.request<T, R, D>(url, data, { ...options, method: 'PATCH' })
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Make a DELETE request
|
|
116
|
+
*
|
|
117
|
+
* @param url - The URL to request
|
|
118
|
+
* @param options - The request options
|
|
119
|
+
* @returns The response data
|
|
120
|
+
*/
|
|
121
|
+
async delete<T = any, R = AxiosResponse<T>, D = any>(url: string, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
122
|
+
return await this.request<T, R, D>(url, undefined, { ...options, method: 'DELETE' })
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get the access token
|
|
127
|
+
*
|
|
128
|
+
* @returns The access token
|
|
129
|
+
*/
|
|
130
|
+
private async getAccessToken (): Promise<string> {
|
|
131
|
+
if (isNotEmpty(this.tokenService.getAccessToken()) && !this.tokenService.isAuthenticated()) {
|
|
132
|
+
await this.tokenService.refresh()
|
|
133
|
+
}
|
|
134
|
+
return this.tokenService.getAccessToken() ?? ''
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Stone } from '@stone-js/core'
|
|
2
|
+
import { AxiosClient } from './AxiosClient'
|
|
3
|
+
import { Comment, CommentInput } from '../models/Comment'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Comment Client Options
|
|
7
|
+
*/
|
|
8
|
+
export interface CommentClientOptions {
|
|
9
|
+
httpClient: AxiosClient
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Comment Client
|
|
14
|
+
*/
|
|
15
|
+
@Stone({ alias: 'commentClient' })
|
|
16
|
+
export class CommentClient {
|
|
17
|
+
private readonly path: string
|
|
18
|
+
private readonly client: AxiosClient
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Create a new Comment Client
|
|
22
|
+
*
|
|
23
|
+
* @param options - The options to create the Comment Client.
|
|
24
|
+
*/
|
|
25
|
+
constructor ({ httpClient }: CommentClientOptions) {
|
|
26
|
+
this.path = '/comments'
|
|
27
|
+
this.client = httpClient
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* List comments
|
|
32
|
+
*
|
|
33
|
+
* @param postId - The id of the Post to list Comments
|
|
34
|
+
* @param limit - The limit of Comments to list
|
|
35
|
+
* @returns The list of Comments
|
|
36
|
+
*/
|
|
37
|
+
async list (postId: number, limit: number = 10): Promise<Comment[]> {
|
|
38
|
+
const query = new URLSearchParams({ limit: limit.toString() })
|
|
39
|
+
return await this.client.get<Comment[]>(`${this.path}/posts/${postId}?${String(query)}`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create a comment
|
|
44
|
+
*
|
|
45
|
+
* @param postId - The id of the Post to create the Comment for
|
|
46
|
+
* @param comment - The Comment to create
|
|
47
|
+
* @returns The created Comment
|
|
48
|
+
*/
|
|
49
|
+
async create (postId: number, comment: CommentInput): Promise<Comment> {
|
|
50
|
+
return await this.client.post(`${this.path}/posts/${postId}`, { ...comment, id: undefined })
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Delete a comment
|
|
55
|
+
*
|
|
56
|
+
* @param id - The id of the Comment to delete
|
|
57
|
+
*/
|
|
58
|
+
async delete (id: number): Promise<unknown> {
|
|
59
|
+
return await this.client.delete(`${this.path}/${id}`)
|
|
60
|
+
}
|
|
61
|
+
}
|