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
2 changes: 1 addition & 1 deletion .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Deploy to Firebase Hosting on merge
on:
push:
branches:
- master
- main
jobs:
build_and_deploy:
runs-on: ubuntu-latest
Expand Down
88 changes: 76 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ VITE_MESSAGING_SENDER_ID=...
VITE_APP_ID=...
VITE_MEASUREMENT_ID=...

# Functions 호출용 (env:setup가 자동 추가)
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_REGION=us-central1
VITE_FUNCTIONS_URL_LOCAL=http://localhost:5001/your-project-id/us-central1
VITE_FUNCTIONS_URL_PROD=https://us-central1-your-project-id.cloudfunctions.net
# Functions 호출용 (`pnpm proxy`로 자동 추가)
VITE_FIREBASE_PROJECT_ID=
VITE_FIREBASE_REGION=
VITE_FUNCTIONS_URL_LOCAL=
VITE_FUNCTIONS_URL_PROD=
```

### 2. 개발 서버 시작
Expand Down Expand Up @@ -74,18 +74,82 @@ VITE_MESSAGING_SENDER_ID=...
VITE_APP_ID=...
VITE_MEASUREMENT_ID=...

# Functions 호출 설정 (env:setup 실행 시 자동 추가/보강)
VITE_FIREBASE_PROJECT_ID=til-alarm
VITE_FIREBASE_REGION=us-central1
VITE_FUNCTIONS_URL_LOCAL=http://localhost:5001/til-alarm/us-central1
VITE_FUNCTIONS_URL_PROD=https://us-central1-til-alarm.cloudfunctions.net
# Functions 호출 설정 (`pnpm proxy` 실행 시 자동 추가)
VITE_FIREBASE_PROJECT_ID=
VITE_FIREBASE_REGION=
VITE_FUNCTIONS_URL_LOCAL=
VITE_FUNCTIONS_URL_PROD=
```

### Functions 환경변수 (functions/.env)
```bash
GITHUB_TOKEN=your_github_token_here
CLOVA_API_KEY=your_clova_api_key
NCLOUD_API_KEY=your_ncloud_api_key
```

## 🌏 리전 설정

이 프로젝트는 기본적으로 **Seoul (asia-northeast3)** 리전에 배포됩니다.

