ligun and sogup

This commit is contained in:
john 2025-05-06 16:31:55 +02:00
parent b6633d6f25
commit 4573048a47
24 changed files with 482 additions and 226 deletions

View file

@ -1,36 +0,0 @@
import { Temporal } from '@js-temporal/polyfill'
import { components } from '../../api/schema.ts'
export class Post {
public readonly postId: string
public readonly content: string
public readonly media: URL[]
public readonly createdAt: Temporal.Instant
public readonly authorName: string
constructor(
postId: string,
content: string,
media: URL[],
createdAt: string | Temporal.Instant,
authorName: string,
) {
this.postId = postId
this.content = content
this.media = media
this.createdAt = Temporal.Instant.from(createdAt)
this.authorName = authorName
}
public static fromDto(
dto: components['schemas']['AuthorPostDto'] | components['schemas']['PublicPostDto'],
): Post {
return new Post(
dto.postId,
dto.content,
dto.media.map((url) => new URL(url)),
Temporal.Instant.from(dto.createdAt),
dto.author.username,
)
}
}