diff --git a/src/App.tsx b/src/App.tsx index 60fe93f..374da9b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,13 +1,16 @@ import { BrowserRouter, Route, Routes } from 'react-router' import HomePage from './pages/HomePage.tsx' -import { PostsService } from './model/posts/postsService.ts' +import { PostsService } from './feed/models/posts/postsService.ts' import AuthorPage from './pages/AuthorPage.tsx' -import { MediaService } from './model/mediaService.ts' +import { MediaService } from './model/media/mediaService.ts' import SignupPage from './pages/SignupPage.tsx' +import LoginPage from './pages/LoginPage.tsx' +import { AuthService } from './auth/authService.ts' function App() { const postService = new PostsService() const mediaService = new MediaService() + const authService = new AuthService() return ( @@ -17,6 +20,7 @@ function App() { element={} /> } /> + } /> } /> diff --git a/src/api/api.ts b/src/api/api.ts index 08e0912..012dedd 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -6,25 +6,15 @@ const ApiHost = `http://${location.hostname}:5181` console.debug('API HOST IS', ApiHost) -export async function loadPostsForAuthor( - authorId: string, - cursor: string | null, - amount: number | null, -): Promise { - const url = new URL(`authors/${authorId}/posts`, ApiHost) - if (amount != null) url.searchParams.set('amount', amount.toString()) - if (cursor != null) url.searchParams.set('from', cursor) - const res = await doGetRequest(url) - return res as components['schemas']['GetAuthorPostsResponse'] -} - export async function loadPublicFeed( cursor: string | null, amount: number | null, + author: string | null, ): Promise { const url = new URL(`posts`, ApiHost) if (amount != null) url.searchParams.set('amount', amount.toString()) if (cursor != null) url.searchParams.set('from', cursor) + if (author != null) url.searchParams.set('author', author) const res = await doGetRequest(url) @@ -51,7 +41,7 @@ export async function uploadMedia( export async function createPost( authorId: string, content: string, - media: string[], + media: components['schemas']['CreatePostRequestMedia'][], ): Promise { const url = new URL('posts', ApiHost) const body: components['schemas']['CreatePostRequest'] = { diff --git a/src/api/schema.ts b/src/api/schema.ts index cc2f120..c4f87e2 100644 --- a/src/api/schema.ts +++ b/src/api/schema.ts @@ -11,6 +11,8 @@ export interface paths { query?: { From?: string Amount?: number + AuthorId?: string + Author?: string } header?: never path?: never @@ -145,71 +147,26 @@ export interface paths { patch?: never trace?: never } - '/authors/{username}/posts': { - parameters: { - query?: never - header?: never - path?: never - cookie?: never - } - get: { - parameters: { - query?: { - From?: string - Amount?: number - } - header?: never - path: { - username: string - } - cookie?: never - } - requestBody?: never - responses: { - /** @description OK */ - 200: { - headers: { - [name: string]: unknown - } - content: { - 'text/plain': components['schemas']['GetAuthorPostsResponse'] - 'application/json': components['schemas']['GetAuthorPostsResponse'] - 'text/json': components['schemas']['GetAuthorPostsResponse'] - } - } - } - } - put?: never - post?: never - delete?: never - options?: never - head?: never - patch?: never - trace?: never - } } export type webhooks = Record export interface components { schemas: { - AuthoPostAuthorDto: { - /** Format: uuid */ - authorId: string - username: string - } - AuthorPostDto: { - /** Format: uuid */ - postId: string - content: string - media: string[] - /** Format: date-time */ - createdAt: string - author: components['schemas']['AuthoPostAuthorDto'] - } CreatePostRequest: { /** Format: uuid */ authorId: string content: string - media: string[] + media: components['schemas']['CreatePostRequestMedia'][] + } + CreatePostRequestMedia: { + /** Format: uuid */ + mediaId: string + /** Format: uri */ + url: string + type: string | null + /** Format: int32 */ + width: number | null + /** Format: int32 */ + height: number | null } CreatePostResponse: { /** Format: uuid */ @@ -220,11 +177,6 @@ export interface components { /** Format: uuid */ next: string | null } - GetAuthorPostsResponse: { - posts: components['schemas']['AuthorPostDto'][] - /** Format: uuid */ - next: string | null - } PublicPostAuthorDto: { /** Format: uuid */ authorId: string @@ -235,10 +187,18 @@ export interface components { /** Format: uuid */ postId: string content: string - media: string[] + media: components['schemas']['PublicPostMediaDto'][] /** Format: date-time */ createdAt: string } + PublicPostMediaDto: { + /** Format: uri */ + url: string + /** Format: int32 */ + width: number | null + /** Format: int32 */ + height: number | null + } UploadMediaResponse: { /** Format: uuid */ mediaId: string diff --git a/src/auth/authService.ts b/src/auth/authService.ts new file mode 100644 index 0000000..4716131 --- /dev/null +++ b/src/auth/authService.ts @@ -0,0 +1,9 @@ +export class AuthService { + async login(username: string, password: string) { + throw new Error('not implemented') + } + + async signup(username: string, password: string, signupCode: string, email?: string) { + throw new Error('not implemented') + } +} diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index 0150237..a8d70bc 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -1,11 +1,10 @@ -import { Link } from 'react-router' +import NavLinkButton from './NavLinkButton' export default function NavBar() { return ( -