diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-12-07 03:24:42 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-12-07 03:24:46 +0900 |
| commit | 26df54a09d7e195d0e33266e0b34f8e11d072277 (patch) | |
| tree | ca7f47d8beb4fcea7419350852b845b8a3179ec1 /src/client/api | |
| parent | 39deb471d976d863d2ec803f908025a2366f1486 (diff) | |
| download | kioku-26df54a09d7e195d0e33266e0b34f8e11d072277.tar.gz kioku-26df54a09d7e195d0e33266e0b34f8e11d072277.tar.zst kioku-26df54a09d7e195d0e33266e0b34f8e11d072277.zip | |
feat(client): remove registration page
Diffstat (limited to 'src/client/api')
| -rw-r--r-- | src/client/api/client.test.ts | 58 | ||||
| -rw-r--r-- | src/client/api/client.ts | 7 | ||||
| -rw-r--r-- | src/client/api/index.ts | 8 | ||||
| -rw-r--r-- | src/client/api/types.ts | 4 |
4 files changed, 1 insertions, 76 deletions
diff --git a/src/client/api/client.test.ts b/src/client/api/client.test.ts index 3cfe190..16deb28 100644 --- a/src/client/api/client.test.ts +++ b/src/client/api/client.test.ts @@ -56,63 +56,6 @@ describe("ApiClient", () => { vi.restoreAllMocks(); }); - describe("register", () => { - it("sends registration request without auth header", async () => { - const mockStorage = createMockTokenStorage(); - const client = new ApiClient({ - tokenStorage: mockStorage, - baseUrl: "http://localhost:3000", - }); - - const responseBody = { user: { id: "123", username: "testuser" } }; - global.fetch = mockFetch([{ status: 201, body: responseBody }]); - - const result = await client.register("testuser", "password123"); - - expect(result).toEqual(responseBody); - expect(global.fetch).toHaveBeenCalledWith( - "http://localhost:3000/api/auth/register", - expect.objectContaining({ - method: "POST", - body: JSON.stringify({ - username: "testuser", - password: "password123", - }), - }), - ); - - const call = (global.fetch as Mock).mock.calls[0] as [ - string, - RequestInit, - ]; - const headers = call[1].headers as Record<string, string>; - expect(headers.Authorization).toBeUndefined(); - }); - - it("throws ApiClientError on registration failure", async () => { - const mockStorage = createMockTokenStorage(); - const client = new ApiClient({ tokenStorage: mockStorage }); - - global.fetch = mockFetch([ - { - status: 409, - body: { error: "Username already exists", code: "USERNAME_EXISTS" }, - }, - ]); - - try { - await client.register("testuser", "password"); - expect.fail("Expected ApiClientError to be thrown"); - } catch (e) { - expect(e).toBeInstanceOf(ApiClientError); - const error = e as ApiClientError; - expect(error.message).toBe("Username already exists"); - expect(error.status).toBe(409); - expect(error.code).toBe("USERNAME_EXISTS"); - } - }); - }); - describe("login", () => { it("sends login request and stores tokens", async () => { const mockStorage = createMockTokenStorage(); @@ -223,7 +166,6 @@ describe("ApiClient", () => { // RPC client should have auth routes expect(client.rpc.api.auth.login).toBeDefined(); - expect(client.rpc.api.auth.register).toBeDefined(); expect(client.rpc.api.auth.refresh).toBeDefined(); }); }); diff --git a/src/client/api/client.ts b/src/client/api/client.ts index f9b8a61..36a7431 100644 --- a/src/client/api/client.ts +++ b/src/client/api/client.ts @@ -119,13 +119,6 @@ export class ApiClient { } } - async register(username: string, password: string) { - const res = await this.rpc.api.auth.register.$post({ - json: { username, password }, - }); - return this.handleResponse<{ user: { id: string; username: string } }>(res); - } - async login(username: string, password: string): Promise<AuthResponse> { const res = await this.rpc.api.auth.login.$post({ json: { username, password }, diff --git a/src/client/api/index.ts b/src/client/api/index.ts index 2d95c14..fb26b70 100644 --- a/src/client/api/index.ts +++ b/src/client/api/index.ts @@ -6,10 +6,4 @@ export { localStorageTokenStorage, type TokenStorage, } from "./client"; -export type { - ApiError, - AuthResponse, - RegisterResponse, - Tokens, - User, -} from "./types"; +export type { ApiError, AuthResponse, Tokens, User } from "./types"; diff --git a/src/client/api/types.ts b/src/client/api/types.ts index 1ba3624..d5df182 100644 --- a/src/client/api/types.ts +++ b/src/client/api/types.ts @@ -9,10 +9,6 @@ export interface AuthResponse { user: User; } -export interface RegisterResponse { - user: User; -} - export interface ApiError { error: string; code?: string; |
