diff --git a/backend/src/index.ts b/backend/src/index.ts index a22168a..68ced2c 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -25,17 +25,22 @@ export const app = express(); app.use(attachCorsHeaders); app.use(express.json()); -app.use(authenticateUser); // ローカル:モック or JWT検証 -// ルート定義例 -app.get("/api/docs", DocumentController.getDocumentsOfLoggedInUser); -app.get("/api/docs/:slug", DocumentController.getDocumentBySlugOfLoggedInUser); +// ===================== +// 認証不要ルート +// ===================== +app.get("/api/documents/:slug", DocumentController.getDocumentBySlugOfPublic); + + +// ===================== +// 認証が必要なルート +// ===================== +app.get("/api/docs", authenticateUser, DocumentController.getDocumentsOfLoggedInUser); +app.get("/api/docs/:slug", authenticateUser, DocumentController.getDocumentBySlugOfLoggedInUser); // @ts-ignore -app.post("/api/docs", DocumentController.createDocument); +app.post("/api/docs", authenticateUser, DocumentController.createDocument); // @ts-ignore -app.put("/api/docs/:slug", DocumentController.updateDocument); -app.delete("/api/docs/:slug", DocumentController.deleteDocument); - -app.get("/api/documents/:slug", DocumentController.getDocumentBySlugOfPublic); +app.put("/api/docs/:slug", authenticateUser, DocumentController.updateDocument); +app.delete("/api/docs/:slug", authenticateUser, DocumentController.deleteDocument); export const handler: Handler = serverlessHttp(app) as Handler; \ No newline at end of file diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index c2bc835..7164659 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,15 +1,14 @@ -// App.tsx (抜粋) +// App.tsx (抜粋) + import React from "react"; import { BrowserRouter as Router, Route, Routes, Link } from "react-router-dom"; import DocsListPage from "./pages/DocsListPage"; import DocPage from "./pages/DocPage"; import PublicDocumentPage from "./pages/PublicDocumentPage"; import PrivacyPolicyPage from "./pages/PrivacyPolicyPage"; - import { CombinedAuthProvider } from "./context/AuthContext.bridge"; -import { useAuthContextSwitch as useAuthContext} from "./context/useAuthContextSwitch.ts"; -import "./App.css"; // 必要に応じて、追加CSSをApp.cssなどに追記 - +import { useAuthContextSwitch as useAuthContext} from "./context/useAuthContextSwitch"; +import "./App.css"; import footerStyles from "./styles/Footer.module.scss"; import TermsOfUsePage from "./pages/TermsOfUsePage"; import AccountInfoPage from "./pages/AccountInfoPage"; @@ -30,14 +29,11 @@ const MainRouter: React.FC = () => { {/* ナビゲーションバー */}
- - Markdown Portal - + Markdown Portal
{isSignedIn ? ( <> - {/* displayName を押すと /account へ移動するように */} {displayName} @@ -52,24 +48,30 @@ const MainRouter: React.FC = () => { )}
+
- {/* ルーティング */} - - }/> - }/> - }/> - }/> - }/> - } /> - } /> - + + {/* 新規作成 (DocPageを "新規モード" で表示) */} + } /> + + {/* 自分のドキュメント一覧 */} + } /> + + {/* 自分のドキュメント詳細・編集 */} + } /> + + {/* 公開用ドキュメント */} + } /> + + } /> + } /> + } /> +
- {/* Footer */}