forked from OurProjectsCombined/chat-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed message/user endpoint bugs and added clarifying comments
- Loading branch information
Keagan Aromin
authored and
Keagan Aromin
committed
Jan 11, 2025
1 parent
6ca7ea3
commit 0ac9d50
Showing
4 changed files
with
21 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import express, { Router } from "express"; | ||
import { sendMessage } from "../controllers/message.controller"; | ||
import protectRoute from "../middleware/protectRoute"; | ||
import { getMessages, sendMessage } from "../controllers/message.controller.js"; | ||
import protectRoute from "../middleware/protectRoute.js"; | ||
|
||
const router = express.Router(); | ||
|
||
//when we have a post request, we first run protectRoute until the next() call is reached, then we run sendMessage | ||
//protectRoute makes sure that only authenticated users can send a message | ||
//access id using req.params.id | ||
router.get("/:id", protectRoute, getMessages) | ||
router.post("/send/:id", protectRoute, sendMessage) | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters