Skip to content

Commit

Permalink
rename: discover api 관련 데이터 변수명 변경
Browse files Browse the repository at this point in the history
* discover -> filter로 변수명 변경
  • Loading branch information
ag502 committed Nov 9, 2024
1 parent 7cdd941 commit 4af5f79
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import {
DiscoveredMovieList,
discoveredMovieListQuerySchema,
SDiscoveredMovieListReqParams,
} from "@/entities/discover";
import { tmdbHttpServer, withCommonRoute } from "@/shared/api";
import { camelCaseObjMapper } from "@/shared/lib";

import {
FilteredMovieList,
filteredMovieListQuerySchema,
SFilteredMovieListReqParams,
} from "../../../src/entities/filter";

export default withCommonRoute(
async (req, res) => {
const queries = req.query as unknown as SDiscoveredMovieListReqParams;
const queries = req.query as unknown as SFilteredMovieListReqParams;

const result = await tmdbHttpServer.get<DiscoveredMovieList>("discover/movie", {
const result = await tmdbHttpServer.get<FilteredMovieList>("discover/movie", {
params: {
certification_country: queries.certificationCountry,
include_adult: queries.includeAdult,
Expand All @@ -36,5 +37,5 @@ export default withCommonRoute(
return res.status(200).send(camelCaseObjMapper(result.data));
},
["GET"],
discoveredMovieListQuerySchema,
filteredMovieListQuerySchema,
);
7 changes: 0 additions & 7 deletions apps/web/src/entities/discover/api/queries/query-keys.ts

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions apps/web/src/entities/discover/api/request-types/movie.ts

This file was deleted.

3 changes: 0 additions & 3 deletions apps/web/src/entities/discover/api/response-types/movie.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { AxiosRequestConfig } from "axios";

import { DiscoveredMovieListDTO } from "@/entities/discover";
import { DiscoveredMovieListReqParams } from "@/entities/discover/api/request-types/movie";
import { FilteredMovieListDTO } from "@/entities/filter";
import { FilteredMovieListReqParams } from "@/entities/filter/api/request-types/movie";
import { localHttp } from "@/shared/api";

const discoverBaseURL = "discover";
const discoverBaseURL = "filter";

export default class DiscoverApi {
export default class FilterApi {
/**
* 영화 필터
*/
static async getFilterMovies(
args: DiscoveredMovieListReqParams,
args: FilteredMovieListReqParams,
axiosRequestConfig?: AxiosRequestConfig,
): Promise<DiscoveredMovieListDTO> {
): Promise<FilteredMovieListDTO> {
return localHttp
.get(`${discoverBaseURL}/movie`, {
params: args,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./request-types";
export * from "./response-types";
export * from "./discover-api";
export * from "./filter-api";
6 changes: 6 additions & 0 deletions apps/web/src/entities/filter/api/queries/query-keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { FilteredMovieListReqParams } from "@/entities/filter/api/request-types/movie";

export const filteredMediaListQueryKeys = {
all: ["filter"] as const,
filteredMovieList: (args: FilteredMovieListReqParams) => ["filtered-movie-list", { ...args }] as const,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useQuery } from "@tanstack/react-query";

import FilterApi from "@/entities/filter/api/filter-api";
import { filteredMediaListQueryKeys } from "@/entities/filter/api/queries/query-keys";
import { FilteredMovieListReqParams } from "@/entities/filter/api/request-types/movie";
import FilteredMovieListModel from "@/entities/filter/model/filtered-movie-list";

export const useFilteredMovieList = (args: FilteredMovieListReqParams = {}) => {
const { page = 1, watchRegion = "KR", certificationCountry = "KR", language = "ko-KR", ...restArgs } = args;

const reqArgs = {
page,
watchRegion,
certificationCountry,
language,
...restArgs,
};

return useQuery({
queryKey: [...filteredMediaListQueryKeys.all, ...filteredMediaListQueryKeys.filteredMovieList(reqArgs)],
queryFn: () => FilterApi.getFilterMovies(reqArgs),
select: (data) => new FilteredMovieListModel(data),
});
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from "zod";

export const discoveredMovieListQuerySchema = z.object({
export const filteredMovieListQuerySchema = z.object({
certificationCountry: z.string().optional(),
includeAdult: z.coerce.boolean().optional(),
includeVideo: z.coerce.boolean().optional(),
Expand Down Expand Up @@ -46,4 +46,4 @@ export const discoveredMovieListQuerySchema = z.object({
* 6 - TV
* ```
*/
export type SDiscoveredMovieListReqParams = z.infer<typeof discoveredMovieListQuerySchema>;
export type SFilteredMovieListReqParams = z.infer<typeof filteredMovieListQuerySchema>;
3 changes: 3 additions & 0 deletions apps/web/src/entities/filter/api/request-types/movie.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { SFilteredMovieListReqParams } from "../.";

export interface FilteredMovieListReqParams extends SFilteredMovieListReqParams {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { MovieList } from "@/entities/movie-list/api/response-types/movie-list.server";

export interface DiscoveredMovieList extends MovieList {}
export interface FilteredMovieList extends MovieList {}
3 changes: 3 additions & 0 deletions apps/web/src/entities/filter/api/response-types/movie.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { MovieListDTO } from "@/entities/movie-list";

export interface FilteredMovieListDTO extends MovieListDTO {}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MovieListDTO, MovieListModel } from "@/entities/movie-list";

export default class DiscoveredMovieListModel extends MovieListModel {
export default class FilteredMovieListModel extends MovieListModel {
constructor(data: MovieListDTO) {
super(data);
}
Expand Down
File renamed without changes.

0 comments on commit 4af5f79

Please sign in to comment.