@qlover/create-app 0.10.1 → 0.10.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.
Files changed (214) hide show
  1. package/CHANGELOG.md +178 -0
  2. package/dist/configs/_common/.github/workflows/general-check.yml +1 -1
  3. package/dist/configs/_common/.github/workflows/release.yml +2 -2
  4. package/dist/index.cjs +4 -4
  5. package/dist/index.js +4 -4
  6. package/dist/templates/next-app/config/IOCIdentifier.ts +2 -2
  7. package/dist/templates/next-app/config/Identifier/common/common.ts +14 -0
  8. package/dist/templates/next-app/config/Identifier/pages/index.ts +1 -0
  9. package/dist/templates/next-app/config/Identifier/pages/page.about.ts +20 -0
  10. package/dist/templates/next-app/config/common.ts +1 -1
  11. package/dist/templates/next-app/config/cookies.ts +23 -0
  12. package/dist/templates/next-app/config/i18n/AboutI18n.ts +14 -0
  13. package/dist/templates/next-app/config/i18n/i18nConfig.ts +3 -1
  14. package/dist/templates/next-app/config/i18n/index.ts +1 -0
  15. package/dist/templates/next-app/config/i18n/loginI18n.ts +8 -0
  16. package/dist/templates/next-app/config/theme.ts +4 -0
  17. package/dist/templates/next-app/eslint.config.mjs +9 -2
  18. package/dist/templates/next-app/next.config.ts +1 -0
  19. package/dist/templates/next-app/package.json +17 -6
  20. package/dist/templates/next-app/public/locales/en.json +5 -0
  21. package/dist/templates/next-app/public/locales/zh.json +5 -0
  22. package/dist/templates/next-app/src/app/[locale]/admin/AdminI18nProvider.tsx +37 -0
  23. package/dist/templates/next-app/src/app/[locale]/admin/layout.tsx +30 -6
  24. package/dist/templates/next-app/src/app/[locale]/admin/locales/page.tsx +1 -1
  25. package/dist/templates/next-app/src/app/[locale]/layout.tsx +47 -10
  26. package/dist/templates/next-app/src/app/[locale]/login/LoginForm.tsx +1 -1
  27. package/dist/templates/next-app/src/app/[locale]/login/page.tsx +22 -10
  28. package/dist/templates/next-app/src/app/[locale]/page.tsx +23 -8
  29. package/dist/templates/next-app/src/app/[locale]/register/page.tsx +21 -9
  30. package/dist/templates/next-app/src/app/api/admin/locales/create/route.ts +7 -28
  31. package/dist/templates/next-app/src/app/api/admin/locales/import/route.ts +7 -34
  32. package/dist/templates/next-app/src/app/api/admin/locales/route.ts +12 -34
  33. package/dist/templates/next-app/src/app/api/admin/locales/update/route.ts +7 -26
  34. package/dist/templates/next-app/src/app/api/admin/users/route.ts +14 -33
  35. package/dist/templates/next-app/src/app/api/locales/json/route.ts +13 -25
  36. package/dist/templates/next-app/src/app/api/user/login/route.ts +6 -46
  37. package/dist/templates/next-app/src/app/api/user/logout/route.ts +5 -24
  38. package/dist/templates/next-app/src/app/api/user/register/route.ts +6 -45
  39. package/dist/templates/next-app/src/app/manifest.ts +16 -0
  40. package/dist/templates/next-app/src/app/robots.txt +2 -0
  41. package/dist/templates/next-app/src/base/cases/AdminPageManager.ts +3 -3
  42. package/dist/templates/next-app/src/base/cases/AppConfig.ts +14 -13
  43. package/dist/templates/next-app/src/base/cases/Datetime.ts +3 -3
  44. package/dist/templates/next-app/src/base/cases/DialogErrorPlugin.ts +8 -2
  45. package/dist/templates/next-app/src/base/cases/DialogHandler.ts +30 -4
  46. package/dist/templates/next-app/src/base/cases/InversifyContainer.ts +16 -4
  47. package/dist/templates/next-app/src/base/cases/NavigateBridge.ts +20 -4
  48. package/dist/templates/next-app/src/base/cases/RequestEncryptPlugin.ts +8 -2
  49. package/dist/templates/next-app/src/base/cases/ResourceState.ts +3 -3
  50. package/dist/templates/next-app/src/base/cases/RouterService.ts +28 -10
  51. package/dist/templates/next-app/src/base/cases/StringEncryptor.ts +14 -2
  52. package/dist/templates/next-app/src/base/cases/TranslateI18nInterface.ts +1 -1
  53. package/dist/templates/next-app/src/base/cases/UserServiceApi.ts +20 -5
  54. package/dist/templates/next-app/src/base/cases/ZodColumnBuilder.ts +31 -8
  55. package/dist/templates/next-app/src/base/port/AdminLayoutInterface.ts +4 -1
  56. package/dist/templates/next-app/src/base/port/AppApiInterface.ts +22 -0
  57. package/dist/templates/next-app/src/base/port/I18nServiceInterface.ts +27 -7
  58. package/dist/templates/next-app/src/base/port/IOCInterface.ts +9 -0
  59. package/dist/templates/next-app/src/base/services/AdminPageEvent.ts +1 -1
  60. package/dist/templates/next-app/src/base/services/AdminPageScheduler.ts +3 -3
  61. package/dist/templates/next-app/src/base/services/I18nService.ts +20 -10
  62. package/dist/templates/next-app/src/base/services/ResourceService.ts +32 -11
  63. package/dist/templates/next-app/src/base/services/UserService.ts +12 -3
  64. package/dist/templates/next-app/src/base/services/adminApi/AdminLocalesApi.ts +9 -6
  65. package/dist/templates/next-app/src/base/services/adminApi/AdminUserApi.ts +20 -5
  66. package/dist/templates/next-app/src/base/services/appApi/AppApiPlugin.ts +21 -4
  67. package/dist/templates/next-app/src/base/services/appApi/AppUserApi.ts +12 -3
  68. package/dist/templates/next-app/src/base/services/appApi/AppUserApiBootstrap.ts +10 -2
  69. package/dist/templates/next-app/src/base/types/{PageProps.ts → AppPageRouter.ts} +4 -1
  70. package/dist/templates/next-app/src/base/types/PagesRouter.ts +9 -0
  71. package/dist/templates/next-app/src/core/bootstraps/BootstrapClient.ts +20 -6
  72. package/dist/templates/next-app/src/core/bootstraps/BootstrapServer.ts +27 -9
  73. package/dist/templates/next-app/src/core/bootstraps/BootstrapsRegistry.ts +6 -4
  74. package/dist/templates/next-app/src/core/clientIoc/ClientIOC.ts +39 -9
  75. package/dist/templates/next-app/src/core/clientIoc/ClientIOCRegister.ts +9 -2
  76. package/dist/templates/next-app/src/core/serverIoc/ServerIOC.ts +37 -10
  77. package/dist/templates/next-app/src/core/serverIoc/ServerIOCRegister.ts +9 -2
  78. package/dist/templates/next-app/src/i18n/loadMessages.ts +103 -0
  79. package/dist/templates/next-app/src/i18n/request.ts +3 -22
  80. package/dist/templates/next-app/src/pages/[locale]/about.tsx +61 -0
  81. package/dist/templates/next-app/src/pages/_app.tsx +50 -0
  82. package/dist/templates/next-app/src/pages/_document.tsx +13 -0
  83. package/dist/templates/next-app/src/{middleware.ts → proxy.ts} +2 -1
  84. package/dist/templates/next-app/src/server/AppErrorApi.ts +1 -1
  85. package/dist/templates/next-app/src/server/AppPageRouteParams.ts +107 -0
  86. package/dist/templates/next-app/src/server/AppSuccessApi.ts +1 -1
  87. package/dist/templates/next-app/src/server/NextApiServer.ts +62 -0
  88. package/dist/templates/next-app/src/server/PagesRouteParams.ts +146 -0
  89. package/dist/templates/next-app/src/server/PasswordEncrypt.ts +8 -2
  90. package/dist/templates/next-app/src/server/ServerAuth.ts +20 -5
  91. package/dist/templates/next-app/src/server/{sqlBridges/SupabaseBridge.ts → SupabaseBridge.ts} +50 -8
  92. package/dist/templates/next-app/src/server/UserCredentialToken.ts +8 -2
  93. package/dist/templates/next-app/src/server/controllers/AdminLocalesController.ts +86 -0
  94. package/dist/templates/next-app/src/server/controllers/AdminUserController.ts +42 -0
  95. package/dist/templates/next-app/src/server/controllers/LocalesController.ts +36 -0
  96. package/dist/templates/next-app/src/server/controllers/UserController.ts +86 -0
  97. package/dist/templates/next-app/src/server/port/AIControllerInterface.ts +8 -0
  98. package/dist/templates/next-app/src/server/port/AdminLocalesControllerInterface.ts +21 -0
  99. package/dist/templates/next-app/src/server/port/AdminUserControllerInterface.ts +11 -0
  100. package/dist/templates/next-app/src/server/port/LocalesControllerInterface.ts +10 -0
  101. package/dist/templates/next-app/src/server/port/{ParamsHandlerInterface.ts → RouteParamsnHandlerInterface.ts} +9 -2
  102. package/dist/templates/next-app/src/server/port/ServerInterface.ts +2 -2
  103. package/dist/templates/next-app/src/server/port/UserControllerInerface.ts +8 -0
  104. package/dist/templates/next-app/src/server/port/UserServiceInterface.ts +1 -1
  105. package/dist/templates/next-app/src/server/port/ValidatorInterface.ts +2 -2
  106. package/dist/templates/next-app/src/server/repositorys/LocalesRepository.ts +31 -9
  107. package/dist/templates/next-app/src/server/repositorys/UserRepository.ts +15 -6
  108. package/dist/templates/next-app/src/server/services/AIService.ts +3 -1
  109. package/dist/templates/next-app/src/server/services/AdminAuthPlugin.ts +5 -2
  110. package/dist/templates/next-app/src/{base → server}/services/AdminLocalesService.ts +2 -2
  111. package/dist/templates/next-app/src/server/services/ApiLocaleService.ts +29 -14
  112. package/dist/templates/next-app/src/server/services/ApiUserService.ts +6 -3
  113. package/dist/templates/next-app/src/server/services/UserService.ts +12 -3
  114. package/dist/templates/next-app/src/server/validators/LocalesValidator.ts +24 -7
  115. package/dist/templates/next-app/src/server/validators/LoginValidator.ts +17 -5
  116. package/dist/templates/next-app/src/server/validators/PaginationValidator.ts +17 -11
  117. package/dist/templates/next-app/src/styles/css/antd-themes/_common/_default.css +0 -44
  118. package/dist/templates/next-app/src/styles/css/antd-themes/_common/dark.css +0 -44
  119. package/dist/templates/next-app/src/styles/css/antd-themes/_common/pink.css +0 -44
  120. package/dist/templates/next-app/src/styles/css/index.css +1 -1
  121. package/dist/templates/next-app/src/styles/css/scrollbar.css +34 -0
  122. package/dist/templates/next-app/src/uikit/components/AdminLayout.tsx +34 -11
  123. package/dist/templates/next-app/src/uikit/components/BootstrapsProvider.tsx +69 -39
  124. package/dist/templates/next-app/src/uikit/components/ClientRootProvider.tsx +64 -0
  125. package/dist/templates/next-app/src/uikit/components/ClinetRenderProvider.tsx +42 -0
  126. package/dist/templates/next-app/src/uikit/components/IOCProvider.tsx +34 -0
  127. package/dist/templates/next-app/src/uikit/components/localesImportButton/LocalesImportEvent.ts +7 -1
  128. package/dist/templates/next-app/src/uikit/components-app/AppBridge.tsx +17 -0
  129. package/dist/templates/next-app/src/uikit/components-app/AppRoutePage.tsx +112 -0
  130. package/dist/templates/next-app/src/uikit/{components → components-app}/LanguageSwitcher.tsx +15 -19
  131. package/dist/templates/next-app/src/uikit/{components → components-app}/ThemeSwitcher.tsx +53 -52
  132. package/dist/templates/next-app/src/uikit/components-pages/LanguageSwitcher.tsx +98 -0
  133. package/dist/templates/next-app/src/uikit/components-pages/PagesRoutePage.tsx +93 -0
  134. package/dist/templates/next-app/src/uikit/context/IOCContext.ts +16 -4
  135. package/dist/templates/next-app/src/uikit/hook/useStrictEffect.ts +32 -0
  136. package/dist/templates/next-app/tsconfig.json +3 -2
  137. package/dist/templates/react-app/__tests__/__mocks__/BootstrapTest.ts +3 -1
  138. package/dist/templates/react-app/__tests__/__mocks__/MockAppConfig.ts +19 -19
  139. package/dist/templates/react-app/__tests__/__mocks__/MockDialogHandler.ts +8 -8
  140. package/dist/templates/react-app/__tests__/__mocks__/MockLogger.ts +9 -9
  141. package/dist/templates/react-app/__tests__/__mocks__/components/TestBootstrapsProvider.tsx +1 -1
  142. package/dist/templates/react-app/__tests__/__mocks__/i18nextHttpBackend.ts +5 -5
  143. package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOC.ts +9 -5
  144. package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOCRegister.ts +8 -4
  145. package/dist/templates/react-app/__tests__/src/base/cases/I18nKeyErrorPlugin.test.ts +4 -4
  146. package/dist/templates/react-app/__tests__/src/base/cases/InversifyContainer.test.ts +5 -5
  147. package/dist/templates/react-app/__tests__/src/core/bootstraps/BootstrapClient.test.ts +3 -3
  148. package/dist/templates/react-app/__tests__/src/uikit/components/chatMessage/ChatRoot.test.tsx +1 -1
  149. package/dist/templates/react-app/docs/en/components/chat-message-component.md +35 -29
  150. package/dist/templates/react-app/docs/en/components/chat-message-refactor.md +18 -5
  151. package/dist/templates/react-app/docs/en/components/message-base-list-component.md +11 -12
  152. package/dist/templates/react-app/docs/en/request.md +1 -3
  153. package/dist/templates/react-app/docs/zh/components/chat-message-component.md +35 -29
  154. package/dist/templates/react-app/docs/zh/components/chat-message-refactor.md +18 -5
  155. package/dist/templates/react-app/docs/zh/components/message-base-list-component.md +11 -12
  156. package/dist/templates/react-app/docs/zh/request.md +1 -3
  157. package/dist/templates/react-app/eslint.config.mjs +10 -5
  158. package/dist/templates/react-app/src/App.tsx +1 -1
  159. package/dist/templates/react-app/src/base/apis/feApi/FeApi.ts +2 -2
  160. package/dist/templates/react-app/src/base/apis/feApi/FeApiBootstarp.ts +14 -11
  161. package/dist/templates/react-app/src/base/apis/userApi/UserApi.ts +10 -16
  162. package/dist/templates/react-app/src/base/apis/userApi/UserApiBootstarp.ts +12 -10
  163. package/dist/templates/react-app/src/base/cases/AppConfig.ts +19 -19
  164. package/dist/templates/react-app/src/base/cases/DialogHandler.ts +28 -5
  165. package/dist/templates/react-app/src/base/cases/I18nKeyErrorPlugin.ts +5 -2
  166. package/dist/templates/react-app/src/base/cases/InversifyContainer.ts +16 -4
  167. package/dist/templates/react-app/src/base/cases/PublicAssetsPath.ts +1 -1
  168. package/dist/templates/react-app/src/base/cases/RequestLanguages.ts +6 -3
  169. package/dist/templates/react-app/src/base/cases/RequestLogger.ts +17 -8
  170. package/dist/templates/react-app/src/base/cases/RequestStatusCatcher.ts +4 -6
  171. package/dist/templates/react-app/src/base/cases/ResourceState.ts +3 -3
  172. package/dist/templates/react-app/src/base/cases/RouterLoader.ts +3 -3
  173. package/dist/templates/react-app/src/base/cases/TranslateI18nInterface.ts +1 -1
  174. package/dist/templates/react-app/src/base/port/ExecutorPageBridgeInterface.ts +2 -2
  175. package/dist/templates/react-app/src/base/port/IOCInterface.ts +4 -2
  176. package/dist/templates/react-app/src/base/port/JSONStoragePageBridgeInterface.ts +5 -5
  177. package/dist/templates/react-app/src/base/port/RequestPageBridgeInterface.ts +7 -7
  178. package/dist/templates/react-app/src/base/port/RouteServiceInterface.ts +8 -8
  179. package/dist/templates/react-app/src/base/port/UserServiceInterface.ts +4 -2
  180. package/dist/templates/react-app/src/base/services/BaseLayoutService.ts +3 -3
  181. package/dist/templates/react-app/src/base/services/I18nService.ts +24 -13
  182. package/dist/templates/react-app/src/base/services/IdentifierService.ts +21 -26
  183. package/dist/templates/react-app/src/base/services/RouteService.ts +8 -8
  184. package/dist/templates/react-app/src/base/services/UserBootstrap.ts +2 -2
  185. package/dist/templates/react-app/src/base/services/UserGatewayPlugin.ts +9 -5
  186. package/dist/templates/react-app/src/base/services/UserService.ts +10 -4
  187. package/dist/templates/react-app/src/core/bootstraps/BootstrapClient.ts +3 -1
  188. package/dist/templates/react-app/src/core/bootstraps/BootstrapsRegistry.ts +5 -2
  189. package/dist/templates/react-app/src/core/clientIoc/ClientIOC.ts +11 -4
  190. package/dist/templates/react-app/src/core/clientIoc/ClientIOCRegister.ts +5 -4
  191. package/dist/templates/react-app/src/pages/base/Layout.tsx +1 -1
  192. package/dist/templates/react-app/src/styles/css/antd-themes/_common/_default.css +0 -44
  193. package/dist/templates/react-app/src/styles/css/antd-themes/_common/dark.css +0 -44
  194. package/dist/templates/react-app/src/styles/css/antd-themes/_common/pink.css +0 -44
  195. package/dist/templates/react-app/src/styles/css/index.css +1 -1
  196. package/dist/templates/react-app/src/styles/css/scrollbar.css +34 -0
  197. package/dist/templates/react-app/src/uikit/bridges/ExecutorPageBridge.ts +2 -2
  198. package/dist/templates/react-app/src/uikit/bridges/JSONStoragePageBridge.ts +4 -4
  199. package/dist/templates/react-app/src/uikit/bridges/NavigateBridge.ts +8 -2
  200. package/dist/templates/react-app/src/uikit/bridges/RequestPageBridge.ts +6 -6
  201. package/dist/templates/react-app/src/uikit/components/AppRouterProvider.tsx +1 -1
  202. package/dist/templates/react-app/src/uikit/components/BootstrapsProvider.tsx +1 -3
  203. package/dist/templates/react-app/src/uikit/components/MessageBaseList.tsx +4 -1
  204. package/dist/templates/react-app/src/uikit/components/chatMessage/ChatMessageBridge.ts +39 -16
  205. package/dist/templates/react-app/src/uikit/components/chatMessage/MessageApi.ts +4 -2
  206. package/package.json +3 -3
  207. package/dist/templates/next-app/src/server/PageParams.ts +0 -66
  208. package/dist/templates/next-app/src/uikit/components/BaseHeader.tsx +0 -80
  209. package/dist/templates/next-app/src/uikit/components/BaseLayout.tsx +0 -65
  210. package/dist/templates/next-app/src/uikit/components/ComboProvider.tsx +0 -58
  211. package/dist/templates/next-app/src/uikit/components/NextIntlProvider.tsx +0 -21
  212. package/dist/templates/react-app/makes/eslint-utils.mjs +0 -195
  213. /package/dist/templates/next-app/{src/app/[locale] → public}/favicon.ico +0 -0
  214. /package/dist/templates/next-app/src/uikit/{components → components-app}/LogoutButton.tsx +0 -0
