Skip to content

Commit 3bf5400

Browse files
author
aXenDeveloper
committed
refactor(admin, auth): 🔄 restructure transport and session handling
1 parent 106cfd0 commit 3bf5400

32 files changed

Lines changed: 1025 additions & 289 deletions

‎apps/web/src/components/admin-shell.tsx‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import type { AdminUserSearch } from '@vitnode/core/tanstack/admin'
2-
31
import { AdminShellContent } from '@vitnode/core/tanstack/admin'
42
import { useAppNavigate } from '@vitnode/core/tanstack/auth'
53
import { LanguageSwitcher } from '@vitnode/core/tanstack/layout'
64

75
import { adminNav } from '@/lib/admin-nav'
8-
import { adminUserSearchFn } from '@/lib/admin-search'
9-
10-
const searchUsers: AdminUserSearch = async (search) =>
11-
await adminUserSearchFn({ data: { search } })
126

137
export const AdminShell = ({ children }: { children: React.ReactNode }) => {
148
const navigate = useAppNavigate()
@@ -20,7 +14,6 @@ export const AdminShell = ({ children }: { children: React.ReactNode }) => {
2014
onNavigate={(href) => {
2115
void navigate(href)
2216
}}
23-
searchUsers={searchUsers}
2417
>
2518
{children}
2619
</AdminShellContent>

‎apps/web/src/lib/admin-auth.ts‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎apps/web/src/lib/admin-search.ts‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎apps/web/src/lib/auth.ts‎

Lines changed: 0 additions & 73 deletions
This file was deleted.

‎apps/web/src/router.tsx‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ import {
1515
pluginRouteSpecs,
1616
withPluginRoutes,
1717
} from '@vitnode/core/tanstack/plugin-routes'
18-
19-
import './lib/auth'
20-
import './lib/admin-auth'
2118
import {
2219
withCoreAdminRoutes,
2320
withCoreMainRoutes,

‎packages/create-vitnode-app/copy-of-vitnode-app/root/src/components/admin-shell.tsx‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import type { AdminUserSearch } from "@vitnode/core/tanstack/admin";
2-
31
import { AdminShellContent } from "@vitnode/core/tanstack/admin";
42
import { useAppNavigate } from "@vitnode/core/tanstack/auth";
53
import { LanguageSwitcher } from "@vitnode/core/tanstack/layout";
64

75
import { adminNav } from "@/lib/admin-nav";
8-
import { adminUserSearchFn } from "@/lib/admin-search";
9-
10-
const searchUsers: AdminUserSearch = async search =>
11-
await adminUserSearchFn({ data: { search } });
126

137
export const AdminShell = ({ children }: { children: React.ReactNode }) => {
148
const navigate = useAppNavigate();
@@ -20,7 +14,6 @@ export const AdminShell = ({ children }: { children: React.ReactNode }) => {
2014
onNavigate={href => {
2115
void navigate(href);
2216
}}
23-
searchUsers={searchUsers}
2417
>
2518
{children}
2619
</AdminShellContent>

‎packages/create-vitnode-app/copy-of-vitnode-app/root/src/lib/admin-auth.ts‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎packages/create-vitnode-app/copy-of-vitnode-app/root/src/lib/admin-search.ts‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎packages/create-vitnode-app/copy-of-vitnode-app/root/src/lib/auth.ts‎

Lines changed: 0 additions & 73 deletions
This file was deleted.

‎packages/create-vitnode-app/copy-of-vitnode-app/root/src/lib/i18n.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/**
2+
* The one bootstrap adapter this application still owns.
3+
*
4+
* Auth, the AdminCP session and the AdminCP user search all reach the API
5+
* through `@vitnode/core`'s own default transports now, so none of them needs a
6+
* module here. Messages cannot work that way, for two reasons that only hold
7+
* in app source:
8+
*
9+
* - `loadIntlMessages` reads *this* application's locale barrels, which are the
10+
* app's own files plus whichever packages it installed. A package cannot know
11+
* them.
12+
* - `createServerFn` is extracted by the TanStack Start compiler, and the
13+
* compiler only runs over the application's source. `@vitnode/core` ships
14+
* precompiled, so a server function declared there would never have its
15+
* handler extracted and would resolve to `undefined` at runtime.
16+
*
17+
* `configureIntl` is where the two meet: the app hands core the fetch and its
18+
* configured languages, and everything else in the package reads them back
19+
* through `getIntlRuntime()`.
20+
*/
121
import { createServerFn } from "@tanstack/react-start";
222
import { configureIntl, validateIntlInput } from "@vitnode/core/tanstack/i18n";
323
import { IntlProvider } from "use-intl";

0 commit comments

Comments
 (0)