Auth: document an import for the generated Better Auth tables (`userTable`, …)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 62/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- sqlite, typescript
- Ambito
- backend, database, documentation
Direzione di ricerca
Documenta .void/better-auth-schema.ts e i suoi export (userTable, sessionTable, accountTable, verificationTable) nella guida all'autenticazione, con un esempio di chiave esterna verso userTable.id. Inizia dalla documentazione di autenticazione esistente, dove sono descritti i tipi AuthUser e AuthSession di void/auth, e aggiungi una sezione per le tabelle. Il lavoro è completo quando la guida mostra il percorso di import, indica gli export stabili e include l'esempio. La proposta di import pubblico resta una decisione dei maintainer.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Void generates the Better Auth tables into .void/better-auth-schema.ts (userTable, sessionTable, accountTable, verificationTable), but the docs never say how to import them. The auth guide documents the AuthUser and AuthSession types from void/auth, but not the tables.
An app that queries its users, or has a table that belongs to a user, needs those tables. Today the only way to get them is to point at the generated file yourself, and a release that renames the file or its exports breaks that app without warning.
Example
An admin page that lists users:
// tsconfig.json: our own alias, next to the `@schema` one Void configures
"paths": {
"@auth-schema": ["./.void/better-auth-schema.ts"]
}
// src/server/data/users.ts
import { userTable } from '@auth-schema';
import { db, desc } from 'void/db';
export function listUsers() {
return db.select().from(userTable).orderBy(desc(userTable.createdAt));
}
A table whose rows belong to a user needs the same import for its foreign key:
// db/schema.ts
import { userTable } from '@auth-schema';
import { sqliteTable, text } from 'void/schema-d1';
export const postTable = sqliteTable('post', {
id: text('id').primaryKey(),
userId: text('user_id')
.notNull()
.references(() => userTable.id, { onDelete: 'cascade' }),
});
Why it matters
- Users are app data too. Admin lists, "posts by this user" joins and foreign keys from app tables all need the table, not just the
AuthUsertype. - The generated file looks internal. It sits in
.void/with "Auto-generated by void — do not edit" at the top, so nothing tells an app it's safe to import. Its path and export names aren't documented, so an app can't tell what a release may change. - The tables already include the app's own columns. The generated
userTablehas the columns from Better Auth plugins anduser.additionalFields(such asroleandbannedfromadmin()), so it's the right table to query. Copying it by hand would drift.
Proposal
In order of preference:
- A public import, for example
import { userTable } from 'void/auth/schema', typed for the app's dialect and plugins. - An auto-configured alias, like the existing
@schemafordb/schema.ts. - At minimum, document
.void/better-auth-schema.tsand its export names as stable, with an example of a foreign key touserTable.idin the database or auth guide.
Environment
void1.5.0- D1 with Better Auth's
admin()plugin
- Lingua principale
- TypeScript
- Stelle
- 627
- Fork
- 66
- Merge medio
- 14h 56m
- PR unite (30g)
- 170
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di voidzero-dev/void
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
voidzero-dev/void#680 ·
I maintainer di solito rispondono entro 1 giorno
-
`withValidator({ body })` rejects the multipart bodies that `useForm` and `action()` send for filesAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
voidzero-dev/void#679 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
voidzero-dev/void#676 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
voidzero-dev/void#667 ·
I maintainer di solito rispondono entro 1 giorno
-
platform: interrupted install ignores a replacement runtime token and never updates deployed WorkersAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
voidzero-dev/void#666 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di voidzero-dev/void
Issue simili
-
mobile-app
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
Open-Locker/Open-Locker#352 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
leanprover-community/lean4game#589 ·
I maintainer di solito rispondono entro 2 giorni
-
Add: CS Action BGApertacheck:passed streams:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
unocss/unocss#5421 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno