-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Post creation and getting all posts work well
- Loading branch information
Showing
20 changed files
with
331 additions
and
133 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './create-post.usecase'; | ||
export * from './create-post.use-case'; | ||
export * from './create-post.request'; |
25 changes: 15 additions & 10 deletions
25
server/src/application/post/find-all/find-all-post.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,34 @@ | ||
import { InvalidParameterException } from "@domain/shared/exceptions"; | ||
import { EnumValueObject } from "@domain/shared/value-object/enum-value-object"; | ||
|
||
enum POST_STATUS { | ||
DRAFT = 'draft', | ||
PUBLISHED = 'published', | ||
} | ||
|
||
export { POST_STATUS }; | ||
class PostStatus extends EnumValueObject<POST_STATUS> { | ||
protected throwErrorForInvalidValue(value: POST_STATUS): void { | ||
throw new InvalidParameterException(`The status ${value} is invalid`); | ||
} | ||
constructor(value: POST_STATUS) { | ||
super(value, Object.values(POST_STATUS)); | ||
} | ||
|
||
public static fromValue(value: string): PostStatus { | ||
switch (value) { | ||
case POST_STATUS.DRAFT: { | ||
return new PostStatus(POST_STATUS.DRAFT); | ||
} | ||
case POST_STATUS.PUBLISHED: { | ||
return new PostStatus(POST_STATUS.PUBLISHED); | ||
} | ||
default: { | ||
throw new Error(`The status ${value} is invalid`); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
export { PostStatus }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.