@@ -1,34 +1,13 @@
1
- import { ExecutorError } from '@qlover/fe-corekit';
2
- import { NextResponse } from 'next/server';
3
- import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
4
- import { AppErrorApi } from '@/server/AppErrorApi';
5
- import { AppSuccessApi } from '@/server/AppSuccessApi';
1
+ import { AdminLocalesController } from '@/server/controllers/AdminLocalesController';
2
+ import { NextApiServer } from '@/server/NextApiServer';
6
3
  import { AdminAuthPlugin } from '@/server/services/AdminAuthPlugin';
7
- import { ApiLocaleService } from '@/server/services/ApiLocaleService';
8
- import { LocalesValidator } from '@/server/validators/LocalesValidator';
9
4
  import type { NextRequest } from 'next/server';
10
5
 
11
6
  export async function POST(req: NextRequest) {
12
- const server = new BootstrapServer();
13
-
14
- const result = await server
7
+ const requestBody = await req.json();
8
+ return await new NextApiServer()
15
9
  .use(new AdminAuthPlugin())
16
- .execNoError(async ({ parameters: { IOC } }) => {
17
- const requestBody = await req.json();
18
- const localesParams = IOC(LocalesValidator).getThrow(requestBody);
19
- const adminLocalesService = IOC(ApiLocaleService);
20
- await adminLocalesService.create(localesParams);
21
- return {
22
- success: true
23
- };
24
- });
25
-
26
- if (result instanceof ExecutorError) {
27
- console.error(result);
28
- return NextResponse.json(new AppErrorApi(result.id, result.message), {
29
- status: 400
30
- });
31
- }
32
-
33
- return NextResponse.json(new AppSuccessApi(result));
10
+ .runWithJson(async ({ parameters: { IOC } }) =>
11
+ IOC(AdminLocalesController).createLocale(requestBody)
12
+ );
34
13
  }
