BLOG-126 Post management (list and create) #139
@ -11,8 +11,7 @@ Sentry.init({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const handle: Handle = sequence(Sentry.sentryHandle(), ({ event, resolve }) => {
|
export const handle: Handle = sequence(Sentry.sentryHandle(), ({ event, resolve }) => {
|
||||||
const container = new Container(event.fetch);
|
event.locals.container ??= new Container(event.fetch);
|
||||||
event.locals.container = container;
|
|
||||||
|
|
||||||
return resolve(event);
|
return resolve(event);
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
import { AuthViewModel } from '$lib/auth/adapter/presenter/authViewModel';
|
import { AuthViewModel } from '$lib/auth/adapter/presenter/authViewModel';
|
||||||
import { UserViewModel } from '$lib/auth/adapter/presenter/userViewModel';
|
import { UserViewModel } from '$lib/auth/adapter/presenter/userViewModel';
|
||||||
import type { GetCurrentUserUseCase } from '$lib/auth/application/useCase/getCurrentUserUseCase';
|
import type { GetCurrentUserUseCase } from '$lib/auth/application/useCase/getCurrentUserUseCase';
|
||||||
import {
|
import { StateFactory, type AsyncState } from '$lib/common/adapter/presenter/asyncState';
|
||||||
StateFactory,
|
|
||||||
StatusType,
|
|
||||||
type AsyncState,
|
|
||||||
} from '$lib/common/adapter/presenter/asyncState';
|
|
||||||
import { captureException } from '@sentry/sveltekit';
|
import { captureException } from '@sentry/sveltekit';
|
||||||
import { get, writable } from 'svelte/store';
|
import { get, writable } from 'svelte/store';
|
||||||
|
|
||||||
@ -13,9 +9,7 @@ export type AuthState = AsyncState<AuthViewModel>;
|
|||||||
export type AuthEvent = CurrentUserLoadedEvent;
|
export type AuthEvent = CurrentUserLoadedEvent;
|
||||||
|
|
||||||
export class AuthBloc {
|
export class AuthBloc {
|
||||||
private readonly state = writable<AuthState>({
|
private readonly state = writable<AuthState>(StateFactory.idle());
|
||||||
status: StatusType.Idle,
|
|
||||||
});
|
|
||||||
|
|
||||||
constructor(private readonly getCurrentUserUseCase: GetCurrentUserUseCase) {}
|
constructor(private readonly getCurrentUserUseCase: GetCurrentUserUseCase) {}
|
||||||
|
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
import {
|
import { StateFactory, type AsyncState } from '$lib/common/adapter/presenter/asyncState';
|
||||||
StateFactory,
|
|
||||||
StatusType,
|
|
||||||
type AsyncState,
|
|
||||||
} from '$lib/common/adapter/presenter/asyncState';
|
|
||||||
import { ImageInfoViewModel } from '$lib/image/adapter/presenter/imageInfoViewModel';
|
import { ImageInfoViewModel } from '$lib/image/adapter/presenter/imageInfoViewModel';
|
||||||
import type { UploadImageUseCase } from '$lib/image/application/useCase/uploadImageUseCase';
|
import type { UploadImageUseCase } from '$lib/image/application/useCase/uploadImageUseCase';
|
||||||
import { captureException } from '@sentry/sveltekit';
|
import { captureException } from '@sentry/sveltekit';
|
||||||
@ -12,9 +8,7 @@ export type ImageInfoState = AsyncState<ImageInfoViewModel>;
|
|||||||
export type ImageEvent = ImageUploadedEvent;
|
export type ImageEvent = ImageUploadedEvent;
|
||||||
|
|
||||||
export class ImageBloc {
|
export class ImageBloc {
|
||||||
private readonly state = writable<ImageInfoState>({
|
private readonly state = writable<ImageInfoState>(StateFactory.idle());
|
||||||
status: StatusType.Idle,
|
|
||||||
});
|
|
||||||
|
|
||||||
constructor(private readonly uploadImageUseCase: UploadImageUseCase) {}
|
constructor(private readonly uploadImageUseCase: UploadImageUseCase) {}
|
||||||
|
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
import {
|
import { StateFactory, type AsyncState } from '$lib/common/adapter/presenter/asyncState';
|
||||||
StateFactory,
|
|
||||||
StatusType,
|
|
||||||
type AsyncState,
|
|
||||||
} from '$lib/common/adapter/presenter/asyncState';
|
|
||||||
import { PostViewModel } from '$lib/post/adapter/presenter/postViewModel';
|
import { PostViewModel } from '$lib/post/adapter/presenter/postViewModel';
|
||||||
import type { CreatePostParams } from '$lib/post/application/gateway/postRepository';
|
import type { CreatePostParams } from '$lib/post/application/gateway/postRepository';
|
||||||
import type { CreatePostUseCase } from '$lib/post/application/useCase/createPostUseCase';
|
import type { CreatePostUseCase } from '$lib/post/application/useCase/createPostUseCase';
|
||||||
@ -14,19 +10,14 @@ export type PostState = AsyncState<PostViewModel>;
|
|||||||
export type PostEvent = PostLoadedEvent | PostCreatedEvent;
|
export type PostEvent = PostLoadedEvent | PostCreatedEvent;
|
||||||
|
|
||||||
export class PostBloc {
|
export class PostBloc {
|
||||||
private readonly state = writable<PostState>({
|
private readonly state = writable<PostState>(StateFactory.idle());
|
||||||
status: StatusType.Idle,
|
|
||||||
});
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly getPostUseCase: GetPostUseCase,
|
private readonly getPostUseCase: GetPostUseCase,
|
||||||
private readonly createPostUseCase: CreatePostUseCase,
|
private readonly createPostUseCase: CreatePostUseCase,
|
||||||
initialData?: PostViewModel
|
initialData?: PostViewModel
|
||||||
) {
|
) {
|
||||||
this.state.set({
|
this.state.set(StateFactory.idle(initialData));
|
||||||
status: StatusType.Idle,
|
|
||||||
data: initialData,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get subscribe() {
|
get subscribe() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user