Skip to content

Commit

Permalink
rmv redundant codes
Browse files Browse the repository at this point in the history
  • Loading branch information
huytran17 committed Sep 7, 2024
1 parent 8b25cfc commit 82ea5f8
Show file tree
Hide file tree
Showing 154 changed files with 310 additions and 390 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HttpStatusCode } from "../../../../constants/http-status-code";
import IAdmin from "../../../../database/interfaces/admin";
import {
CreateCategory,
ICreateCategoryPayload,
ICreateCategory,
} from "../../../../use-cases/category/create-category";

export default function makeCreateCategoryController({
Expand All @@ -23,7 +23,7 @@ export default function makeCreateCategoryController({
};

try {
const category_details = <ICreateCategoryPayload>(
const category_details = <ICreateCategory>(
get(httpRequest, "context.validated", {})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Logger } from "winston";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import {
DeleteCategory,
IDeleteCategoryPayload,
IDeleteCategory,
} from "../../../../use-cases/category/delete-category";
import { GetCategory } from "../../../../use-cases/category/get-category";
import { isEmpty } from "../../../../utils/is-empty";
Expand All @@ -26,7 +26,7 @@ export default function makeDeleteCategoryController({
};

try {
const { _id } = <IDeleteCategoryPayload>(
const { _id } = <IDeleteCategory>(
get(httpRequest, "context.validated", {})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { get, sortBy, split } from "lodash";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import {
GetCategoryAnalystics,
IGetCategoryAnalysticsPayload,
IGetCategoryAnalystics,
} from "../../../../use-cases/category/get-category-analystics";

interface IPayload extends Omit<IGetCategoryAnalysticsPayload, "range"> {
interface IPayload extends Omit<IGetCategoryAnalystics, "range"> {
range?: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { get } from "lodash";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import {
GetCategory,
IGetCategoryPayload,
IGetCategory,
} from "../../../../use-cases/category/get-category";
import { isEmpty } from "../../../../utils/is-empty";

Expand All @@ -20,9 +20,7 @@ export default function makeGetCategoryController({
};

try {
const { _id } = <IGetCategoryPayload>(
get(httpRequest, "context.validated", {})
);
const { _id } = <IGetCategory>get(httpRequest, "context.validated", {});

const exists = await getCategory({ _id });
if (isEmpty(exists)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HttpStatusCode } from "../../../../constants/http-status-code";
import { GetCategory } from "../../../../use-cases/category/get-category";
import {
HardDeleteCategory,
IHardDeleteCategoryPayload,
IHardDeleteCategory,
} from "../../../../use-cases/category/hard-delete-category";
import { isEmpty } from "../../../../utils/is-empty";

Expand All @@ -26,7 +26,7 @@ export default function makeHardDeleteCategoryController({
};

try {
const { _id } = <IHardDeleteCategoryPayload>(
const { _id } = <IHardDeleteCategory>(
get(httpRequest, "context.validated", {})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Logger } from "winston";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import {
GetSoftDeletedCategory,
IGetSoftDeletedCategoryPayload,
IGetSoftDeletedCategory,
} from "../../../../use-cases/category/get-soft-deleted-category";
import { UpdateCategory } from "../../../../use-cases/category/update-category";
import { isEmpty } from "../../../../utils/is-empty";
Expand All @@ -26,7 +26,7 @@ export default function makeRestoreCategoryController({
};

try {
const { _id } = <IGetSoftDeletedCategoryPayload>(
const { _id } = <IGetSoftDeletedCategory>(
get(httpRequest, "context.validated", {})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HttpStatusCode } from "../../../../constants/http-status-code";
import { GetCategory } from "../../../../use-cases/category/get-category";
import { GetCategoryByTitle } from "../../../../use-cases/category/get-category-by-title";
import {
IUpdateCategoryPayload,
IUpdateCategory,
UpdateCategory,
} from "../../../../use-cases/category/update-category";
import { isEmpty } from "../../../../utils/is-empty";
Expand All @@ -29,7 +29,7 @@ export default function makeUpdateCategoryController({
};

try {
const category_details = <IUpdateCategoryPayload>(
const category_details = <IUpdateCategory>(
get(httpRequest, "context.validated", {})
);
const { _id, title } = category_details;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { get } from "lodash";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import {
GetCategory,
IGetCategoryPayload,
IGetCategory,
} from "../../../../use-cases/category/get-category";
import { UpdateCategory } from "../../../../use-cases/category/update-category";
import deleteS3Object from "../../../../utils/delete-s3-object";
Expand All @@ -24,9 +24,7 @@ export default function makeUploadCategoryThumbnailController({
};

try {
const { _id } = <IGetCategoryPayload>(
get(httpRequest, "context.validated", {})
);
const { _id } = <IGetCategory>get(httpRequest, "context.validated", {});

const exists = await getCategory({ _id });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HttpStatusCode } from "../../../../constants/http-status-code";
import { GetComment } from "../../../../use-cases/comment/get-comment";
import {
HardDeleteComment,
IHardDeleteCommentPayload,
IHardDeleteComment,
} from "../../../../use-cases/comment/hard-delete-comment";
import { isEmpty } from "../../../../utils/is-empty";

Expand All @@ -23,7 +23,7 @@ export default function makeDeleteComment({
};

try {
const { _id } = <IHardDeleteCommentPayload>(
const { _id } = <IHardDeleteComment>(
get(httpRequest, "context.validated", {})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HttpStatusCode } from "../../../../constants/http-status-code";
import IAdmin from "../../../../database/interfaces/admin";
import {
CreateGallery,
ICreateGalleryPayload,
ICreateGallery,
} from "../../../../use-cases/gallery/create-gallery";

export default function makeCreateGalleryController({
Expand All @@ -23,7 +23,7 @@ export default function makeCreateGalleryController({
};

try {
const gallery_details = <ICreateGalleryPayload>(
const gallery_details = <ICreateGallery>(
get(httpRequest, "context.validated", {})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HttpStatusCode } from "../../../../constants/http-status-code";
import { GetGalleriesByParent } from "../../../../use-cases/gallery/get-galleries-by-parent";
import {
GetGallery,
IGetGalleryPayload,
IGetGallery,
} from "../../../../use-cases/gallery/get-gallery";
import { isEmpty } from "../../../../utils/is-empty";

Expand All @@ -23,9 +23,7 @@ export default function makeGetGalleriesByParentController({
};

try {
const { _id } = <IGetGalleryPayload>(
get(httpRequest, "context.validated", {})
);
const { _id } = <IGetGallery>get(httpRequest, "context.validated", {});

const exists = await getGallery({ _id });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { get } from "lodash";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import {
GetGalleriesPaginated,
IGetGalleriesPaginatedPayload,
IGetGalleriesPaginated,
} from "../../../../use-cases/gallery/get-galleries-paginated";

export default function makeGetGalleriesPaginatedController({
Expand All @@ -20,7 +20,7 @@ export default function makeGetGalleriesPaginatedController({

try {
const { query, page, entries_per_page, is_parent } = <
IGetGalleriesPaginatedPayload
IGetGalleriesPaginated
>get(httpRequest, "context.validated", {});

const galleries = await getGalleriesPaginated({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { get } from "lodash";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import {
GetGallery,
IGetGalleryPayload,
IGetGallery,
} from "../../../../use-cases/gallery/get-gallery";
import { isEmpty } from "../../../../utils/is-empty";

Expand All @@ -20,9 +20,7 @@ export default function makeGetGalleryController({
};

try {
const { _id } = <IGetGalleryPayload>(
get(httpRequest, "context.validated", {})
);
const { _id } = <IGetGallery>get(httpRequest, "context.validated", {});

const exists = await getGallery({ _id });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HttpStatusCode } from "../../../../constants/http-status-code";
import { GetGallery } from "../../../../use-cases/gallery/get-gallery";
import {
HardDeleteGallery,
IHardDeleteGalleryPayload,
IHardDeleteGallery,
} from "../../../../use-cases/gallery/hard-delete-gallery";
import { isEmpty } from "../../../../utils/is-empty";

Expand All @@ -26,7 +26,7 @@ export default function makeHardDeleteGalleryController({
};

try {
const { _id } = <IHardDeleteGalleryPayload>(
const { _id } = <IHardDeleteGallery>(
get(httpRequest, "context.validated", {})
);
const exists = await getGallery({ _id });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Logger } from "winston";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import { GetGallery } from "../../../../use-cases/gallery/get-gallery";
import {
IUpdateGalleryPayload,
IUpdateGallery,
UpdateGallery,
} from "../../../../use-cases/gallery/update-gallery";
import { isEmpty } from "../../../../utils/is-empty";
Expand All @@ -26,7 +26,7 @@ export default function makeUpdateGalleryController({
};

try {
const gallery_details = <IUpdateGalleryPayload>(
const gallery_details = <IUpdateGallery>(
get(httpRequest, "context.validated", {})
);
const { _id } = gallery_details;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Logger } from "winston";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import {
GetGallery,
IGetGalleryPayload,
IGetGallery,
} from "../../../../use-cases/gallery/get-gallery";
import { UpdateGallery } from "../../../../use-cases/gallery/update-gallery";
import { isEmpty } from "../../../../utils/is-empty";
Expand All @@ -26,9 +26,7 @@ export default function makeUploadGalleryItemController({
};

try {
const { _id } = <IGetGalleryPayload>(
get(httpRequest, "context.validated", {})
);
const { _id } = <IGetGallery>get(httpRequest, "context.validated", {});
const file = get(httpRequest, "context.file", {});

if (isEmpty(file)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Request } from "express";
import { get } from "lodash";
import { Logger } from "winston";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import { GetPost, IGetPostPayload } from "../../../../use-cases/post/get-post";
import { GetPost, IGetPost } from "../../../../use-cases/post/get-post";
import { UpdatePost } from "../../../../use-cases/post/update-post";
import { isEmpty } from "../../../../utils/is-empty";

Expand All @@ -23,9 +23,7 @@ export default function makeBlockPostCommentController({
};

try {
const { _id } = <IGetPostPayload>(
get(httpRequest, "context.validated", {})
);
const { _id } = <IGetPost>get(httpRequest, "context.validated", {});

const exists = await getPost({ _id });
if (isEmpty(exists)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HttpStatusCode } from "../../../../constants/http-status-code";
import IAdmin from "../../../../database/interfaces/admin";
import {
CreatePost,
ICreatePostPayload,
ICreatePost,
} from "../../../../use-cases/post/create-post";
import { GetPost } from "../../../../use-cases/post/get-post";
import { UpdatePost } from "../../../../use-cases/post/update-post";
Expand Down Expand Up @@ -44,7 +44,7 @@ export default function makeCreatePostController({
try {
const admin = <IAdmin>get(httpRequest, "context.user", {});

const post_details = <ICreatePostPayload>(
const post_details = <ICreatePost>(
get(httpRequest, "context.validated", {})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Logger } from "winston";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import {
DeletePost,
IDeletePostPayload,
IDeletePost,
} from "../../../../use-cases/post/delete-post";
import { GetPost } from "../../../../use-cases/post/get-post";
import { isEmpty } from "../../../../utils/is-empty";
Expand All @@ -26,9 +26,7 @@ export default function makeDeletePostController({
};

try {
const { _id } = <IDeletePostPayload>(
get(httpRequest, "context.validated", {})
);
const { _id } = <IDeletePost>get(httpRequest, "context.validated", {});

const exists = await getPost({ _id });
if (isEmpty(exists)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { get, sortBy, split } from "lodash";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import {
GetMostPopularPostsAnalystics,
IGetMostPopularPostsAnalysticsPayload,
IGetMostPopularPostsAnalystics,
} from "../../../../use-cases/post/get-most-popular-posts-analystics";

interface IPayload
extends Omit<IGetMostPopularPostsAnalysticsPayload, "range"> {
interface IPayload extends Omit<IGetMostPopularPostsAnalystics, "range"> {
range?: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { get, sortBy, split } from "lodash";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import {
GetPostAnalystics,
IGetPostAnalysticsPayload,
IGetPostAnalystics,
} from "../../../../use-cases/post/get-post-analystics";
interface IPayload extends Omit<IGetPostAnalysticsPayload, "range"> {
interface IPayload extends Omit<IGetPostAnalystics, "range"> {
range?: string;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request } from "express";
import { get } from "lodash";
import { HttpStatusCode } from "../../../../constants/http-status-code";
import { GetPost, IGetPostPayload } from "../../../../use-cases/post/get-post";
import { GetPost, IGetPost } from "../../../../use-cases/post/get-post";
import { isEmpty } from "../../../../utils/is-empty";

export default function makeGetPostController({
Expand All @@ -17,9 +17,7 @@ export default function makeGetPostController({
};

try {
const { _id } = <IGetPostPayload>(
get(httpRequest, "context.validated", {})
);
const { _id } = <IGetPost>get(httpRequest, "context.validated", {});

const exists = await getPost({ _id });
if (isEmpty(exists)) {
Expand Down
Loading

0 comments on commit 82ea5f8

Please sign in to comment.