@@ -1,40 +1,13 @@
1
- import { ExecutorError } from '@qlover/fe-corekit';
2
- import { NextResponse } from 'next/server';
3
- import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
4
- import { AppErrorApi } from '@/server/AppErrorApi';
5
- import { AppSuccessApi } from '@/server/AppSuccessApi';
1
+ import { AdminLocalesController } from '@/server/controllers/AdminLocalesController';
2
+ import { NextApiServer } from '@/server/NextApiServer';
6
3
  import { AdminAuthPlugin } from '@/server/services/AdminAuthPlugin';
7
- import { ApiLocaleService } from '@/server/services/ApiLocaleService';
8
- import { LocalesImportValidator } from '@/server/validators/LocalesValidator';
9
4
  import type { NextRequest } from 'next/server';
10
5
 
11
6
  export async function POST(req: NextRequest) {
12
- const server = new BootstrapServer();
13
-
14
- const result = await server
7
+ const formData = await req.formData();
8
+ return await new NextApiServer()
15
9
  .use(new AdminAuthPlugin())
16
- .execNoError(async ({ parameters: { IOC } }) => {
17
- const formData = await req.formData();
18
-
19
- const localesParams = await IOC(LocalesImportValidator).getThrow({
20
- values: formData
21
- });
22
-
23
- const adminLocalesService = IOC(ApiLocaleService);
24
-
25
- const result = await adminLocalesService.importLocales(localesParams);
26
- return {
27
- success: true,
28
- data: result
29
- };
30
- });
31
-
32
- if (result instanceof ExecutorError) {
33
- console.error(result);
34
- return NextResponse.json(new AppErrorApi(result.id, result.message), {
35
- status: 400
36
- });
37
- }
38
-
39
- return NextResponse.json(new AppSuccessApi(result));
10
+ .runWithJson(async ({ parameters: { IOC } }) =>
11
+ IOC(AdminLocalesController).importLocales(formData)
12
+ );
40
13
  }
