update: playwright and solid, tanstack-start exmaple
Run Tests / test (push) Successful in 6m46s

This commit is contained in:
2026-09-28 18:42:26 +05:30
parent dfa37b5244
commit a0454f82d6
10 changed files with 87 additions and 89 deletions
-55
View File
@@ -1,55 +0,0 @@
import { em, entity, text, boolean } from "userbase";
import { registerLocalMediaAdapter } from "userbase/adapter/node";
import { TanstackStartConfig } from "userbase/adapter/tanstack-start";
const local = registerLocalMediaAdapter();
const schema = em({
todos: entity("todos", {
title: text(),
done: boolean(),
}),
});
// register your schema to get automatic type completion
type Database = (typeof schema)["DB"];
declare module "userbase" {
interface DB extends Database {}
}
export default {
connection: {
url: "file:data.db",
},
options: {
// the seed option is only executed if the database was empty
seed: async (ctx) => {
// create some entries
await ctx.em.mutator("todos").insertMany([
{ title: "Learn userbase", done: true },
{ title: "Build something cool", done: false },
]);
// and create a user
await ctx.app.module.auth.createUser({
email: "test@userbase.io",
password: "12345678",
});
},
},
config: {
data: schema.toJSON(),
auth: {
enabled: true,
jwt: {
secret: "random_gibberish_please_change_this",
},
},
media: {
enabled: true,
adapter: local({
path: "./public/uploads",
}),
},
},
} satisfies TanstackStartConfig;
+22 -22
View File
@@ -9,24 +9,19 @@
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
import { Route as rootRouteImport } from './routes/__root'
import { Route as SsrRouteImport } from './routes/ssr'
import { Route as IndexRouteImport } from './routes/index'
import { Route as ApiSplatRouteImport } from './routes/api.$'
import { Route as SsrRouteImport } from './routes/ssr'
import { Route as AdminSplatRouteImport } from './routes/admin.$'
import { Route as ApiSplatRouteImport } from './routes/api.$'
const SsrRoute = SsrRouteImport.update({
id: '/ssr',
path: '/ssr',
getParentRoute: () => rootRouteImport,
} as any)
const IndexRoute = IndexRouteImport.update({
id: '/',
path: '/',
getParentRoute: () => rootRouteImport,
} as any)
const ApiSplatRoute = ApiSplatRouteImport.update({
id: '/api/$',
path: '/api/$',
const SsrRoute = SsrRouteImport.update({
id: '/ssr',
path: '/ssr',
getParentRoute: () => rootRouteImport,
} as any)
const AdminSplatRoute = AdminSplatRouteImport.update({
@@ -34,6 +29,11 @@ const AdminSplatRoute = AdminSplatRouteImport.update({
path: '/admin/$',
getParentRoute: () => rootRouteImport,
} as any)
const ApiSplatRoute = ApiSplatRouteImport.update({
id: '/api/$',
path: '/api/$',
getParentRoute: () => rootRouteImport,
} as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
@@ -71,13 +71,6 @@ export interface RootRouteChildren {
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
'/ssr': {
id: '/ssr'
path: '/ssr'
fullPath: '/ssr'
preLoaderRoute: typeof SsrRouteImport
parentRoute: typeof rootRouteImport
}
'/': {
id: '/'
path: '/'
@@ -85,11 +78,11 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof IndexRouteImport
parentRoute: typeof rootRouteImport
}
'/api/$': {
id: '/api/$'
path: '/api/$'
fullPath: '/api/$'
preLoaderRoute: typeof ApiSplatRouteImport
'/ssr': {
id: '/ssr'
path: '/ssr'
fullPath: '/ssr'
preLoaderRoute: typeof SsrRouteImport
parentRoute: typeof rootRouteImport
}
'/admin/$': {
@@ -99,6 +92,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AdminSplatRouteImport
parentRoute: typeof rootRouteImport
}
'/api/$': {
id: '/api/$'
path: '/api/$'
fullPath: '/api/$'
preLoaderRoute: typeof ApiSplatRouteImport
parentRoute: typeof rootRouteImport
}
}
}
+3 -3
View File
@@ -8,7 +8,7 @@ import { Footer } from "@/components/Footer";
import { List } from "@/components/List";
export const completeTodo = createServerFn({ method: "POST" })
.inputValidator(
.validator(
(data) => data as { done: boolean; id: number; title: string },
)
.handler(async ({ data: todo }) => {
@@ -24,7 +24,7 @@ export const completeTodo = createServerFn({ method: "POST" })
});
export const deleteTodo = createServerFn({ method: "POST" })
.inputValidator((data) => data as { id: number })
.validator((data) => data as { id: number })
.handler(async ({ data }) => {
try {
const api = await getApi({});
@@ -36,7 +36,7 @@ export const deleteTodo = createServerFn({ method: "POST" })
});
export const createTodo = createServerFn({ method: "POST" })
.inputValidator((data) => data as { title: string })
.validator((data) => data as { title: string })
.handler(async ({ data }) => {
try {
const api = await getApi({});
@@ -0,0 +1,55 @@
import { em, entity, text, boolean } from "userbase";
import { registerLocalMediaAdapter } from "userbase/adapter/node";
import type { TanstackStartConfig } from "userbase/adapter/tanstack-start";
const local = registerLocalMediaAdapter();
const schema = em({
todos: entity("todos", {
title: text(),
done: boolean(),
}),
});
// register your schema to get automatic type completion
type Database = (typeof schema)["DB"];
declare module "userbase" {
interface DB extends Database {}
}
export default {
connection: {
url: "file:data.db",
},
options: {
// the seed option is only executed if the database was empty
seed: async (ctx) => {
// create some entries
await ctx.em.mutator("todos").insertMany([
{ title: "Learn userbase", done: true },
{ title: "Build something cool", done: false },
]);
// and create a user
await ctx.app.module.auth.createUser({
email: "test@userbase.io",
password: "12345678",
});
},
},
config: {
data: schema.toJSON(),
auth: {
enabled: true,
jwt: {
secret: "random_gibberish_please_change_this",
},
},
media: {
enabled: true,
adapter: local({
path: "./public/uploads",
}),
},
},
} satisfies TanstackStartConfig;
+1 -1
View File
@@ -3,7 +3,7 @@ import { devtools } from "@tanstack/devtools-vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import viteReact from "@vitejs/plugin-react";
import viteTsConfigPaths from "vite-tsconfig-paths";
import { fileURLToPath, URL } from "url";
import { fileURLToPath, URL } from "node:url";
import tailwindcss from "@tailwindcss/vite";
import { nitro } from "nitro/vite";