Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apps/university-web/src/apis/universities/api.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { DEFAULT_UNIVERSITY_TERM_ID } from "@/constants/university";
import type { HomeUniversityName } from "@/types/university";
import { axiosInstance, publicAxiosInstance } from "@/utils/axiosInstance";

const getClientUniversityTermId = () => {
const termId = Number(process.env.NEXT_PUBLIC_UNIVERSITY_TERM_ID);

return Number.isInteger(termId) && termId > 0 ? termId : DEFAULT_UNIVERSITY_TERM_ID;
return Number.isInteger(termId) && termId > 0 ? termId : undefined;
};

const normalizePositiveInt = (value: unknown) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { URLSearchParams } from "node:url";
import { DEFAULT_UNIVERSITY_TERM_ID } from "@/constants/university";
import type { CountryCode, LanguageTestType, ListUniversity } from "@/types/university";
import serverFetch from "@/utils/serverFetchUtil";
import { assertUniversitySsgResponse } from "./assertUniversitySsgResponse";
Expand All @@ -22,7 +21,7 @@ export interface UniversitySearchFilterParams {
const getUniversityTermId = () => {
const termId = Number(process.env.UNIVERSITY_TERM_ID ?? process.env.NEXT_PUBLIC_UNIVERSITY_TERM_ID);

return Number.isInteger(termId) && termId > 0 ? termId : DEFAULT_UNIVERSITY_TERM_ID;
return Number.isInteger(termId) && termId > 0 ? termId : undefined;
};

const normalizePositiveInt = (value: unknown) => {
Expand Down Expand Up @@ -78,10 +77,11 @@ export const getSearchUniversitiesAllRegions = async (
params: Pick<UniversitySearchFilterParams, "termId" | "homeUniversityId"> = {},
): Promise<ListUniversity[]> => {
const termId = params.termId === undefined ? getUniversityTermId() : assertPositiveInt("termId", params.termId);
const searchParams = new URLSearchParams({
value: "",
termId: String(termId),
});
const searchParams = new URLSearchParams({ value: "" });

if (termId !== undefined) {
searchParams.set("termId", String(termId));
}

if (params.homeUniversityId !== undefined) {
searchParams.set("homeUniversityId", String(assertPositiveInt("homeUniversityId", params.homeUniversityId)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { URLSearchParams } from "node:url";
import { DEFAULT_UNIVERSITY_TERM_ID } from "@/constants/university";
import { type AllRegionsUniversityList, type ListUniversity, RegionEnumExtend } from "@/types/university";
import serverFetch from "@/utils/serverFetchUtil";
import { assertUniversitySsgResponse } from "./assertUniversitySsgResponse";
Expand All @@ -17,7 +16,7 @@ export interface UniversitySearchTextParams {
const getUniversityTermId = () => {
const termId = Number(process.env.UNIVERSITY_TERM_ID ?? process.env.NEXT_PUBLIC_UNIVERSITY_TERM_ID);

return Number.isInteger(termId) && termId > 0 ? termId : DEFAULT_UNIVERSITY_TERM_ID;
return Number.isInteger(termId) && termId > 0 ? termId : undefined;
};

const normalizePositiveInt = (value: unknown) => {
Expand All @@ -38,10 +37,11 @@ const assertPositiveInt = (name: string, value: unknown) => {

const createSearchTextEndpoint = (value: string, params: UniversitySearchTextParams = {}) => {
const termId = params.termId === undefined ? getUniversityTermId() : assertPositiveInt("termId", params.termId);
const searchParams = new URLSearchParams({
value,
termId: String(termId),
});
const searchParams = new URLSearchParams({ value });

if (termId !== undefined) {
searchParams.set("termId", String(termId));
}

if (params.homeUniversityId !== undefined) {
searchParams.set("homeUniversityId", String(assertPositiveInt("homeUniversityId", params.homeUniversityId)));
Expand Down
3 changes: 0 additions & 3 deletions apps/university-web/src/constants/university.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ export const HOME_UNIVERSITY_LIST: HomeUniversityInfo[] = [
},
];

// 배포 환경에서 UNIVERSITY_TERM_ID를 주입하지 못했을 때 사용하는 현재 학기 fallback입니다.
export const DEFAULT_UNIVERSITY_TERM_ID = 13;

/**
* 슬러그로 홈 대학교 정보 조회
*/
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/apis/universities/api.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { DEFAULT_UNIVERSITY_TERM_ID } from "@/constants/university";
import type { HomeUniversityName } from "@/types/university";
import { axiosInstance, publicAxiosInstance } from "@/utils/axiosInstance";

const getClientUniversityTermId = () => {
const termId = Number(process.env.NEXT_PUBLIC_UNIVERSITY_TERM_ID);

return Number.isInteger(termId) && termId > 0 ? termId : DEFAULT_UNIVERSITY_TERM_ID;
return Number.isInteger(termId) && termId > 0 ? termId : undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep default-term searches scoped without env vars

In deployments following the documented env setup (.env.guide.md production variables and apps/web/.env.production do not define NEXT_PUBLIC_UNIVERSITY_TERM_ID), this now returns undefined; ApplyPageContent passes useDefaultTermId: true before loading selectable universities, so the search request is sent without any termId instead of the previous fallback 13. That lets the application flow load choices outside the current term whenever the API does not add the same default, so either keep a positive fallback or require/inject the term env before removing it.

Useful? React with 👍 / 👎.

};

const normalizePositiveInt = (value: unknown) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { URLSearchParams } from "node:url";
import { DEFAULT_UNIVERSITY_TERM_ID } from "@/constants/university";
import type { CountryCode, LanguageTestType, ListUniversity } from "@/types/university";
import serverFetch from "@/utils/serverFetchUtil";

Expand All @@ -21,7 +20,7 @@ export interface UniversitySearchFilterParams {
const getUniversityTermId = () => {
const termId = Number(process.env.UNIVERSITY_TERM_ID ?? process.env.NEXT_PUBLIC_UNIVERSITY_TERM_ID);

return Number.isInteger(termId) && termId > 0 ? termId : DEFAULT_UNIVERSITY_TERM_ID;
return Number.isInteger(termId) && termId > 0 ? termId : undefined;
};

const normalizePositiveInt = (value: unknown) => {
Expand Down Expand Up @@ -81,10 +80,11 @@ export const getSearchUniversitiesAllRegions = async (
params: Pick<UniversitySearchFilterParams, "termId" | "homeUniversityId"> = {},
): Promise<ListUniversity[]> => {
const termId = params.termId === undefined ? getUniversityTermId() : assertPositiveInt("termId", params.termId);
const searchParams = new URLSearchParams({
value: "",
termId: String(termId),
});
const searchParams = new URLSearchParams({ value: "" });

if (termId !== undefined) {
searchParams.set("termId", String(termId));
}

if (params.homeUniversityId !== undefined) {
searchParams.set("homeUniversityId", String(assertPositiveInt("homeUniversityId", params.homeUniversityId)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { URLSearchParams } from "node:url";
import { DEFAULT_UNIVERSITY_TERM_ID } from "@/constants/university";
import { type AllRegionsUniversityList, type ListUniversity, RegionEnumExtend } from "@/types/university";
import serverFetch from "@/utils/serverFetchUtil";

Expand All @@ -16,7 +15,7 @@ export interface UniversitySearchTextParams {
const getUniversityTermId = () => {
const termId = Number(process.env.UNIVERSITY_TERM_ID ?? process.env.NEXT_PUBLIC_UNIVERSITY_TERM_ID);

return Number.isInteger(termId) && termId > 0 ? termId : DEFAULT_UNIVERSITY_TERM_ID;
return Number.isInteger(termId) && termId > 0 ? termId : undefined;
};

const normalizePositiveInt = (value: unknown) => {
Expand All @@ -37,10 +36,11 @@ const assertPositiveInt = (name: string, value: unknown) => {

const createSearchTextEndpoint = (value: string, params: UniversitySearchTextParams = {}) => {
const termId = params.termId === undefined ? getUniversityTermId() : assertPositiveInt("termId", params.termId);
const searchParams = new URLSearchParams({
value,
termId: String(termId),
});
const searchParams = new URLSearchParams({ value });

if (termId !== undefined) {
searchParams.set("termId", String(termId));
}

if (params.homeUniversityId !== undefined) {
searchParams.set("homeUniversityId", String(assertPositiveInt("homeUniversityId", params.homeUniversityId)));
Expand Down
3 changes: 0 additions & 3 deletions apps/web/src/constants/university.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ export const HOME_UNIVERSITY_LIST: HomeUniversityInfo[] = [
},
];

// 배포 환경에서 UNIVERSITY_TERM_ID를 주입하지 못했을 때 사용하는 현재 학기 fallback입니다.
export const DEFAULT_UNIVERSITY_TERM_ID = 13;

/**
* 슬러그로 홈 대학교 정보 조회
*/
Expand Down
Loading