@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,79 @@
|
|
|
1
|
+
import { routerBlueprint } from '@stone-js/router'
|
|
2
|
+
import { browserAdapterBlueprint } from '@stone-js/browser-adapter'
|
|
3
|
+
import { nodeHttpAdapterBlueprint } from '@stone-js/node-http-adapter'
|
|
4
|
+
import { nodeConsoleAdapterBlueprint } from '@stone-js/node-cli-adapter'
|
|
5
|
+
import { defineStoneReactApp, ReactLifecycleHookType } from '@stone-js/use-react'
|
|
6
|
+
import { defineHookListeners, IBlueprint, IContainer, ILogger, LogLevel, Promiseable } from '@stone-js/core'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Start the application
|
|
10
|
+
* Run at each cold start.
|
|
11
|
+
* At this point, you only have access to the blueprint.
|
|
12
|
+
* Because the container is not yet created.
|
|
13
|
+
*/
|
|
14
|
+
export function onStart ({ blueprint }: { blueprint: IBlueprint }): void {
|
|
15
|
+
const AppName = blueprint.get<string>('stone.name')
|
|
16
|
+
console.log(`${String(AppName)}'s Application is starting`)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Prepare the application
|
|
21
|
+
* Run at each warm start in server context.
|
|
22
|
+
* And at each cold start in browser context.
|
|
23
|
+
*/
|
|
24
|
+
export function onInit ({ logger }: { logger: ILogger }): Promiseable<void> {
|
|
25
|
+
logger.info('Application is initializing')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Before handle the incoming event
|
|
30
|
+
*/
|
|
31
|
+
export function onHandlingEvent ({ logger }: { logger: ILogger }): Promiseable<void> {
|
|
32
|
+
logger.info('Before handle incoming event')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Before prepare the react page
|
|
37
|
+
*/
|
|
38
|
+
export function onPreparingPage ({ container }: { container: IContainer }): Promiseable<void> {
|
|
39
|
+
container.make<ILogger>('logger').info('Before prepare the react page')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* After the incoming event has been processed
|
|
44
|
+
*/
|
|
45
|
+
export function onProcessingKernelMiddleware ({ pipe }: { pipe: any }): Promiseable<void> {
|
|
46
|
+
console.info('Kernel middleware is processing', pipe.module.name)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* After the platform event has been sent to the user
|
|
51
|
+
*/
|
|
52
|
+
export function onTerminate ({ logger }: { logger: ILogger }): Promiseable<void> {
|
|
53
|
+
logger.info('The event has been sent to the user')
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Stone-React Application
|
|
58
|
+
*/
|
|
59
|
+
export const MyStoneReactApp = defineStoneReactApp(
|
|
60
|
+
{ name: 'My Stone', logger: { level: LogLevel.DEBUG } },
|
|
61
|
+
[
|
|
62
|
+
routerBlueprint,
|
|
63
|
+
browserAdapterBlueprint,
|
|
64
|
+
nodeHttpAdapterBlueprint,
|
|
65
|
+
nodeConsoleAdapterBlueprint
|
|
66
|
+
]
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Hooks Listeners Blueprint
|
|
71
|
+
*/
|
|
72
|
+
export const HooksListenersBlueprint = defineHookListeners<ReactLifecycleHookType>({
|
|
73
|
+
onInit: [onInit],
|
|
74
|
+
onStart: [onStart],
|
|
75
|
+
onTerminate: [onTerminate],
|
|
76
|
+
onPreparingPage: [onPreparingPage],
|
|
77
|
+
onHandlingEvent: [onHandlingEvent],
|
|
78
|
+
onProcessingKernelMiddleware: [onProcessingKernelMiddleware]
|
|
79
|
+
})
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { isEmpty, isNotEmpty } from '@stone-js/core'
|
|
2
|
+
import { IAxiosClient } from './contracts/IAxiosClient'
|
|
3
|
+
import { UnauthorizedError } from '../errors/UnauthorizedError'
|
|
4
|
+
import { isServer, ReactIncomingEvent } from '@stone-js/use-react'
|
|
5
|
+
import { ITokenService } from '../services/contracts/ITokenService'
|
|
6
|
+
import { AxiosError, Axios, AxiosRequestConfig, AxiosResponse } from 'axios'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Axios Client Options
|
|
10
|
+
*/
|
|
11
|
+
export interface AxiosClientOptions {
|
|
12
|
+
axios: Axios
|
|
13
|
+
event: ReactIncomingEvent
|
|
14
|
+
tokenService: ITokenService
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Axios Client
|
|
19
|
+
*/
|
|
20
|
+
export const AxiosClient = ({ axios, event, tokenService }: AxiosClientOptions): IAxiosClient => {
|
|
21
|
+
return {
|
|
22
|
+
/**
|
|
23
|
+
* Make a request
|
|
24
|
+
*
|
|
25
|
+
* @param url - The URL to request
|
|
26
|
+
* @param data - The data to send
|
|
27
|
+
* @param options - The request options
|
|
28
|
+
* @returns The response data
|
|
29
|
+
* @throws NotAuthenticateError
|
|
30
|
+
* @throws AxiosError
|
|
31
|
+
*/
|
|
32
|
+
async request<T = any, R = AxiosResponse<T>, D = any>(url: string, payload?: D, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
33
|
+
try {
|
|
34
|
+
const token = await this.getAccessToken()
|
|
35
|
+
const headers: Record<string, any> = options?.headers ?? {}
|
|
36
|
+
// const validateStatus = (status: number) => status >= 200 && status < 500
|
|
37
|
+
|
|
38
|
+
if (isServer()) { headers['User-Agent'] = event.userAgent }
|
|
39
|
+
|
|
40
|
+
headers.Accept ??= 'application/json'
|
|
41
|
+
headers['Content-Type'] ??= 'application/json'
|
|
42
|
+
headers.Authorization = isEmpty(token) ? '' : `Bearer ${token}`
|
|
43
|
+
|
|
44
|
+
return (await axios.request({ ...options, url, data: payload, headers /* validateStatus */ })).data
|
|
45
|
+
} catch (error: any) {
|
|
46
|
+
if (isNotEmpty<AxiosError<R, D>>(error) && error.status === 401) {
|
|
47
|
+
throw new UnauthorizedError(error.message, { cause: error })
|
|
48
|
+
} else {
|
|
49
|
+
throw error
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Make a GET request
|
|
56
|
+
*
|
|
57
|
+
* @param url - The URL to request
|
|
58
|
+
* @param options - The request options
|
|
59
|
+
* @returns The response data
|
|
60
|
+
*/
|
|
61
|
+
async get<T = any, R = AxiosResponse<T>, D = any>(url: string, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
62
|
+
return await this.request<T, R, D>(url, undefined, { ...options, method: 'GET' })
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Make a POST request
|
|
67
|
+
*
|
|
68
|
+
* @param url - The URL to request
|
|
69
|
+
* @param data - The data to send
|
|
70
|
+
* @param options - The request options
|
|
71
|
+
* @returns The response data
|
|
72
|
+
*/
|
|
73
|
+
async post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
74
|
+
return await this.request<T, R, D>(url, data, { ...options, method: 'POST' })
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Make a PUT request
|
|
79
|
+
*
|
|
80
|
+
* @param url - The URL to request
|
|
81
|
+
* @param data - The data to send
|
|
82
|
+
* @param options - The request options
|
|
83
|
+
* @returns The response data
|
|
84
|
+
*/
|
|
85
|
+
async put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
86
|
+
return await this.request<T, R, D>(url, data, { ...options, method: 'PUT' })
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Make a PATCH request
|
|
91
|
+
*
|
|
92
|
+
* @param url - The URL to request
|
|
93
|
+
* @param data - The data to send
|
|
94
|
+
* @param options - The request options
|
|
95
|
+
* @returns The response data
|
|
96
|
+
*/
|
|
97
|
+
async patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
98
|
+
return await this.request<T, R, D>(url, data, { ...options, method: 'PATCH' })
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Make a DELETE request
|
|
103
|
+
*
|
|
104
|
+
* @param url - The URL to request
|
|
105
|
+
* @param options - The request options
|
|
106
|
+
* @returns The response data
|
|
107
|
+
*/
|
|
108
|
+
async delete<T = any, R = AxiosResponse<T>, D = any>(url: string, options?: AxiosRequestConfig<D>): Promise<T> {
|
|
109
|
+
return await this.request<T, R, D>(url, undefined, { ...options, method: 'DELETE' })
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Get the access token
|
|
114
|
+
*
|
|
115
|
+
* @returns The access token
|
|
116
|
+
*/
|
|
117
|
+
async getAccessToken (): Promise<string> {
|
|
118
|
+
if (isNotEmpty(tokenService.getAccessToken()) && !tokenService.isAuthenticated()) {
|
|
119
|
+
await tokenService.refresh()
|
|
120
|
+
}
|
|
121
|
+
return tokenService.getAccessToken() ?? ''
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineStone } from '@stone-js/core'
|
|
2
|
+
import { IAxiosClient } from './contracts/IAxiosClient'
|
|
3
|
+
import { Comment, CommentInput } from '../models/Comment'
|
|
4
|
+
import { ICommentClient } from './contracts/ICommentClient'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Comment Client Options
|
|
8
|
+
*/
|
|
9
|
+
export interface CommentClientOptions {
|
|
10
|
+
httpClient: IAxiosClient
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Comment Client
|
|
15
|
+
*/
|
|
16
|
+
export const CommentClient = ({ httpClient: client }: CommentClientOptions): ICommentClient => {
|
|
17
|
+
const path = '/comments'
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
/**
|
|
21
|
+
* List comments
|
|
22
|
+
*
|
|
23
|
+
* @param postId - The id of the Post to list Comments
|
|
24
|
+
* @param limit - The limit of Comments to list
|
|
25
|
+
* @returns The list of Comments
|
|
26
|
+
*/
|
|
27
|
+
async list (postId: number, limit: number = 10): Promise<Comment[]> {
|
|
28
|
+
const query = new URLSearchParams({ limit: limit.toString() })
|
|
29
|
+
return await client.get<Comment[]>(`${String(path)}/posts/${String(postId)}?${String(query)}`)
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Create a comment
|
|
34
|
+
*
|
|
35
|
+
* @param postId - The id of the Post to create the Comment for
|
|
36
|
+
* @param comment - The Comment to create
|
|
37
|
+
* @returns The created Comment
|
|
38
|
+
*/
|
|
39
|
+
async create (postId: number, comment: CommentInput) {
|
|
40
|
+
return await client.post(`${path}/posts/${postId}`, { ...comment, id: undefined })
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Delete a comment
|
|
45
|
+
*
|
|
46
|
+
* @param id - The id of the Comment to delete
|
|
47
|
+
*/
|
|
48
|
+
async delete (id: number) {
|
|
49
|
+
return await client.delete(`${path}/${id}`)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Comment Client blueprint.
|
|
56
|
+
*/
|
|
57
|
+
export const CommentClientBlueprint = defineStone(CommentClient, { alias: 'commentClient' })
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { defineStone } from '@stone-js/core'
|
|
2
|
+
import { Post, PostInput } from '../models/Post'
|
|
3
|
+
import { IPostClient } from './contracts/IPostClient'
|
|
4
|
+
import { IAxiosClient } from './contracts/IAxiosClient'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Post Client Options
|
|
8
|
+
*/
|
|
9
|
+
export interface PostClientOptions {
|
|
10
|
+
httpClient: IAxiosClient
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Post Client
|
|
15
|
+
*/
|
|
16
|
+
export const PostClient = ({ httpClient: client }: PostClientOptions): IPostClient => {
|
|
17
|
+
const path = '/posts'
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
/**
|
|
21
|
+
* List posts
|
|
22
|
+
*
|
|
23
|
+
* @param limit - The limit of posts to list
|
|
24
|
+
* @returns The list of posts
|
|
25
|
+
*/
|
|
26
|
+
async list (limit: number = 10): Promise<Post[]> {
|
|
27
|
+
return await client.get<Post[]>(`${path}?limit=${limit}`)
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* List posts by author
|
|
32
|
+
*
|
|
33
|
+
* @param id - The id of the author to list posts
|
|
34
|
+
* @param limit - The limit of posts to list
|
|
35
|
+
* @returns The list of posts
|
|
36
|
+
*/
|
|
37
|
+
async listByAuthor (id: number, limit: number = 10): Promise<Post[]> {
|
|
38
|
+
return await client.get<Post[]>(`${path}/authors/${id}?limit=${limit}`)
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Find an post
|
|
43
|
+
*
|
|
44
|
+
* @param id - The id of the post to find
|
|
45
|
+
* @returns The found post
|
|
46
|
+
*/
|
|
47
|
+
async find (id: number): Promise<Post> {
|
|
48
|
+
return await client.get<Post>(`${path}/${id}`)
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Create an post
|
|
53
|
+
*
|
|
54
|
+
* @param post - The post to create
|
|
55
|
+
* @returns The created post
|
|
56
|
+
*/
|
|
57
|
+
async create (post: PostInput) {
|
|
58
|
+
return await client.post(path, post)
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Update an post
|
|
63
|
+
*
|
|
64
|
+
* @param id - The id of the post to update
|
|
65
|
+
* @param post - The post to update
|
|
66
|
+
* @returns The updated post
|
|
67
|
+
*/
|
|
68
|
+
async update (id: number, post: PostInput) {
|
|
69
|
+
return await client.patch(`${path}/${id}`, post)
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Delete an post
|
|
74
|
+
*
|
|
75
|
+
* @param id - The id of the post to delete
|
|
76
|
+
*/
|
|
77
|
+
async delete (id: number) {
|
|
78
|
+
return await client.delete(`${path}/${id}`)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Post Client blueprint.
|
|
85
|
+
*/
|
|
86
|
+
export const PostClientBlueprint = defineStone(PostClient, { alias: 'postClient' })
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
|
|
2
|
+
import { Axios } from 'axios'
|
|
3
|
+
import { defineStone } from '@stone-js/core'
|
|
4
|
+
import { IAxiosClient } from './contracts/IAxiosClient'
|
|
5
|
+
import { ISecurityClient } from './contracts/ISecurityClient'
|
|
6
|
+
import { UserChangePassword, UserLogin, UserRegister, UserToken } from '../models/User'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Security Client Options
|
|
10
|
+
*/
|
|
11
|
+
export interface SecurityClientOptions {
|
|
12
|
+
axios: Axios
|
|
13
|
+
httpClient: IAxiosClient
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Security Client
|
|
18
|
+
*/
|
|
19
|
+
export const SecurityClient = ({ axios, httpClient: client }: SecurityClientOptions): ISecurityClient => {
|
|
20
|
+
return {
|
|
21
|
+
/**
|
|
22
|
+
* Login a user
|
|
23
|
+
*
|
|
24
|
+
* @param user - The user to login
|
|
25
|
+
*/
|
|
26
|
+
async login (user: UserLogin): Promise<UserToken> {
|
|
27
|
+
return (await axios.post<UserToken>('/login', user)).data
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Logout a user
|
|
32
|
+
*/
|
|
33
|
+
async logout (): Promise<void> {
|
|
34
|
+
await client.post<UserToken>('/logout')
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Register a user
|
|
39
|
+
*
|
|
40
|
+
* @param user - The user to register
|
|
41
|
+
*/
|
|
42
|
+
async register (user: UserRegister): Promise<void> {
|
|
43
|
+
await axios.post('/register', user)
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Change the user password
|
|
48
|
+
*
|
|
49
|
+
* @param password - The password to change
|
|
50
|
+
*/
|
|
51
|
+
async changePassword (password: UserChangePassword): Promise<void> {
|
|
52
|
+
await client.patch('/change-password', password)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Security Client blueprint.
|
|
59
|
+
*/
|
|
60
|
+
export const SecurityClientBlueprint = defineStone(SecurityClient, { alias: 'securityClient' })
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { defineStone } from '@stone-js/core'
|
|
2
|
+
import { User, UserInput } from '../models/User'
|
|
3
|
+
import { IUserClient } from './contracts/IUserClient'
|
|
4
|
+
import { IAxiosClient } from './contracts/IAxiosClient'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* User Client Options
|
|
8
|
+
*/
|
|
9
|
+
export interface UserClientOptions {
|
|
10
|
+
httpClient: IAxiosClient
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* User Client
|
|
15
|
+
*/
|
|
16
|
+
export const UserClient = ({ httpClient: client }: UserClientOptions): IUserClient => {
|
|
17
|
+
const path = '/users'
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
/**
|
|
21
|
+
* List users
|
|
22
|
+
*
|
|
23
|
+
* @param limit - The limit of users to list
|
|
24
|
+
* @returns The list of users
|
|
25
|
+
*/
|
|
26
|
+
async list (limit: number = 10): Promise<User[]> {
|
|
27
|
+
return await client.get<User[]>(`${path}?limit=${limit}`)
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get the current user
|
|
32
|
+
*
|
|
33
|
+
* @returns The current user
|
|
34
|
+
*/
|
|
35
|
+
async currentUser (): Promise<User> {
|
|
36
|
+
return await client.get<User>(`${path}/me`)
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Find a user
|
|
41
|
+
*
|
|
42
|
+
* @param id - The id of the user to find
|
|
43
|
+
* @returns The found user
|
|
44
|
+
*/
|
|
45
|
+
async find (id: number): Promise<User> {
|
|
46
|
+
return await client.get<User>(`${path}/${id}`)
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Create a user
|
|
51
|
+
*
|
|
52
|
+
* @param user - The user to create
|
|
53
|
+
*/
|
|
54
|
+
async create (user: UserInput) {
|
|
55
|
+
return await client.post(path, user)
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Update the current user
|
|
60
|
+
*
|
|
61
|
+
* @param user - The current user
|
|
62
|
+
* @returns The current user
|
|
63
|
+
*/
|
|
64
|
+
async updateCurrent (user: UserInput) {
|
|
65
|
+
return await client.patch(`${path}/me`, user)
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Update a user
|
|
70
|
+
*
|
|
71
|
+
* @param id - The id of the user to update
|
|
72
|
+
* @param user - The user to update
|
|
73
|
+
* @returns The updated user
|
|
74
|
+
*/
|
|
75
|
+
async update (id: number, user: UserInput) {
|
|
76
|
+
return await client.patch(`${path}/${id}`, user)
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Delete a user
|
|
81
|
+
*
|
|
82
|
+
* @param id - The id of the user to delete
|
|
83
|
+
*/
|
|
84
|
+
async delete (id: number) {
|
|
85
|
+
return await client.delete(`${path}/${id}`)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* User client blueprint.
|
|
92
|
+
*/
|
|
93
|
+
export const UserClientBlueprint = defineStone(UserClient, { alias: 'userClient' })
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosRequestConfig } from 'axios'
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Axios Client contract
|
|
7
|
+
*/
|
|
8
|
+
export interface IAxiosClient {
|
|
9
|
+
/**
|
|
10
|
+
* Make a generic HTTP request.
|
|
11
|
+
*
|
|
12
|
+
* @param url - The URL to request.
|
|
13
|
+
* @param payload - Optional request body.
|
|
14
|
+
* @param options - Axios request configuration.
|
|
15
|
+
* @returns The response data.
|
|
16
|
+
* @throws UnauthorizedError
|
|
17
|
+
* @throws AxiosError
|
|
18
|
+
*/
|
|
19
|
+
request: <T = any, R = AxiosResponse<T>, D = any>(
|
|
20
|
+
url: string,
|
|
21
|
+
payload?: D,
|
|
22
|
+
options?: AxiosRequestConfig<D>
|
|
23
|
+
) => Promise<T>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Make a GET request.
|
|
27
|
+
*
|
|
28
|
+
* @param url - The URL to request.
|
|
29
|
+
* @param options - Axios request configuration.
|
|
30
|
+
* @returns The response data.
|
|
31
|
+
*/
|
|
32
|
+
get: <T = any, R = AxiosResponse<T>, D = any>(
|
|
33
|
+
url: string,
|
|
34
|
+
options?: AxiosRequestConfig<D>
|
|
35
|
+
) => Promise<T>
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Make a POST request.
|
|
39
|
+
*
|
|
40
|
+
* @param url - The URL to request.
|
|
41
|
+
* @param data - The data to send.
|
|
42
|
+
* @param options - Axios request configuration.
|
|
43
|
+
* @returns The response data.
|
|
44
|
+
*/
|
|
45
|
+
post: <T = any, R = AxiosResponse<T>, D = any>(
|
|
46
|
+
url: string,
|
|
47
|
+
data?: D,
|
|
48
|
+
options?: AxiosRequestConfig<D>
|
|
49
|
+
) => Promise<T>
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Make a PUT request.
|
|
53
|
+
*
|
|
54
|
+
* @param url - The URL to request.
|
|
55
|
+
* @param data - The data to send.
|
|
56
|
+
* @param options - Axios request configuration.
|
|
57
|
+
* @returns The response data.
|
|
58
|
+
*/
|
|
59
|
+
put: <T = any, R = AxiosResponse<T>, D = any>(
|
|
60
|
+
url: string,
|
|
61
|
+
data?: D,
|
|
62
|
+
options?: AxiosRequestConfig<D>
|
|
63
|
+
) => Promise<T>
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Make a PATCH request.
|
|
67
|
+
*
|
|
68
|
+
* @param url - The URL to request.
|
|
69
|
+
* @param data - The data to send.
|
|
70
|
+
* @param options - Axios request configuration.
|
|
71
|
+
* @returns The response data.
|
|
72
|
+
*/
|
|
73
|
+
patch: <T = any, R = AxiosResponse<T>, D = any>(
|
|
74
|
+
url: string,
|
|
75
|
+
data?: D,
|
|
76
|
+
options?: AxiosRequestConfig<D>
|
|
77
|
+
) => Promise<T>
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Make a DELETE request.
|
|
81
|
+
*
|
|
82
|
+
* @param url - The URL to request.
|
|
83
|
+
* @param options - Axios request configuration.
|
|
84
|
+
* @returns The response data.
|
|
85
|
+
*/
|
|
86
|
+
delete: <T = any, R = AxiosResponse<T>, D = any>(
|
|
87
|
+
url: string,
|
|
88
|
+
options?: AxiosRequestConfig<D>
|
|
89
|
+
) => Promise<T>
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Retrieves the access token.
|
|
93
|
+
*
|
|
94
|
+
* @returns The access token string.
|
|
95
|
+
*/
|
|
96
|
+
getAccessToken: () => Promise<string>
|
|
97
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Comment, CommentInput } from '../../models/Comment'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Comment Client contract
|
|
5
|
+
*/
|
|
6
|
+
export interface ICommentClient {
|
|
7
|
+
/**
|
|
8
|
+
* List comments for a given post.
|
|
9
|
+
*
|
|
10
|
+
* @param postId - The ID of the post to list comments for.
|
|
11
|
+
* @param limit - Optional limit of comments to retrieve (default: 10).
|
|
12
|
+
* @returns The list of comments.
|
|
13
|
+
*/
|
|
14
|
+
list: (postId: number, limit?: number) => Promise<Comment[]>
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Create a new comment for a given post.
|
|
18
|
+
*
|
|
19
|
+
* @param postId - The ID of the post to comment on.
|
|
20
|
+
* @param comment - The comment data.
|
|
21
|
+
* @returns The created comment.
|
|
22
|
+
*/
|
|
23
|
+
create: (postId: number, comment: CommentInput) => Promise<Comment>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Delete a comment by its ID.
|
|
27
|
+
*
|
|
28
|
+
* @param id - The ID of the comment to delete.
|
|
29
|
+
*/
|
|
30
|
+
delete: (id: number) => Promise<void>
|
|
31
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Post, PostInput } from '../../models/Post'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Post Client contract
|
|
5
|
+
*/
|
|
6
|
+
export interface IPostClient {
|
|
7
|
+
/**
|
|
8
|
+
* List posts.
|
|
9
|
+
*
|
|
10
|
+
* @param limit - The limit of posts to list (default: 10).
|
|
11
|
+
* @returns The list of posts.
|
|
12
|
+
*/
|
|
13
|
+
list: (limit?: number) => Promise<Post[]>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* List posts by author.
|
|
17
|
+
*
|
|
18
|
+
* @param id - The author ID.
|
|
19
|
+
* @param limit - The number of posts to retrieve (default: 10).
|
|
20
|
+
* @returns The list of posts.
|
|
21
|
+
*/
|
|
22
|
+
listByAuthor: (id: number, limit?: number) => Promise<Post[]>
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Find a post by ID.
|
|
26
|
+
*
|
|
27
|
+
* @param id - The ID of the post to find.
|
|
28
|
+
* @returns The found post.
|
|
29
|
+
*/
|
|
30
|
+
find: (id: number) => Promise<Post>
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Create a new post.
|
|
34
|
+
*
|
|
35
|
+
* @param post - The post data to create.
|
|
36
|
+
* @returns The created post.
|
|
37
|
+
*/
|
|
38
|
+
create: (post: PostInput) => Promise<Post>
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Update an existing post.
|
|
42
|
+
*
|
|
43
|
+
* @param id - The ID of the post to update.
|
|
44
|
+
* @param post - The updated post data.
|
|
45
|
+
* @returns The updated post.
|
|
46
|
+
*/
|
|
47
|
+
update: (id: number, post: PostInput) => Promise<Post>
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Delete a post.
|
|
51
|
+
*
|
|
52
|
+
* @param id - The ID of the post to delete.
|
|
53
|
+
*/
|
|
54
|
+
delete: (id: number) => Promise<void>
|
|
55
|
+
}
|