Skip to content

Commit 285d0d8

Browse files
committed
update route configuration with auth middleware
1 parent d6e29b0 commit 285d0d8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/content/docs/workers-ai/tutorials/build-ai-interview-practice-tool.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ const api = new Hono<ApiContext>();
330330
// Set up global middleware that runs on every request
331331
// - Logger gives us visibility into what is happening
332332
app.use("*", logger());
333-
app.use("*", requireAuth);
334333

335334
// Wire up all our authentication routes (login, etc)
336335
// These will be mounted under /api/v1/auth/
@@ -418,6 +417,8 @@ Now we need to export the Durable Object in our main `src/index.ts` file:
418417
```typescript title="src/index.ts"
419418
import { Interview } from "./interview";
420419

420+
// ... previous code ...
421+
421422
export { Interview };
422423

423424
export default app;
@@ -846,6 +847,7 @@ import {
846847
InterviewTitle,
847848
InterviewSkill,
848849
} from "../types";
850+
import { requireAuth } from "../middleware/auth";
849851

850852
/**
851853
* Gets the Interview Durable Object instance for a given user.
@@ -914,6 +916,7 @@ const createInterview = async (ctx: HonoCtx) => {
914916
*/
915917
export const configureInterviewRoutes = () => {
916918
const router = new Hono<ApiContext>();
919+
router.use("*", requireAuth);
917920
router.get("/", getAllInterviews);
918921
router.post("/", createInterview);
919922
return router;
@@ -935,7 +938,7 @@ import type { ApiContext } from "./types";
935938
const app = new Hono<ApiContext>();
936939
const api = new Hono<ApiContext>();
937940

938-
app.use("", logger());
941+
app.use("*", logger());
939942

940943
api.route("/auth", configureAuthRoutes());
941944
api.route("/interviews", configureInterviewRoutes());

0 commit comments

Comments
 (0)