@@ -1,42 +1,20 @@
1
- import { ExecutorError } from '@qlover/fe-corekit';
2
- import { NextResponse } from 'next/server';
3
- import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
4
- import { AppErrorApi } from '@/server/AppErrorApi';
5
- import { AppSuccessApi } from '@/server/AppSuccessApi';
1
+ import { AdminLocalesController } from '@/server/controllers/AdminLocalesController';
2
+ import { NextApiServer } from '@/server/NextApiServer';
3
+ import type { BridgeOrderBy } from '@/server/port/DBBridgeInterface';
6
4
  import { AdminAuthPlugin } from '@/server/services/AdminAuthPlugin';
7
- import { ApiLocaleService } from '@/server/services/ApiLocaleService';
8
- import { PaginationValidator } from '@/server/validators/PaginationValidator';
9
5
  import type { NextRequest } from 'next/server';
10
6
 
11
7
  export async function GET(req: NextRequest) {
12
- const server = new BootstrapServer();
13
-
14
- const result = await server
8
+ const searchParams = Object.fromEntries(req.nextUrl.searchParams.entries());
9
+ return await new NextApiServer()
15
10
  .use(new AdminAuthPlugin())
16
- .execNoError(async ({ parameters: { IOC } }) => {
17
- const searchParams = Object.fromEntries(
18
- req.nextUrl.searchParams.entries()
11
+ .runWithJson(async ({ parameters: { IOC } }) => {
12
+ return IOC(AdminLocalesController).getLocales(
13
+ searchParams as unknown as {
14
+ page: number;
15
+ pageSize: number;
16
+ orders?: BridgeOrderBy;
17
+ }
19
18
  );
20
-
21
- const paginationParams = IOC(PaginationValidator).getThrow(searchParams);
22
-
23
- const apiUserService = IOC(ApiLocaleService);
24
-
25
- const result = await apiUserService.getLocales({
26
- page: paginationParams.page,
27
- pageSize: paginationParams.pageSize,
28
- orderBy: paginationParams.orders
29
- });
30
-
31
- return result;
32
- });
33
-
34
- if (result instanceof ExecutorError) {
35
- console.error(result);
36
- return NextResponse.json(new AppErrorApi(result.id, result.message), {
37
- status: 400
38
19
  });
39
- }
40
-
41
- return NextResponse.json(new AppSuccessApi(result));
42
20
  }
@@ -1,32 +1,13 @@
1
- import { ExecutorError } from '@qlover/fe-corekit';
2
- import { NextResponse } from 'next/server';
3
- import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
4
- import { AppErrorApi } from '@/server/AppErrorApi';
5
- import { AppSuccessApi } from '@/server/AppSuccessApi';
1
+ import { AdminLocalesController } from '@/server/controllers/AdminLocalesController';
2
+ import { NextApiServer } from '@/server/NextApiServer';
6
3
  import { AdminAuthPlugin } from '@/server/services/AdminAuthPlugin';
7
- import { ApiLocaleService } from '@/server/services/ApiLocaleService';
8
4
  import type { NextRequest } from 'next/server';
9
5
 
10
6
  export async function POST(req: NextRequest) {
11
- const server = new BootstrapServer();
12
-
13
- const result = await server
7
+ const requestBody = await req.json();
8
+ return await new NextApiServer()
14
9
  .use(new AdminAuthPlugin())
15
- .execNoError(async ({ parameters: { IOC } }) => {
16
- const requestBody = await req.json();
17
- const adminLocalesService = IOC(ApiLocaleService);
18
- await adminLocalesService.update(requestBody);
19
- return {
20
- success: true
21
- };
22
- });
23
-
24
- if (result instanceof ExecutorError) {
25
- console.error(result);
26
- return NextResponse.json(new AppErrorApi(result.id, result.message), {
27
- status: 400
28
- });
29
- }
30
-
31
- return NextResponse.json(new AppSuccessApi(result));
10
+ .runWithJson(async ({ parameters: { IOC } }) =>
11
+ IOC(AdminLocalesController).updateLocale(requestBody)
12
+ );
32
13
  }
@@ -1,39 +1,20 @@
1
- import { ExecutorError } from '@qlover/fe-corekit';
2
- import { NextResponse } from 'next/server';
3
- import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
4
- import { AppErrorApi } from '@/server/AppErrorApi';
5
- import { AppSuccessApi } from '@/server/AppSuccessApi';
1
+ import { AdminUserController } from '@/server/controllers/AdminUserController';
2
+ import { NextApiServer } from '@/server/NextApiServer';
3
+ import type { BridgeOrderBy } from '@/server/port/DBBridgeInterface';
6
4
  import { AdminAuthPlugin } from '@/server/services/AdminAuthPlugin';
7
- import { ApiUserService } from '@/server/services/ApiUserService';
8
- import { PaginationValidator } from '@/server/validators/PaginationValidator';
9
5
  import type { NextRequest } from 'next/server';
10
6
 
11
7
  export async function GET(req: NextRequest) {
12
- const server = new BootstrapServer();
8
+ const searchParams = Object.fromEntries(req.nextUrl.searchParams.entries());
13
9
 
14
- const result = await server
15
- .use(new AdminAuthPlugin())
16
- .execNoError(async ({ parameters: { IOC } }) => {
17
- const searchParams = Object.fromEntries(
18
- req.nextUrl.searchParams.entries()
19
- );
20
- const paginationParams = IOC(PaginationValidator).getThrow(searchParams);
21
-
22
- const apiUserService = IOC(ApiUserService);
23
-
24
- const result = await apiUserService.getUsers({
25
- page: paginationParams.page,
26
- pageSize: paginationParams.pageSize
27
- });
28
-
29
- return result;
30
- });
31
-
32
- if (result instanceof ExecutorError) {
33
- return NextResponse.json(new AppErrorApi(result.id, result.message), {
34
- status: 400
35
- });
36
- }
37
-
38
- return NextResponse.json(new AppSuccessApi(result));
10
+ return await new NextApiServer().use(new AdminAuthPlugin()).runWithJson(
11
+ async ({ parameters: { IOC } }) =>
12
+ await IOC(AdminUserController).getUsers(
13
+ searchParams as unknown as {
14
+ page: number;
15
+ pageSize: number;
16
+ orderBy?: BridgeOrderBy;
17
+ }
18
+ )
19
+ );
39
20
  }
@@ -1,9 +1,9 @@
1
- import { ExecutorError } from '@qlover/fe-corekit';
2
1
  import { NextResponse, type NextRequest } from 'next/server';
3
- import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
4
- import { ApiLocaleService } from '@/server/services/ApiLocaleService';
5
- import { i18nConfig } from '@config/i18n';
2
+ import { LocalesController } from '@/server/controllers/LocalesController';
3
+ import { NextApiServer } from '@/server/NextApiServer';
4
+ import type { LocalesControllerJsonQuery } from '@/server/port/LocalesControllerInterface';
6
5
  import type { LocaleType } from '@config/i18n';
6
+ import { i18nConfig } from '@config/i18n';
7
7
 
8
8
  // Use literal value instead of imported config to ensure static analysis
9
9
  export const revalidate = 60; // Cache time in seconds (matches i18nConfig.localeCacheTime)
@@ -12,30 +12,18 @@ export async function GET(req: NextRequest) {
12
12
  const searchParams = Object.fromEntries(req.nextUrl.searchParams.entries());
13
13
  const locale = searchParams.locale as LocaleType;
14
14
 
15
- if (!locale || !i18nConfig.supportedLngs.includes(locale)) {
16
- return NextResponse.json({}, { status: 404 });
17
- }
18
-
19
- const server = new BootstrapServer();
20
-
21
- const result = await server.execNoError(async ({ parameters: { IOC } }) => {
22
- const localesService = IOC(ApiLocaleService);
23
- const result = await localesService.getLocalesJson(locale);
24
-
25
- return result;
26
- });
15
+ const result = await new NextApiServer().run(
16
+ async ({ parameters: { IOC } }) =>
17
+ IOC(LocalesController).json(
18
+ searchParams as unknown as LocalesControllerJsonQuery
19
+ )
20
+ );
27
21
 
28
- if (result instanceof ExecutorError) {
29
- console.error(result);
30
- return NextResponse.json(
31
- {},
32
- {
33
- status: 400
34
- }
35
- );
22
+ if (!result.success) {
23
+ return NextResponse.json({});
36
24
  }
37
25
 
38
- const response = NextResponse.json(result);
26
+ const response = NextResponse.json(result.data);
39
27
  response.headers.set(
40
28
  'Cache-Control',
41
29
  `s-maxage=${i18nConfig.localeCacheTime}`
@@ -1,50 +1,10 @@
1
- import { ExecutorError } from '@qlover/fe-corekit';
2
- import { NextResponse } from 'next/server';
3
- import { StringEncryptor } from '@/base/cases/StringEncryptor';
4
- import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
5
- import { AppErrorApi } from '@/server/AppErrorApi';
6
- import { AppSuccessApi } from '@/server/AppSuccessApi';
7
- import type { UserServiceInterface } from '@/server/port/UserServiceInterface';
8
- import { ServerAuth } from '@/server/ServerAuth';
9
- import { UserService } from '@/server/services/UserService';
10
- import { LoginValidator } from '@/server/validators/LoginValidator';
11
- import type { UserSchema } from '@migrations/schema/UserSchema';
1
+ import { UserController } from '@/server/controllers/UserController';
2
+ import { NextApiServer } from '@/server/NextApiServer';
12
3
  import type { NextRequest } from 'next/server';
13
4
 
14
5
  export async function POST(req: NextRequest) {
15
- const server = new BootstrapServer();
16
-
17
- const result = await server.execNoError(async ({ parameters: { IOC } }) => {
18
- const requestBody = await req.json();
19
-
20
- try {
21
- if (requestBody.password) {
22
- requestBody.password = IOC(StringEncryptor).decrypt(
23
- requestBody.password
24
- );
25
- }
26
- } catch {
27
- throw new ExecutorError(
28
- 'encrypt_password_failed',
29
- 'Encrypt password failed'
30
- );
31
- }
32
- const body = IOC(LoginValidator).getThrow(requestBody);
33
-
34
- const userService: UserServiceInterface = IOC(UserService);
35
-
36
- const user = (await userService.login(body)) as UserSchema;
37
-
38
- await IOC(ServerAuth).setAuth(user.credential_token);
39
-
40
- return user;
41
- });
42
-
43
- if (result instanceof ExecutorError) {
44
- return NextResponse.json(new AppErrorApi(result.id, result.message), {
45
- status: 400
46
- });
47
- }
48
-
49
- return NextResponse.json(new AppSuccessApi(result));
6
+ const requestBody = await req.json();
7
+ return await new NextApiServer().runWithJson(
8
+ async ({ parameters: { IOC } }) => IOC(UserController).login(requestBody)
9
+ );
50
10
  }
@@ -1,27 +1,8 @@
1
- import { ExecutorError } from '@qlover/fe-corekit';
2
- import { NextResponse } from 'next/server';
3
- import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
4
- import { AppErrorApi } from '@/server/AppErrorApi';
5
- import { AppSuccessApi } from '@/server/AppSuccessApi';
6
- import type { UserServiceInterface } from '@/server/port/UserServiceInterface';
7
- import { UserService } from '@/server/services/UserService';
1
+ import { UserController } from '@/server/controllers/UserController';
2
+ import { NextApiServer } from '@/server/NextApiServer';
8
3
 
9
4
  export async function POST() {
10
- const server = new BootstrapServer();
11
-
12
- const result = await server.execNoError(async ({ parameters: { IOC } }) => {
13
- const userService: UserServiceInterface = IOC(UserService);
14
-
15
- await userService.logout();
16
-
17
- return true;
18
- });
19
-
20
- if (result instanceof ExecutorError) {
21
- return NextResponse.json(new AppErrorApi(result.id, result.message), {
22
- status: 400
23
- });
24
- }
25
-
26
- return NextResponse.json(new AppSuccessApi(result));
5
+ return await new NextApiServer().runWithJson(
6
+ async ({ parameters: { IOC } }) => IOC(UserController).logout()
7
+ );
27
8
  }
@@ -1,50 +1,11 @@
1
- import { ExecutorError } from '@qlover/fe-corekit';
2
- import { NextResponse } from 'next/server';
3
- import { StringEncryptor } from '@/base/cases/StringEncryptor';
4
- import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
5
- import { AppErrorApi } from '@/server/AppErrorApi';
6
- import { AppSuccessApi } from '@/server/AppSuccessApi';
7
- import type { UserServiceInterface } from '@/server/port/UserServiceInterface';
8
- import { UserService } from '@/server/services/UserService';
9
- import { LoginValidator } from '@/server/validators/LoginValidator';
1
+ import { UserController } from '@/server/controllers/UserController';
2
+ import { NextApiServer } from '@/server/NextApiServer';
10
3
  import type { NextRequest } from 'next/server';
11
4
 
12
5
  export async function POST(req: NextRequest) {
13
- const server = new BootstrapServer();
6
+ const requestBody = await req.json();
14
7
 
15
- const result = await server.execNoError(async ({ parameters: { IOC } }) => {
16
- const requestBody = await req.json();
17
-
18
- try {
19
- if (requestBody.password) {
20
- requestBody.password = IOC(StringEncryptor).decrypt(
21
- requestBody.password
22
- );
23
- }
24
- } catch {
25
- throw new ExecutorError(
26
- 'encrypt_password_failed',
27
- 'Encrypt password failed'
28
- );
29
- }
30
-
31
- const body = IOC(LoginValidator).getThrow(requestBody);
32
-
33
- const userService: UserServiceInterface = IOC(UserService);
34
-
35
- const user = await userService.register({
36
- email: body.email,
37
- password: body.password
38
- });
39
-
40
- return user;
41
- });
42
-
43
- if (result instanceof ExecutorError) {
44
- return NextResponse.json(new AppErrorApi(result.id, result.message), {
45
- status: 400
46
- });
47
- }
48
-
49
- return NextResponse.json(new AppSuccessApi(result));
8
+ return await new NextApiServer().runWithJson(
9
+ async ({ parameters: { IOC } }) => IOC(UserController).register(requestBody)
10
+ );
50
11
  }
@@ -0,0 +1,16 @@
1
+ import { getTranslations } from 'next-intl/server';
2
+ import { routing } from '@/i18n/routing';
3
+ import { COMMON_MANIFEST_NAME } from '@config/Identifier';
4
+ import type { MetadataRoute } from 'next';
5
+
6
+ export default async function manifest(): Promise<MetadataRoute.Manifest> {
7
+ const t = await getTranslations({
8
+ locale: routing.defaultLocale
9
+ });
10
+
11
+ return {
12
+ name: t(COMMON_MANIFEST_NAME),
13
+ start_url: '/',
14
+ theme_color: '#101E33'
15
+ };
16
+ }
@@ -0,0 +1,2 @@
1
+ User-Agent: *
2
+ Allow: *
@@ -7,9 +7,9 @@ import type {
7
7
  } from '../port/AdminLayoutInterface';
8
8
 
9
9
  class AdminPageManagerState implements AdminPageState {
10
- collapsedSidebar = false;
10
+ public collapsedSidebar = false;
11
11
 
12
- navItems: NavItemInterface[] = defaultNavItems;
12
+ public navItems: NavItemInterface[] = defaultNavItems;
13
13
  }
14
14
 
15
15
  @injectable()
@@ -18,7 +18,7 @@ export class AdminPageManager extends AdminLayoutInterface {
18
18
  super(() => new AdminPageManagerState());
19
19
  }
20
20
 
21
- override toggleSidebar(): void {
21
+ public override toggleSidebar(): void {
22
22
  this.emit(
23
23
  this.cloneState({
24
24
  collapsedSidebar: !this.state.collapsedSidebar
@@ -8,30 +8,31 @@ export class AppConfig implements EnvConfigInterface {
8
8
  * @description Represents the running environment (development, production, etc.)
9
9
  * Automatically set based on the current .env file being used
10
10
  */
11
- readonly env: string = process.env.APP_ENV!;
12
- readonly appName: string = name;
13
- readonly appVersion: string = version;
11
+ public readonly env: string = process.env.APP_ENV!;
12
+ public readonly appName: string = name;
13
+ public readonly appVersion: string = version;
14
14
 
15
- readonly userTokenKey: string = '_user_token';
15
+ public readonly userTokenKey: string = '_user_token';
16
16
 
17
- readonly testLoginEmail: string = process.env.NEXT_PUBLIC_LOGIN_USER!;
18
- readonly testLoginPassword: string = process.env.NEXT_PUBLIC_LOGIN_PASSWORD!;
17
+ public readonly testLoginEmail: string = process.env.NEXT_PUBLIC_LOGIN_USER!;
18
+ public readonly testLoginPassword: string =
19
+ process.env.NEXT_PUBLIC_LOGIN_PASSWORD!;
19
20
 
20
- readonly supabaseUrl: string = process.env.SUPABASE_URL!;
21
- readonly supabaseAnonKey: string = process.env.SUPABASE_ANON_KEY!;
21
+ public readonly supabaseUrl: string = process.env.SUPABASE_URL!;
22
+ public readonly supabaseAnonKey: string = process.env.SUPABASE_ANON_KEY!;
22
23
 
23
- readonly stringEncryptorKey: string =
24
+ public readonly stringEncryptorKey: string =
24
25
  process.env.NEXT_PUBLIC_STRING_ENCRYPT_KEY!;
25
26
 
26
- readonly jwtSecret: string = process.env.JWT_SECRET!;
27
+ public readonly jwtSecret: string = process.env.JWT_SECRET!;
27
28
  /**
28
29
  * login user token expires in
29
30
  *
30
31
  * @example '30 days'
31
32
  * @example '1 year'
32
33
  */
33
- readonly jwtExpiresIn: StringValue = '30 days';
34
+ public readonly jwtExpiresIn: StringValue = '30 days';
34
35
 
35
- readonly openaiBaseUrl: string = process.env.CEREBRAS_BASE_URL!;
36
- readonly openaiApiKey: string = process.env.CEREBRAS_API_KEY!;
36
+ public readonly openaiBaseUrl: string = process.env.CEREBRAS_BASE_URL!;
37
+ public readonly openaiApiKey: string = process.env.CEREBRAS_API_KEY!;
37
38
  }
@@ -3,16 +3,16 @@ import { injectable } from 'inversify';
3
3
 
4
4
  @injectable()
5
5
  export class Datetime {
6
- timestamp(): number {
6
+ public timestamp(): number {
7
7
  return dayjs().unix();
8
8
  }
9
9
 
10
- timestampz(): string {
10
+ public timestampz(): string {
11
11
  const now = new Date();
12
12
  return now.toISOString().replace('T', ' ').replace('Z', '+00');
13
13
  }
14
14
 
15
- format(format: string, date?: Date): string {
15
+ public format(format: string, date?: Date): string {
16
16
  return dayjs(date).format(format);
17
17
  }
18
18
  }
@@ -14,7 +14,7 @@ import type { UIDialogInterface } from '@qlover/corekit-bridge';
14
14
 
15
15
  @injectable()
16
16
  export class DialogErrorPlugin implements ExecutorPlugin {
17
- readonly pluginName = 'DialogErrorPlugin';
17
+ public readonly pluginName = 'DialogErrorPlugin';
18
18
 
19
19
  constructor(
20
20
  @inject(I.DialogHandler)
@@ -24,7 +24,10 @@ export class DialogErrorPlugin implements ExecutorPlugin {
24
24
  protected routerService: RouterService
25
25
  ) {}
26
26
 
27
- onError(context: ExecutorContext<unknown>): void | Promise<void> {
27
+ /**
28
+ * @override
29
+ */
30
+ public onError(context: ExecutorContext<unknown>): void | Promise<void> {
28
31
  const { error, hooksRuntimes } = context;
29
32
  const runtimesError = hooksRuntimes.returnValue;
30
33
 
@@ -46,6 +49,9 @@ export class DialogErrorPlugin implements ExecutorPlugin {
46
49
  }
47
50
  }
48
51
 
52
+ /**
53
+ * @override
54
+ */
49
55
  protected isI18nMessage(message: string): boolean {
50
56
  return i18nKeySchema.safeParse(message).success;
51
57
  }
@@ -45,31 +45,48 @@ export class DialogHandler
45
45
  notification?: NotificationApi;
46
46
  } = {};
47
47
 
48
- setMessage(message: MessageApi): void {
48
+ /**
49
+ * @override
50
+ */
51
+ public setMessage(message: MessageApi): void {
49
52
  this.antds.message = message;
50
53
  }
51
54
 
52
- setModal(modal: ModalApi): void {
55
+ /**
56
+ * @override
57
+ */
58
+ public setModal(modal: ModalApi): void {
53
59
  this.antds.modal = modal;
54
60
  }
55
61
 
56
- setNotification(notification: NotificationApi): void {
62
+ /**
63
+ * @override
64
+ */
65
+ public setNotification(notification: NotificationApi): void {
57
66
  this.antds.notification = notification;
58
67
  }
59
68
 
60
69
  /**
61
70
  * Formats error message from various error types
62
- */
71
+
72
+ * @override
73
+ */
63
74
  protected formatErrorMessage(error: unknown): string {
64
75
  if (error instanceof Error) return error.message;
65
76
  if (typeof error === 'string') return error;
66
77
  return 'An unknown error occurred';
67
78
  }
68
79
 
80
+ /**
81
+ * @override
82
+ */
69
83
  public success(msg: string, options?: NotificationOptions): void {
70
84
  this.antds.message?.success({ content: msg, ...options });
71
85
  }
72
86
 
87
+ /**
88
+ * @override
89
+ */
73
90
  public error(msg: string, options?: NotificationOptions): void {
74
91
  this.antds.message?.error({
75
92
  content: options?.error ? this.formatErrorMessage(options.error) : msg,
@@ -77,14 +94,23 @@ export class DialogHandler
77
94
  });
78
95
  }
79
96
 
97
+ /**
98
+ * @override
99
+ */
80
100
  public info(msg: string, options?: NotificationOptions): void {
81
101
  this.antds.message?.info({ content: msg, ...options });
82
102
  }
83
103
 
104
+ /**
105
+ * @override
106
+ */
84
107
  public warn(msg: string, options?: NotificationOptions): void {
85
108
  this.antds.message?.warning({ content: msg, ...options });
86
109
  }
87
110
 
111
+ /**
112
+ * @override
113
+ */
88
114
  public confirm(options: DialogHandlerOptions): void {
89
115
  this.antds.modal?.confirm(options);
90
116
  }