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
34 changes: 34 additions & 0 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,47 +68,81 @@ jobs:
runs-on: ubuntu-latest
needs: lint
timeout-minutes: 15

# โœ… ํ…Œ์ŠคํŠธ ๋‹จ๊ณ„์—์„œ๋„ env ํ•„์š”ํ•œ ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์•„์„œ ๊ฐ™์ด ์ฃผ์ž…
env:
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
NEXT_PUBLIC_API_TIMEOUT: "10000"

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- uses: pnpm/action-setup@v4
with:
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-

- run: pnpm install --frozen-lockfile

- run: pnpm run --if-present test -- --ci

build:
runs-on: ubuntu-latest
needs: test
timeout-minutes: 15

# โœ… ์—ฌ๊ธฐ์„œ supabaseUrl required ํ„ฐ์ง€๋˜ ์›์ธ ํ•ด๊ฒฐ: build์— env ์ฃผ์ž…
env:
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
NEXT_PUBLIC_API_TIMEOUT: "10000"

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- uses: pnpm/action-setup@v4
with:
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-

- run: pnpm install --frozen-lockfile

# โœ… (์„ ํƒ) env ๋ˆ„๋ฝ์ด๋ฉด ์—ฌ๊ธฐ์„œ ๋ฐ”๋กœ ์ฃฝ๊ฒŒ ํ•ด์„œ ์›์ธ ๋นจ๋ฆฌ ์ฐพ๊ธฐ
- name: Check env exists
run: |
test -n "$NEXT_PUBLIC_SUPABASE_URL" || (echo "NEXT_PUBLIC_SUPABASE_URL missing" && exit 1)
test -n "$NEXT_PUBLIC_SUPABASE_ANON_KEY" || (echo "NEXT_PUBLIC_SUPABASE_ANON_KEY missing" && exit 1)
test -n "$SUPABASE_SERVICE_ROLE_KEY" || (echo "SUPABASE_SERVICE_ROLE_KEY missing" && exit 1)

# (์„ ํƒ) Next.js ๋นŒ๋“œ ์บ์‹œ
# - uses: actions/cache@v4
# with:
Expand Down
10 changes: 10 additions & 0 deletions .idea/.gitignore

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

58 changes: 58 additions & 0 deletions .idea/codeStyles/Project.xml

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

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

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

9 changes: 9 additions & 0 deletions .idea/custom-daily-planner.iml

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

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

6 changes: 6 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/prettier.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

72 changes: 72 additions & 0 deletions src/app/api/check-email/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { supabaseAdmin } from "@/lib/supabase/admin";
import { isValidEmail } from "@/lib/validators";
import type { CheckEmailBody, CheckEmailFailRes, CheckEmailOkRes } from "@/types/auth";
import { NextResponse } from "next/server";

export async function POST(req: Request): Promise<Response> {
let body: CheckEmailBody;

try {
body = (await req.json()) as CheckEmailBody;
} catch {
const res: CheckEmailFailRes = {
ok: false,
available: false,
message: "์š”์ฒญ ๋ณธ๋ฌธ(JSON)์ด ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.",
};
return NextResponse.json(res, { status: 400 });
}

const email = (body.email ?? "").trim().toLowerCase();

if (!email) {
const res: CheckEmailFailRes = {
ok: false,
available: false,
message: "์ด๋ฉ”์ผ์ด ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค.",
};
return NextResponse.json(res, { status: 400 });
}

if (!isValidEmail(email)) {
const res: CheckEmailFailRes = {
ok: false,
available: false,
message: "์ด๋ฉ”์ผ ํ˜•์‹์ด ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.",
};
return NextResponse.json(res, { status: 400 });
}

const { data, error } = await supabaseAdmin
.from("profiles")
.select("id")
.eq("email", email)
.limit(1);

if (error) {
const res: CheckEmailFailRes = {
ok: false,
available: false,
message: "์„œ๋ฒ„ ํ™•์ธ ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.",
};
return NextResponse.json(res, { status: 500 });
}

const exists = (data?.length ?? 0) > 0;

if (exists) {
const res: CheckEmailOkRes = {
ok: true,
available: false,
message: "์ด๋ฏธ ๊ฐ€์ž…๋œ ์ด๋ฉ”์ผ์ž…๋‹ˆ๋‹ค.",
};
return NextResponse.json(res);
}

const res: CheckEmailOkRes = {
ok: true,
available: true,
message: "์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์ด๋ฉ”์ผ์ž…๋‹ˆ๋‹ค.",
};
return NextResponse.json(res);
}
31 changes: 31 additions & 0 deletions src/app/api/send-otp/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { createClient } from "@supabase/supabase-js";
import { NextResponse } from "next/server";

type Body = { email?: string };

export async function POST(req: Request) {
const body = (await req.json()) as Body;
const email = (body.email ?? "").trim().toLowerCase();

if (!email) {
return NextResponse.json({ ok: false, message: "์ด๋ฉ”์ผ์ด ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค." }, { status: 400 });
}

const url = process.env.NEXT_PUBLIC_SUPABASE_URL!;
const anon = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!;

const supabase = createClient(url, anon, { auth: { persistSession: false } });

const { error } = await supabase.auth.signInWithOtp({
email,
options: {
shouldCreateUser: true,
},
});

if (error) {
return NextResponse.json({ ok: false, message: error.message }, { status: 400 });
}

return NextResponse.json({ ok: true, message: "์ธ์ฆ ๋ฉ”์ผ์„ ๋ฐœ์†กํ–ˆ์Šต๋‹ˆ๋‹ค." });
}
Loading
Loading