@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,38 @@
|
|
|
1
|
+
import { UserEvent } from '../events/UserEvent'
|
|
2
|
+
import { EventEmitter, IEventSubscriber, ILogger, Subscriber } from '@stone-js/core'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* User Event Subscriber Options
|
|
6
|
+
*/
|
|
7
|
+
export interface UserEventSubscriberOptions {
|
|
8
|
+
logger: ILogger
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* User event subscriber
|
|
13
|
+
*/
|
|
14
|
+
@Subscriber()
|
|
15
|
+
export class UserEventSubscriber implements IEventSubscriber {
|
|
16
|
+
private readonly logger: ILogger
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of UserEventSubscriber
|
|
20
|
+
*
|
|
21
|
+
* @param logger
|
|
22
|
+
*/
|
|
23
|
+
constructor ({ logger }: UserEventSubscriberOptions) {
|
|
24
|
+
this.logger = logger
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Subscribe to user events
|
|
29
|
+
*
|
|
30
|
+
* @param eventEmitter - The event emitter
|
|
31
|
+
*/
|
|
32
|
+
subscribe (eventEmitter: EventEmitter): void {
|
|
33
|
+
eventEmitter
|
|
34
|
+
.on(UserEvent.USER_CREATED, (event: UserEvent) => {
|
|
35
|
+
this.logger.info('User event subscriber', event.user)
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from 'drizzle-kit';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Drizzle Configuration
|
|
5
|
+
*/
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
out: './drizzle',
|
|
8
|
+
dialect: 'sqlite',
|
|
9
|
+
schema: './app/database/schema.ts',
|
|
10
|
+
dbCredentials: {
|
|
11
|
+
url: process.env.DB_FILE_NAME ?? 'file:local.db'
|
|
12
|
+
},
|
|
13
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "full-service-declarative",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Stone.js's full starter to create web app using declarative API.",
|
|
6
|
+
"author": "Mr. Stone <evensstone@gmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20.0.0"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "stone dev",
|
|
14
|
+
"build": "stone build",
|
|
15
|
+
"preview": "stone preview dist/server.mjs",
|
|
16
|
+
"typings": "stone typings",
|
|
17
|
+
"db:setup": "drizzle-kit push",
|
|
18
|
+
"db:generate": "drizzle-kit generate",
|
|
19
|
+
"db:migrate": "drizzle-kit migrate",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:cvg": "npm run test -- --coverage"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@libsql/client": "^0.14.0",
|
|
25
|
+
"@stone-js/core": "^0.8.3",
|
|
26
|
+
"@stone-js/env": "^0.8.3",
|
|
27
|
+
"@stone-js/filesystem": "^0.8.3",
|
|
28
|
+
"@stone-js/http-core": "^0.8.3",
|
|
29
|
+
"@stone-js/node-cli-adapter": "^0.8.3",
|
|
30
|
+
"@stone-js/node-http-adapter": "^0.8.3",
|
|
31
|
+
"@stone-js/pipeline": "^0.8.3",
|
|
32
|
+
"@stone-js/router": "^0.8.3",
|
|
33
|
+
"bcryptjs": "^3.0.2",
|
|
34
|
+
"drizzle-orm": "^0.44.2",
|
|
35
|
+
"jsonwebtoken": "^9.0.2"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
39
|
+
"@babel/preset-env": "^7.26.9",
|
|
40
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
41
|
+
"@stone-js/cli": "^0.8.3",
|
|
42
|
+
"@types/jsonwebtoken": "^9.0.8",
|
|
43
|
+
"@types/node": "^24.0.3",
|
|
44
|
+
"@vitest/coverage-v8": "^3.0.9",
|
|
45
|
+
"drizzle-kit": "^0.31.1",
|
|
46
|
+
"vitest": "^3.0.9"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"app",
|
|
4
|
+
"tests",
|
|
5
|
+
".stone",
|
|
6
|
+
"vitest.config.ts"
|
|
7
|
+
],
|
|
8
|
+
"exclude": [
|
|
9
|
+
"node_modules"
|
|
10
|
+
],
|
|
11
|
+
"compilerOptions": {
|
|
12
|
+
"strict": true,
|
|
13
|
+
"allowJs": false,
|
|
14
|
+
"target": "esnext",
|
|
15
|
+
"module": "ESNext",
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"esModuleInterop": true,
|
|
19
|
+
"isolatedModules": true,
|
|
20
|
+
"resolveJsonModule": true,
|
|
21
|
+
"moduleResolution": "bundler",
|
|
22
|
+
"experimentalDecorators": true,
|
|
23
|
+
"types": ["node", "vitest/globals"],
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config.js'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
globals: true,
|
|
6
|
+
environment: 'node',
|
|
7
|
+
include: ['./tests/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
|
|
8
|
+
coverage: {
|
|
9
|
+
provider: 'v8',
|
|
10
|
+
include: ['app/**/*.ts'],
|
|
11
|
+
reporter: ['text', 'html'],
|
|
12
|
+
reportsDirectory: './coverage',
|
|
13
|
+
thresholds: {
|
|
14
|
+
100: true
|
|
15
|
+
},
|
|
16
|
+
watermarks: {
|
|
17
|
+
statements: [60, 80],
|
|
18
|
+
functions: [60, 80],
|
|
19
|
+
branches: [60, 80],
|
|
20
|
+
lines: [60, 80]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -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,65 @@
|
|
|
1
|
+
# Stone.js - Full starter
|
|
2
|
+
|
|
3
|
+
Stone.js's full starter to create web app using imperative 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
|
+
```
|
|
40
|
+
|
|
41
|
+
## Database setup
|
|
42
|
+
|
|
43
|
+
We use Drizzle ORM with SQLite for this starter. To set up the database, run:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npm run db:setup
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This will create the necessary tables.
|
|
50
|
+
|
|
51
|
+
### Database migrations
|
|
52
|
+
|
|
53
|
+
To generate a new migration, use:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
npm run db:generate
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
To apply database migrations, use:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
npm run db:migrate
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
For more information on database management, refer to the [Drizzle ORM documentation](https://orm.drizzle.team/docs/).
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IncomingHttpEvent,
|
|
3
|
+
OutgoingHttpResponse,
|
|
4
|
+
IncomingHttpEventOptions
|
|
5
|
+
} from '@stone-js/http-core'
|
|
6
|
+
import {
|
|
7
|
+
isEmpty,
|
|
8
|
+
LogLevel,
|
|
9
|
+
IContainer,
|
|
10
|
+
IBlueprint,
|
|
11
|
+
defineConfig,
|
|
12
|
+
AdapterConfig,
|
|
13
|
+
defineStoneApp,
|
|
14
|
+
AdapterContext,
|
|
15
|
+
BlueprintContext,
|
|
16
|
+
defineHookListener,
|
|
17
|
+
AdapterEventBuilderType,
|
|
18
|
+
AdapterHookListenerContext
|
|
19
|
+
} from '@stone-js/core'
|
|
20
|
+
import { getString } from '@stone-js/env'
|
|
21
|
+
import { routerBlueprint } from '@stone-js/router'
|
|
22
|
+
import { PipelineHookContext } from '@stone-js/pipeline'
|
|
23
|
+
import { nodeConsoleAdapterBlueprint } from '@stone-js/node-cli-adapter'
|
|
24
|
+
import { MetaBodyEventMiddleware, MetaFilesEventMiddleware, NODE_HTTP_PLATFORM, nodeHttpAdapterBlueprint } from '@stone-js/node-http-adapter'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Run before the blueprint is prepared
|
|
28
|
+
*
|
|
29
|
+
* @param context - The blueprint context
|
|
30
|
+
*/
|
|
31
|
+
export const onPreparingBlueprint = defineHookListener(({ blueprint, modules }: BlueprintContext): void => {
|
|
32
|
+
blueprint.set('tmpBlueprintTimer', Date.now())
|
|
33
|
+
console.log(`Preparing blueprint by introspecting ${modules.length} modules...`)
|
|
34
|
+
}, { name: 'onPreparingBlueprint' })
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Run before each blueprint middleware is processed
|
|
38
|
+
*
|
|
39
|
+
* @param context - The pipeline context
|
|
40
|
+
*/
|
|
41
|
+
export const onProcessingBlueprintMiddleware = defineHookListener(({ passable, pipe }: PipelineHookContext<BlueprintContext, IBlueprint>): void => {
|
|
42
|
+
passable.blueprint.set(`tmpBlueprintMiddleware.${String(pipe.module.name)}`, Date.now())
|
|
43
|
+
}, { name: 'onProcessingBlueprintMiddleware' })
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Run after each blueprint middleware is processed
|
|
47
|
+
*
|
|
48
|
+
* @param context - The pipeline context
|
|
49
|
+
*/
|
|
50
|
+
export const onBlueprintMiddlewareProcessed = defineHookListener(({ passable, pipe }: PipelineHookContext<BlueprintContext, IBlueprint>): void => {
|
|
51
|
+
const name = `tmpBlueprintMiddleware.${String(pipe.module.name)}`
|
|
52
|
+
const start = passable.blueprint.get(name, 0)
|
|
53
|
+
const Type = pipe.isClass !== undefined ? 'Class' : pipe.isFactory !== undefined ? 'Factory' : pipe.isAlias !== undefined ? 'Alias' : 'Callable'
|
|
54
|
+
const value = {
|
|
55
|
+
Middleware: pipe.module.name,
|
|
56
|
+
Type,
|
|
57
|
+
Priority: pipe.priority,
|
|
58
|
+
'Execution Time': `${Date.now() - start}ms`
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
passable.blueprint.set(name, value)
|
|
62
|
+
}, { name: 'onBlueprintMiddlewareProcessed' })
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Run after the blueprint is prepared
|
|
66
|
+
*
|
|
67
|
+
* @param context - The blueprint context
|
|
68
|
+
*/
|
|
69
|
+
export const onBlueprintPrepared = defineHookListener(({ blueprint }: BlueprintContext): void => {
|
|
70
|
+
const timer = Date.now() - blueprint.get('tmpBlueprintTimer', 0)
|
|
71
|
+
const middleware = Object.values(blueprint.get('tmpBlueprintMiddleware', {}))
|
|
72
|
+
const message = `Blueprint prepared in ${timer}ms, with ${middleware.length} middleware`
|
|
73
|
+
|
|
74
|
+
console.table(middleware)
|
|
75
|
+
console.log(message)
|
|
76
|
+
}, { name: 'onBlueprintPrepared' })
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Run before the application starts
|
|
80
|
+
*
|
|
81
|
+
* @param context - The adapter context
|
|
82
|
+
*/
|
|
83
|
+
export const onStart = defineHookListener(({ blueprint, context }: AdapterHookListenerContext): void => {
|
|
84
|
+
console.log('Starting application...')
|
|
85
|
+
console.log('Context isEmpty?', isEmpty(context))
|
|
86
|
+
console.log('Blueprint keys:', Object.keys(blueprint.all()).length)
|
|
87
|
+
}, { name: 'onStart' })
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Run before each adapter middleware is processed
|
|
91
|
+
*
|
|
92
|
+
* @param context - The pipeline context
|
|
93
|
+
*/
|
|
94
|
+
export const onProcessingAdapterMiddleware = defineHookListener(({ passable, pipe, pipes }: PipelineHookContext<
|
|
95
|
+
AdapterContext<unknown, unknown, unknown, IncomingHttpEvent, IncomingHttpEventOptions, OutgoingHttpResponse>,
|
|
96
|
+
AdapterEventBuilderType<any>
|
|
97
|
+
>): void => {
|
|
98
|
+
console.log('Processing adapter middleware...')
|
|
99
|
+
console.log('Middleware count:', pipes.length)
|
|
100
|
+
console.log('Middleware name:', pipe.name)
|
|
101
|
+
console.log('IncomingEvent isEmpty?', isEmpty(passable.incomingEvent))
|
|
102
|
+
}, { name: 'onProcessingAdapterMiddleware' })
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Run after each adapter middleware is processed
|
|
106
|
+
*
|
|
107
|
+
* @param context - The pipeline context
|
|
108
|
+
*/
|
|
109
|
+
export const onAdapterMiddlewareProcessed = defineHookListener(({ passable, pipe, pipes }: PipelineHookContext<
|
|
110
|
+
AdapterContext<unknown, unknown, unknown, IncomingHttpEvent, IncomingHttpEventOptions, OutgoingHttpResponse>,
|
|
111
|
+
AdapterEventBuilderType<any>
|
|
112
|
+
>): void => {
|
|
113
|
+
console.log('Adapter middleware processed...')
|
|
114
|
+
console.log('Middleware count:', pipes.length)
|
|
115
|
+
console.log('Middleware name:', pipe.name)
|
|
116
|
+
console.log('IncomingEvent isEmpty?', isEmpty(passable.incomingEvent))
|
|
117
|
+
}, { name: 'onAdapterMiddlewareProcessed' })
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Run before building each incoming event
|
|
121
|
+
*
|
|
122
|
+
* @param context - The adapter context
|
|
123
|
+
*/
|
|
124
|
+
export const onBuildingIncomingEvent = defineHookListener(({ context }: AdapterHookListenerContext<
|
|
125
|
+
AdapterContext<unknown, unknown, unknown, IncomingHttpEvent, IncomingHttpEventOptions, OutgoingHttpResponse>
|
|
126
|
+
>): void => {
|
|
127
|
+
console.log('Building incoming event...')
|
|
128
|
+
console.log('IncomingEvent isEmpty?', isEmpty(context?.incomingEvent))
|
|
129
|
+
}, { name: 'onBuildingIncomingEvent' })
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Run before handling each adapter error
|
|
133
|
+
*
|
|
134
|
+
* @param context - The adapter context
|
|
135
|
+
*/
|
|
136
|
+
export const onHandlingAdapterError = defineHookListener(({ error }: AdapterHookListenerContext<
|
|
137
|
+
AdapterContext<unknown, unknown, unknown, IncomingHttpEvent, IncomingHttpEventOptions, OutgoingHttpResponse>
|
|
138
|
+
>): void => {
|
|
139
|
+
console.error('Handling adapter error...')
|
|
140
|
+
console.error('Error:', error)
|
|
141
|
+
}, { name: 'onHandlingAdapterError' })
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Run before building each outgoing response
|
|
145
|
+
*
|
|
146
|
+
* @param context - The adapter context
|
|
147
|
+
*/
|
|
148
|
+
export const onBuildingRawResponse = defineHookListener(({ context }: AdapterHookListenerContext<
|
|
149
|
+
AdapterContext<unknown, unknown, unknown, IncomingHttpEvent, IncomingHttpEventOptions, OutgoingHttpResponse>
|
|
150
|
+
>): void => {
|
|
151
|
+
console.log('Building raw response...')
|
|
152
|
+
console.log('IncomingEvent isEmpty?', isEmpty(context?.incomingEvent))
|
|
153
|
+
console.log('OutgoingResponse isEmpty?', isEmpty(context?.outgoingResponse))
|
|
154
|
+
}, { name: 'onBuildingRawResponse' })
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Run just before the application stops
|
|
158
|
+
*
|
|
159
|
+
* @param context - The adapter context
|
|
160
|
+
*/
|
|
161
|
+
export const onStop = defineHookListener(({ blueprint, context }: AdapterHookListenerContext): void => {
|
|
162
|
+
console.log('Stopping application...')
|
|
163
|
+
console.log('Context isEmpty?', isEmpty(context))
|
|
164
|
+
console.log('Blueprint keys:', Object.keys(blueprint.all()).length)
|
|
165
|
+
}, { name: 'onStop' })
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Run after the application is initialized
|
|
169
|
+
* The container is available at this point.
|
|
170
|
+
* All services are registered and ready to be used.
|
|
171
|
+
*
|
|
172
|
+
* @param container - The container
|
|
173
|
+
*/
|
|
174
|
+
export const onInit = defineHookListener((container: IContainer): void => {
|
|
175
|
+
console.log('Initializing application...')
|
|
176
|
+
console.log('Container services count:', container.getBindings().size)
|
|
177
|
+
}, { name: 'onInit' })
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Run before handling each event
|
|
181
|
+
*
|
|
182
|
+
* @param container - The container
|
|
183
|
+
*/
|
|
184
|
+
export const onHandlingEvent = defineHookListener((container: IContainer): void => {
|
|
185
|
+
try {
|
|
186
|
+
console.log('Handling event...')
|
|
187
|
+
container.make('event')
|
|
188
|
+
} catch (error: any) {
|
|
189
|
+
console.log('The incoming event is not yet bound at this stage', error.message)
|
|
190
|
+
}
|
|
191
|
+
}, { name: 'onHandlingEvent' })
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Run before processing each kernel middleware
|
|
195
|
+
*
|
|
196
|
+
* @param context - The pipeline context
|
|
197
|
+
*/
|
|
198
|
+
export const onProcessingKernelMiddleware = defineHookListener((
|
|
199
|
+
{ passable, pipe, pipes }: PipelineHookContext<IncomingHttpEvent, OutgoingHttpResponse>
|
|
200
|
+
): void => {
|
|
201
|
+
console.log('Processing kernel middleware...')
|
|
202
|
+
console.log('Middleware count:', pipes.length)
|
|
203
|
+
console.log('Middleware name:', pipe.name)
|
|
204
|
+
console.log('Incoming Source name', passable.source.platform)
|
|
205
|
+
}, { name: 'onProcessingKernelMiddleware' })
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Run after processing each kernel middleware
|
|
209
|
+
*
|
|
210
|
+
* @param context - The pipeline context
|
|
211
|
+
*/
|
|
212
|
+
export const onKernelMiddlewareProcessed = defineHookListener((
|
|
213
|
+
{ passable, pipe, pipes }: PipelineHookContext<IncomingHttpEvent, OutgoingHttpResponse>
|
|
214
|
+
): void => {
|
|
215
|
+
console.log('Kernel middleware processed...')
|
|
216
|
+
console.log('Middleware count:', pipes.length)
|
|
217
|
+
console.log('Middleware name:', pipe.name)
|
|
218
|
+
console.log('Incoming Source name', passable.source.platform)
|
|
219
|
+
}, { name: 'onTerminate' })
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Run before executing each event handler
|
|
223
|
+
*
|
|
224
|
+
* @param container - The container
|
|
225
|
+
*/
|
|
226
|
+
export const onExecutingEventHandler = defineHookListener(({ event }: { event: IncomingHttpEvent }): void => {
|
|
227
|
+
console.log('Executing event handler...')
|
|
228
|
+
console.log('The incoming event is yet bound at this stage', event.source.platform)
|
|
229
|
+
}, { name: 'onExecutingEventHandler' })
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Run before handling each error
|
|
233
|
+
*
|
|
234
|
+
* @param container - The container
|
|
235
|
+
*/
|
|
236
|
+
export const onExecutingErrorHandler = defineHookListener(({ error }: { error: any }): void => {
|
|
237
|
+
console.log('Executing error handler...')
|
|
238
|
+
console.log('Error', error)
|
|
239
|
+
}, { name: 'onExecutingErrorHandler' })
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Run before preparing each response
|
|
243
|
+
*
|
|
244
|
+
* @param container - The container
|
|
245
|
+
*/
|
|
246
|
+
export const onPreparingResponse = defineHookListener(({ response }: { response: OutgoingHttpResponse }): void => {
|
|
247
|
+
console.log('Preparing response...')
|
|
248
|
+
console.log('Response headers', response.headers)
|
|
249
|
+
}, { name: 'onPreparingResponse' })
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Run after preparing each response
|
|
253
|
+
*
|
|
254
|
+
* @param container - The container
|
|
255
|
+
*/
|
|
256
|
+
export const onResponsePrepared = defineHookListener(({ response }: { response: OutgoingHttpResponse }): void => {
|
|
257
|
+
console.log('Response prepared...')
|
|
258
|
+
console.log('Response headers', response.headers)
|
|
259
|
+
}, { name: 'onResponsePrepared' })
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Run after handling each event
|
|
263
|
+
*
|
|
264
|
+
* @param context - The pipeline context
|
|
265
|
+
*/
|
|
266
|
+
export const onEventHandled = defineHookListener((
|
|
267
|
+
{ event, response }: { event: IncomingHttpEvent, response: OutgoingHttpResponse }
|
|
268
|
+
): void => {
|
|
269
|
+
console.log('Event handled...')
|
|
270
|
+
console.log('Event headers', event.headers)
|
|
271
|
+
console.log('Response headers', response.headers)
|
|
272
|
+
}, { name: 'onEventHandled' })
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Run after executing each event handler
|
|
276
|
+
*
|
|
277
|
+
* @param container - The container
|
|
278
|
+
*/
|
|
279
|
+
export const onTerminate = defineHookListener((container: IContainer): void => {
|
|
280
|
+
console.log('Terminating event handling...')
|
|
281
|
+
console.log('Is IncomingEvent exist', container.bound('event'))
|
|
282
|
+
console.log('Is OutgoingResponse exist', container.bound('response'))
|
|
283
|
+
}, { name: 'onTerminate' })
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Define Stone Application.
|
|
287
|
+
*/
|
|
288
|
+
export const Application = defineStoneApp(
|
|
289
|
+
{ name: 'MyApp', logger: { level: LogLevel.INFO } },
|
|
290
|
+
[
|
|
291
|
+
routerBlueprint,
|
|
292
|
+
nodeHttpAdapterBlueprint,
|
|
293
|
+
nodeConsoleAdapterBlueprint
|
|
294
|
+
]
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Application configuration.
|
|
299
|
+
*/
|
|
300
|
+
export const AppConfig = defineConfig({
|
|
301
|
+
configure (blueprint: IBlueprint) {
|
|
302
|
+
blueprint
|
|
303
|
+
.get<AdapterConfig[]>('stone.adapters', [])
|
|
304
|
+
.forEach((adapter: AdapterConfig) => {
|
|
305
|
+
if (adapter.platform === NODE_HTTP_PLATFORM) {
|
|
306
|
+
adapter.default = true
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
},
|
|
310
|
+
afterConfigure (blueprint: IBlueprint) {
|
|
311
|
+
if (blueprint.is('stone.adapter.platform', NODE_HTTP_PLATFORM)) {
|
|
312
|
+
blueprint
|
|
313
|
+
.set('stone.adapter.url', getString('BASE_URL', 'http://localhost:8080'))
|
|
314
|
+
.add('stone.adapter.middleware', [MetaBodyEventMiddleware, MetaFilesEventMiddleware])
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
})
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ILogger, IncomingEvent, isEmpty } from '@stone-js/core'
|
|
2
|
+
import { IUserService } from '../services/contracts/IUserService'
|
|
3
|
+
import { ISessionService } from '../services/contracts/ISessionService'
|
|
4
|
+
import { CommandBuilder, defineCommand, FunctionalCommandHandler } from '@stone-js/node-cli-adapter'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ListSessionsCommandOptions
|
|
8
|
+
*/
|
|
9
|
+
export interface ListSessionsCommandOptions {
|
|
10
|
+
logger: ILogger
|
|
11
|
+
userService: IUserService
|
|
12
|
+
sessionService: ISessionService
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Factory List sessions command
|
|
17
|
+
*/
|
|
18
|
+
export function factoryListSessionsCommand ({ logger, sessionService, userService }: ListSessionsCommandOptions): FunctionalCommandHandler<IncomingEvent> {
|
|
19
|
+
return async function (event: IncomingEvent): Promise<void> {
|
|
20
|
+
const email = event.get<number>('email')
|
|
21
|
+
const limit = event.get<number>('limit', 10)
|
|
22
|
+
const user = isEmpty(email) ? undefined : await userService.findByEmail({ email })
|
|
23
|
+
const sessions = isEmpty(user)
|
|
24
|
+
? await sessionService.list(limit)
|
|
25
|
+
: await sessionService.getByUser(user, limit)
|
|
26
|
+
logger.info('List sessions command')
|
|
27
|
+
console.table(sessions)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* List sessions command
|
|
33
|
+
*/
|
|
34
|
+
export const ListSessionsCommand = defineCommand(factoryListSessionsCommand, {
|
|
35
|
+
alias: 'ls',
|
|
36
|
+
isFactory: true,
|
|
37
|
+
name: 'list-sessions',
|
|
38
|
+
desc: 'List sessions',
|
|
39
|
+
options: (yargs: CommandBuilder) => {
|
|
40
|
+
return yargs
|
|
41
|
+
.option('email', {
|
|
42
|
+
alias: 'e',
|
|
43
|
+
type: 'string',
|
|
44
|
+
default: undefined,
|
|
45
|
+
desc: 'Filter sessions by email'
|
|
46
|
+
})
|
|
47
|
+
.option('limit', {
|
|
48
|
+
alias: 'l',
|
|
49
|
+
type: 'number',
|
|
50
|
+
default: false,
|
|
51
|
+
desc: 'Number of sessions to list'
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ILogger, IncomingEvent } from '@stone-js/core'
|
|
2
|
+
import { IUserService } from '../services/contracts/IUserService'
|
|
3
|
+
import { CommandBuilder, defineCommand, FunctionalCommandHandler } from '@stone-js/node-cli-adapter'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ListUsersCommandOptions
|
|
7
|
+
*/
|
|
8
|
+
export interface ListUsersCommandOptions {
|
|
9
|
+
logger: ILogger
|
|
10
|
+
userService: IUserService
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Factory List users command
|
|
15
|
+
*/
|
|
16
|
+
export function factoryListUsersCommand ({ logger, userService }: ListUsersCommandOptions): FunctionalCommandHandler<IncomingEvent> {
|
|
17
|
+
return async function (event: IncomingEvent): Promise<void> {
|
|
18
|
+
const limit = event.get<number>('limit', 10)
|
|
19
|
+
const users = await userService.list(limit)
|
|
20
|
+
logger.info('List users command')
|
|
21
|
+
console.table(users)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* List users command
|
|
27
|
+
*/
|
|
28
|
+
export const ListUsersCommand = defineCommand(factoryListUsersCommand, {
|
|
29
|
+
alias: 'lu',
|
|
30
|
+
isFactory: true,
|
|
31
|
+
name: 'list-users',
|
|
32
|
+
desc: 'List users',
|
|
33
|
+
options: (yargs: CommandBuilder) => {
|
|
34
|
+
return yargs
|
|
35
|
+
.option('limit', {
|
|
36
|
+
alias: 'l',
|
|
37
|
+
type: 'number',
|
|
38
|
+
default: false,
|
|
39
|
+
desc: 'Number of users to list'
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
})
|