### 사용 가능한 Firebase Functions 리전
- `asia-northeast3` - Seoul (서울) ⭐ 기본값
- `asia-northeast1` - Tokyo (도쿄)
- `us-central1` - Iowa (아이오와)
- `us-west1` - Oregon (오레곤)
- `europe-west1` - Belgium (벨기에)
- [전체 리전 목록](https://firebase.google.com/docs/functions/locations)

### 리전 변경 방법

다른 리전으로 변경하려면 다음 파일들을 수정하세요:

#### 1. Functions 코드 (모든 함수의 region 옵션 수정)

**`functions/src/github.ts`**
```typescript
export const getCommits = onRequest(
{ cors: true, region: 'your-region' }, // 변경
async (req, res) => { ... }
);
// getFilename, getMarkdown, getRepositories, getBranches도 동일하게 수정
```

**`functions/src/hyperclovax.ts`**
```typescript
export const chatCompletions = onRequest(
{ cors: true, region: 'your-region' }, // 변경
async (req, res) => { ... }
);
```

**`functions/src/schedule.ts`**
```typescript
export const sendDaily8amPush = onSchedule(
{
schedule: '0 23 * * *',
timeZone: 'Asia/Seoul',
region: 'your-region' // 변경
},
async () => { ... }
);
```

#### 2. Setup 스크립트 (환경변수 자동 생성용)

**`scripts/setup-proxy.js`**
```javascript
const envVars = {
VITE_FIREBASE_PROJECT_ID: projectId,
VITE_FIREBASE_REGION: 'your-region', // 변경
VITE_FUNCTIONS_URL_LOCAL: `http://localhost:5001/${projectId}/your-region`, // 변경
VITE_FUNCTIONS_URL_PROD: `https://your-region-${projectId}.cloudfunctions.net` // 변경
};
```

#### 3. 환경변수 재생성

```bash
# setup 스크립트 재실행하여 app/.env 업데이트
pnpm env:setup
```

## 🚀 배포
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "tsc && vite build"
},
"dependencies": {
"@til-alarm/shared": "workspace:*",
"@recall-buddy/shared": "workspace:*",
"axios": "^1.12.2",
"firebase": "^10.4.0",
"github-markdown-css": "^5.8.1",
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion app/src/api/github-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { apiClient } from '../modules/axios';
import type { Repository } from '@til-alarm/shared';
import type { Repository } from '@recall-buddy/shared';

interface Commit {
sha: string;
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { signOut } from 'firebase/auth';
import { useIndexedDB } from 'react-indexed-db-hook';
import { auth, db } from '../firebase';
import { getRepositories, getBranches, Branch } from '../api/github-api';
import { Repository } from '@til-alarm/shared';
import { Repository } from '@recall-buddy/shared';
import './Onboarding.css';

interface OnboardingProps {
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { reauthenticateWithPopup } from 'firebase/auth';
import { useIndexedDB } from 'react-indexed-db-hook';
import { auth, db, githubProvider } from '../firebase';
import { getRepositories, getBranches, Branch } from '../api/github-api';
import { Repository } from '@til-alarm/shared';
import { Repository } from '@recall-buddy/shared';
import TermsLinks from '../widgets/TermsLinks';
import './Settings.css';

Expand Down
2 changes: 1 addition & 1 deletion app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default defineConfig(({ mode }) => {
open: true,
proxy: {
'/api': {
target: functionsUrl || 'http://localhost:5001/til-alarm/us-central1',
target: functionsUrl,
changeOrigin: true,
secure: false, // 로컬 개발 시 false
rewrite: (path) => path.replace(/^\/api/, '')
Expand Down
2 changes: 1 addition & 1 deletion functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"deploy:hypercloax": "pnpm build && firebase deploy --only functions:hypercloaxApi,functions:chatCompletions,functions:registerDeviceToken,functions:removeDeviceToken,functions:registerSchedule"
},
"dependencies": {
"@til-alarm/shared": "workspace:*",
"@recall-buddy/shared": "workspace:*",
"firebase-admin": "^12.0.0",
"firebase-functions": "^4.8.0"
},
Expand Down
12 changes: 6 additions & 6 deletions functions/src/github.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { onRequest } from 'firebase-functions/v2/https';
import { getAuth } from 'firebase-admin/auth';
import { getFirestore } from 'firebase-admin/firestore';
import { Repository } from '@til-alarm/shared';
import { Repository } from '@recall-buddy/shared';

/**
* Firebase ID Token 검증 및 사용자 정보 조회
Expand Down Expand Up @@ -60,7 +60,7 @@ async function getUserData(req: any): Promise<{

// GitHub API 호출을 위한 HTTP Functions
export const getCommits = onRequest(
{ cors: true },
{ cors: true, region: 'asia-northeast3' },
async (req, res) => {
try {
const { since, until } = req.query;
Expand Down Expand Up @@ -105,7 +105,7 @@ export const getCommits = onRequest(
);

export const getFilename = onRequest(
{ cors: true },
{ cors: true, region: 'asia-northeast3' },
async (req, res) => {
try {
const { commit_sha } = req.query;
Expand Down Expand Up @@ -149,7 +149,7 @@ export const getFilename = onRequest(
);

export const getMarkdown = onRequest(
{ cors: true },
{ cors: true, region: 'asia-northeast3' },
async (req, res) => {
try {
const { filename } = req.query;
Expand Down Expand Up @@ -198,7 +198,7 @@ export const getMarkdown = onRequest(
* Settings 페이지에서 리포지토리 선택을 위해 사용
*/
export const getRepositories = onRequest(
{ cors: true },
{ cors: true, region: 'asia-northeast3' },
async (req, res) => {
try {
const authHeader = req.headers.authorization;
Expand Down Expand Up @@ -266,7 +266,7 @@ export const getRepositories = onRequest(
* Settings 페이지에서 브랜치 선택을 위해 사용
*/
export const getBranches = onRequest(
{ cors: true },
{ cors: true, region: 'asia-northeast3' },
async (req, res) => {
try {
const { owner, repo } = req.query;
Expand Down
2 changes: 1 addition & 1 deletion functions/src/hyperclovax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { onRequest } from 'firebase-functions/v2/https';

// HyperCLOVA X API (HCX-007)
export const chatCompletions = onRequest(
{ cors: true },
{ cors: true, region: 'asia-northeast3' },
async (req, res) => {
try {
const { prompt, text } = req.body;
Expand Down
3 changes: 2 additions & 1 deletion functions/src/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { getMessaging } from 'firebase-admin/messaging';
export const sendDaily8amPush = onSchedule(
{
schedule: '0 23 * * *', // KST 08:00 = UTC 23:00 (전날)
timeZone: 'Asia/Seoul'
timeZone: 'Asia/Seoul',
region: 'asia-northeast3'
},
async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@til-alarm/shared",
"name": "@recall-buddy/shared",
"version": "1.0.0",
"private": true,
"main": "./dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions scripts/setup-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ try {
// 환경변수 내용 생성 (Functions용)
const envVars = {
VITE_FIREBASE_PROJECT_ID: projectId,
VITE_FIREBASE_REGION: 'us-central1',
VITE_FUNCTIONS_URL_LOCAL: `http://localhost:5001/${projectId}/us-central1`,
VITE_FUNCTIONS_URL_PROD: `https://us-central1-${projectId}.cloudfunctions.net`
VITE_FIREBASE_REGION: 'asia-northeast3',
VITE_FUNCTIONS_URL_LOCAL: `http://localhost:5001/${projectId}/asia-northeast3`,
VITE_FUNCTIONS_URL_PROD: `https://asia-northeast3-${projectId}.cloudfunctions.net`
};

let envFileContent = '';
Expand Down