feat(api): add better-auth admin plugin + close public sign-up (migration 0002)

This commit is contained in:
Bas van Rossem
2026-06-17 17:36:26 +02:00
parent f6bd8eb036
commit c73fa0f898
7 changed files with 626 additions and 37 deletions

View File

@@ -2,9 +2,7 @@ import { describe, it, expect } from 'vitest';
import { eq } from 'drizzle-orm';
import { db } from '../src/db/client';
import { activities, workSessions, user } from '../src/db/schema';
import { createApp } from '../src/app';
const json = { 'content-type': 'application/json' };
import { createTestUser } from './helpers';
describe('domain schema', () => {
it('creates and reads back an activity with a json insole_types array', async () => {
@@ -20,19 +18,10 @@ describe('domain schema', () => {
});
it('defaults a work_sessions row to status=active, source=app, pair_count=2, null end_time', async () => {
const app = createApp();
const creds = {
email: 'schema-user@example.com',
password: 'sterk-wachtwoord-123',
name: 'Schema User',
};
await app.request('/api/auth/sign-up/email', {
method: 'POST',
headers: json,
body: JSON.stringify(creds),
});
const email = 'schema-user@example.com';
await createTestUser(email);
const [createdUser] = await db.select().from(user).where(eq(user.email, creds.email));
const [createdUser] = await db.select().from(user).where(eq(user.email, email));
expect(createdUser).toBeTruthy();
const [activity] = await db