@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,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "basic-react-imperative",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Stone.js's basic starter to create react app using imperative API.",
|
|
6
|
+
"author": "Mr. Stone <evensstone@gmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20.0.0"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "stone dev",
|
|
14
|
+
"build": "stone build",
|
|
15
|
+
"preview": "stone preview",
|
|
16
|
+
"typings": "stone typings",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:cvg": "npm run test -- --coverage"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"react": "^19.0.0",
|
|
22
|
+
"react-dom": "^19.0.0",
|
|
23
|
+
"@stone-js/core": "^0.8.3",
|
|
24
|
+
"@stone-js/use-react": "^0.8.3",
|
|
25
|
+
"@stone-js/browser-adapter": "^0.8.3",
|
|
26
|
+
"@stone-js/node-cli-adapter": "^0.8.3"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
30
|
+
"@babel/preset-env": "^7.26.9",
|
|
31
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
32
|
+
"@stone-js/cli": "^0.8.3",
|
|
33
|
+
"@types/node": "^24.0.7",
|
|
34
|
+
"@types/react": "^19.0.7",
|
|
35
|
+
"@types/react-dom": "^19.0.3",
|
|
36
|
+
"@vitest/coverage-v8": "^3.0.9",
|
|
37
|
+
"vitest": "^3.0.9"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { renderToString } from 'react-dom/server'
|
|
2
|
+
import { ILogger, IncomingEvent } from '@stone-js/core'
|
|
3
|
+
import { FactoryHandler, AppConfig } from '../app/Application'
|
|
4
|
+
|
|
5
|
+
vi.mock('@stone-js/core', async (mod) => {
|
|
6
|
+
const actual: any = await mod()
|
|
7
|
+
return {
|
|
8
|
+
...actual,
|
|
9
|
+
isNotEmpty: vi.fn(() => true),
|
|
10
|
+
defineConfig: (config: any) => config
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
describe('Application', () => {
|
|
15
|
+
let app: any
|
|
16
|
+
let mockedLogger: ILogger
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
mockedLogger = {
|
|
20
|
+
info: vi.fn(),
|
|
21
|
+
} as unknown as ILogger
|
|
22
|
+
|
|
23
|
+
app = FactoryHandler({ logger: mockedLogger })
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('should create an application instance', () => {
|
|
27
|
+
// Assert
|
|
28
|
+
expect(app).toBeInstanceOf(Object)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('get head values', async () => {
|
|
32
|
+
// Arrange
|
|
33
|
+
const expectedMessage = 'Hello World!'
|
|
34
|
+
const event = { get: () => 'World' } as unknown as IncomingEvent
|
|
35
|
+
|
|
36
|
+
// Act
|
|
37
|
+
const head = await app.head({ event })
|
|
38
|
+
|
|
39
|
+
// Assert
|
|
40
|
+
expect(head).toHaveProperty('metas')
|
|
41
|
+
expect(head.title).toBe(expectedMessage)
|
|
42
|
+
expect(head).toHaveProperty('description')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('should handle incoming events', () => {
|
|
46
|
+
// Arrange
|
|
47
|
+
const expectedMessage = 'Hello World!'
|
|
48
|
+
const event = { get: () => 'World' } as unknown as IncomingEvent
|
|
49
|
+
|
|
50
|
+
// Act
|
|
51
|
+
const response = app.handle(event) as { message: string }
|
|
52
|
+
|
|
53
|
+
// Assert
|
|
54
|
+
expect(response.message).toBe(expectedMessage)
|
|
55
|
+
expect(mockedLogger.info).toHaveBeenCalledWith(expectedMessage)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('should render component', () => {
|
|
59
|
+
// Arrange
|
|
60
|
+
const message = 'Hello World!'
|
|
61
|
+
|
|
62
|
+
// Act
|
|
63
|
+
const response = renderToString(app.render({ data: { message } } as any))
|
|
64
|
+
|
|
65
|
+
// Assert
|
|
66
|
+
expect(response).toMatchSnapshot()
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('should get config', () => {
|
|
70
|
+
// Arrange
|
|
71
|
+
const config: any = AppConfig
|
|
72
|
+
const blueprint: any = { is: () => true, set: vi.fn() }
|
|
73
|
+
|
|
74
|
+
// Act
|
|
75
|
+
config.afterConfigure(blueprint)
|
|
76
|
+
|
|
77
|
+
// Assert
|
|
78
|
+
expect(blueprint.set).toHaveBeenCalled()
|
|
79
|
+
})
|
|
80
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
|
|
10
|
+
/* Bundler mode */
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"jsx": "react-jsx",
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
|
|
19
|
+
/* Linting */
|
|
20
|
+
"strict": true,
|
|
21
|
+
"noUnusedLocals": true,
|
|
22
|
+
"noUnusedParameters": true,
|
|
23
|
+
"noFallthroughCasesInSwitch": true,
|
|
24
|
+
"noUncheckedSideEffectImports": true,
|
|
25
|
+
|
|
26
|
+
"types": ["node", "vite/client", "vitest/globals"],
|
|
27
|
+
},
|
|
28
|
+
"include": [
|
|
29
|
+
"app",
|
|
30
|
+
"tests",
|
|
31
|
+
"vitest.config.ts"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
globals: true,
|
|
6
|
+
environment: 'node',
|
|
7
|
+
include: ['./tests/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
|
|
8
|
+
coverage: {
|
|
9
|
+
provider: 'v8',
|
|
10
|
+
include: ['app/**/*.ts', 'app/**/*.tsx'],
|
|
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,39 @@
|
|
|
1
|
+
# Stone.js - Basic starter
|
|
2
|
+
|
|
3
|
+
Stone.js's basic starter to create web app using declarative API.
|
|
4
|
+
|
|
5
|
+
## Project Setup
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Compile and Hot-Reload for Development
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm run dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Compile and Bundle for Production
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm run build
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Run the Production build
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm run preview
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Run tests
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npm run test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Run tests with coverage
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm run test:cvg
|
|
39
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NodeHttp } from '@stone-js/node-http-adapter'
|
|
2
|
+
import { NodeConsole } from '@stone-js/node-cli-adapter'
|
|
3
|
+
import { IncomingEvent, IEventHandler, ILogger, LogLevel, StoneApp } from '@stone-js/core'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Application
|
|
7
|
+
*
|
|
8
|
+
* This is the main application entry point.
|
|
9
|
+
*
|
|
10
|
+
* @NodeHttp() is used to enable the Node HTTP adapter.
|
|
11
|
+
* @StoneApp() is used to enable the Stone application, it is required.
|
|
12
|
+
*/
|
|
13
|
+
@NodeConsole()
|
|
14
|
+
@NodeHttp({ default: true })
|
|
15
|
+
@StoneApp({ logger: { level: LogLevel.INFO } })
|
|
16
|
+
export class Application implements IEventHandler<IncomingEvent> {
|
|
17
|
+
/**
|
|
18
|
+
* Logger is a service for logging.
|
|
19
|
+
*/
|
|
20
|
+
private readonly logger: ILogger
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Create a new instance of Application
|
|
24
|
+
* At this point, all the dependencies are resolved and injected.
|
|
25
|
+
* You can access the container and all the services.
|
|
26
|
+
*
|
|
27
|
+
* @param logger - Logger service.
|
|
28
|
+
*/
|
|
29
|
+
constructor ({ logger }: { logger: ILogger }) {
|
|
30
|
+
this.logger = logger
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Handle incoming events
|
|
35
|
+
*
|
|
36
|
+
* @param event Incoming event
|
|
37
|
+
* @returns response
|
|
38
|
+
*/
|
|
39
|
+
handle (event: IncomingEvent): ResponseData {
|
|
40
|
+
// Get the name from the event
|
|
41
|
+
const message = `Hello ${String(event.get<string>('name', 'World'))}!`
|
|
42
|
+
|
|
43
|
+
// Log a message
|
|
44
|
+
this.logger.info(message)
|
|
45
|
+
|
|
46
|
+
// Return a JSON response
|
|
47
|
+
return { message }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Response data
|
|
53
|
+
*/
|
|
54
|
+
export interface ResponseData {
|
|
55
|
+
message: string
|
|
56
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "basic-service-declarative",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Stone.js's basic 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
|
+
"test": "vitest run",
|
|
18
|
+
"test:cvg": "npm run test -- --coverage"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@stone-js/core": "^0.8.3",
|
|
22
|
+
"@stone-js/node-cli-adapter": "^0.8.3",
|
|
23
|
+
"@stone-js/node-http-adapter": "^0.8.3"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
27
|
+
"@babel/preset-env": "^7.26.9",
|
|
28
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
29
|
+
"@stone-js/cli": "^0.8.3",
|
|
30
|
+
"@types/node": "^24.0.7",
|
|
31
|
+
"@vitest/coverage-v8": "^3.0.9",
|
|
32
|
+
"vitest": "^3.0.9"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Application } from '../app/Application'
|
|
2
|
+
import { ILogger, IncomingEvent } from '@stone-js/core'
|
|
3
|
+
|
|
4
|
+
// We must mock decorators to lighten the test environment
|
|
5
|
+
vi.mock(import("@stone-js/core"), async (importOriginal) => {
|
|
6
|
+
const actual = await importOriginal()
|
|
7
|
+
return {
|
|
8
|
+
...actual,
|
|
9
|
+
StoneApp: vi.fn(() => vi.fn()),
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
// We must mock decorators to lighten the test environment
|
|
14
|
+
vi.mock(import("@stone-js/node-cli-adapter"), async (importOriginal) => {
|
|
15
|
+
const actual = await importOriginal()
|
|
16
|
+
return {
|
|
17
|
+
...actual,
|
|
18
|
+
NodeConsole: vi.fn(() => vi.fn()),
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
// We must mock decorators to lighten the test environment
|
|
23
|
+
vi.mock(import("@stone-js/node-http-adapter"), async (importOriginal) => {
|
|
24
|
+
const actual = await importOriginal()
|
|
25
|
+
return {
|
|
26
|
+
...actual,
|
|
27
|
+
NodeHttp: vi.fn(() => vi.fn()),
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
describe('Application', () => {
|
|
32
|
+
let app: Application
|
|
33
|
+
let mockedLogger: ILogger
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
mockedLogger = {
|
|
37
|
+
info: vi.fn(),
|
|
38
|
+
} as unknown as ILogger
|
|
39
|
+
|
|
40
|
+
app = new Application({ logger: mockedLogger })
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('should create an application instance', () => {
|
|
44
|
+
// Assert
|
|
45
|
+
expect(app).toBeInstanceOf(Application)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('should handle incoming events', () => {
|
|
49
|
+
// Arrange
|
|
50
|
+
const expectedMessage = 'Hello World!'
|
|
51
|
+
const event = { get: () => 'World' } as unknown as IncomingEvent
|
|
52
|
+
|
|
53
|
+
// Act
|
|
54
|
+
const response = app.handle(event) as { message: string }
|
|
55
|
+
|
|
56
|
+
// Assert
|
|
57
|
+
expect(response.message).toBe(expectedMessage)
|
|
58
|
+
expect(mockedLogger.info).toHaveBeenCalledWith(expectedMessage)
|
|
59
|
+
})
|
|
60
|
+
})
|
|
@@ -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'
|
|
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,39 @@
|
|
|
1
|
+
# Stone.js - Basic starter
|
|
2
|
+
|
|
3
|
+
Stone.js's basic 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
|
+
```
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { NODE_HTTP_PLATFORM, nodeHttpAdapterBlueprint } from '@stone-js/node-http-adapter'
|
|
2
|
+
import { defineCommand, NODE_CONSOLE_PLATFORM, nodeConsoleAdapterBlueprint } from '@stone-js/node-cli-adapter'
|
|
3
|
+
import { defineStoneApp, defineConfig, IBlueprint, ILogger, IncomingEvent, FunctionalEventHandler } from '@stone-js/core'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create an handler using the factory handler.
|
|
7
|
+
*/
|
|
8
|
+
export const FactoryHandler = ({ logger }: AppOptions): FunctionalEventHandler<IncomingEvent, ResponseData> => {
|
|
9
|
+
return (event: IncomingEvent): ResponseData => {
|
|
10
|
+
// Get the name from the event
|
|
11
|
+
const message = `Hello ${String(event.get<string>('name', 'World'))}!`
|
|
12
|
+
|
|
13
|
+
// Log a message
|
|
14
|
+
logger.info(message)
|
|
15
|
+
|
|
16
|
+
// Return a JSON response
|
|
17
|
+
return { message }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Application factory.
|
|
23
|
+
*
|
|
24
|
+
* @param options - The application options.
|
|
25
|
+
* @returns A function that handles incoming events and returns a response.
|
|
26
|
+
*/
|
|
27
|
+
export const Application = defineStoneApp(
|
|
28
|
+
FactoryHandler,
|
|
29
|
+
{
|
|
30
|
+
debug: true,
|
|
31
|
+
isFactory: true,
|
|
32
|
+
adapter: { platform: NODE_HTTP_PLATFORM }
|
|
33
|
+
},
|
|
34
|
+
[nodeHttpAdapterBlueprint, nodeConsoleAdapterBlueprint]
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Application configuration.
|
|
39
|
+
*/
|
|
40
|
+
export const AppConfig = defineConfig({
|
|
41
|
+
afterConfigure (blueprint: IBlueprint) {
|
|
42
|
+
if (blueprint.is('stone.adapter.platform', NODE_CONSOLE_PLATFORM)) {
|
|
43
|
+
blueprint.set(defineCommand(FactoryHandler, { name: '*', isFactory: true }))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Application options.
|
|
50
|
+
*/
|
|
51
|
+
interface AppOptions {
|
|
52
|
+
logger: ILogger
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Response data
|
|
57
|
+
*/
|
|
58
|
+
export interface ResponseData {
|
|
59
|
+
message: string
|
|
60
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "basic-service-imperative",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Stone.js's basic starter to create web app using imperative API.",
|
|
6
|
+
"author": "Mr. Stone <evensstone@gmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20.0.0"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "stone dev",
|
|
14
|
+
"build": "stone build",
|
|
15
|
+
"preview": "stone preview dist/server.mjs",
|
|
16
|
+
"typings": "stone typings",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:cvg": "npm run test -- --coverage"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@stone-js/core": "^0.8.3",
|
|
22
|
+
"@stone-js/node-cli-adapter": "^0.8.3",
|
|
23
|
+
"@stone-js/node-http-adapter": "^0.8.3"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
27
|
+
"@babel/preset-env": "^7.26.9",
|
|
28
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
29
|
+
"@stone-js/cli": "^0.8.3",
|
|
30
|
+
"@types/node": "^24.0.7",
|
|
31
|
+
"@vitest/coverage-v8": "^3.0.9",
|
|
32
|
+
"vitest": "^3.0.9"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IncomingHttpEvent } from '@stone-js/http-core'
|
|
2
|
+
import { FunctionalEventHandler, ILogger } from '@stone-js/core'
|
|
3
|
+
import { AppConfig, FactoryHandler, ResponseData } from '../app/Application'
|
|
4
|
+
|
|
5
|
+
vi.mock('@stone-js/core', async (mod) => {
|
|
6
|
+
const actual: any = await mod()
|
|
7
|
+
return {
|
|
8
|
+
...actual,
|
|
9
|
+
isNotEmpty: vi.fn(() => true),
|
|
10
|
+
defineConfig: (config: any) => config
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
describe('Application', () => {
|
|
15
|
+
let mockedLogger: ILogger
|
|
16
|
+
let app: FunctionalEventHandler<IncomingHttpEvent, ResponseData>
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
mockedLogger = {
|
|
20
|
+
info: vi.fn(),
|
|
21
|
+
} as unknown as ILogger
|
|
22
|
+
|
|
23
|
+
app = FactoryHandler({ logger: mockedLogger })
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('should create an event handler instance', () => {
|
|
27
|
+
// Assert
|
|
28
|
+
expect(app).toBeTypeOf('function')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should handle incoming http events', async () => {
|
|
32
|
+
// Arrange
|
|
33
|
+
const event = { get: () => 'World' } as unknown as IncomingHttpEvent
|
|
34
|
+
// Act
|
|
35
|
+
const response = await app(event)
|
|
36
|
+
// Assert
|
|
37
|
+
expect(response.message).toBe('Hello World!')
|
|
38
|
+
expect(mockedLogger.info).toHaveBeenCalledWith('Hello World!')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('should get config', () => {
|
|
42
|
+
// Arrange
|
|
43
|
+
const config: any = AppConfig
|
|
44
|
+
const blueprint: any = { is: () => true, set: vi.fn() }
|
|
45
|
+
|
|
46
|
+
// Act
|
|
47
|
+
config.afterConfigure(blueprint)
|
|
48
|
+
|
|
49
|
+
// Assert
|
|
50
|
+
expect(blueprint.set).toHaveBeenCalled()
|
|
51
|
+
})
|
|
52
|
+
})
|
|
@@ -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
|
+
}
|