-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from PizzaPickle/develop
Develop
- Loading branch information
Showing
6 changed files
with
60 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
import { getRoomList as getRoomListFromRedis } from '../redis_client.js'; | ||
export function getConsultingRoom(req, res) { | ||
const { roomId } = req.params; | ||
const { userName, userId } = req.body; | ||
const { roomId } = req.params; | ||
const { userName, userId } = req.body; | ||
|
||
if (!roomId || !userName || !userId) { | ||
return res.status(400).json({ message: '모든 필드가 필요합니다.' }); | ||
} | ||
if (!roomId || !userName || !userId) { | ||
return res.status(400).json({ message: '모든 필드가 필요합니다.' }); | ||
} | ||
|
||
console.log(roomId, userName, userId); | ||
res.render('consultingRoom', { roomId, userName, userId }); | ||
console.log(roomId, userName, userId); | ||
res.render('consultingRoom', { roomId, userName, userId }); | ||
} | ||
|
||
export async function getRoomList(req, res) { | ||
try { | ||
const { userId } = req.query; | ||
console.log('Requested User ID:', userId); | ||
|
||
const roomList = await getRoomListFromRedis(userId); | ||
console.log('Fetched room list from Redis:', roomList); | ||
|
||
if (!roomList) { | ||
return res.status(404).json({ error: 'Room list not found' }); | ||
} | ||
|
||
res.json(roomList); // JSON 형식으로 응답 전송 | ||
} catch (error) { | ||
console.error('Error fetching room list:', error); | ||
res.status(500).json({ error: 'Failed to fetch room list' }); | ||
} | ||
} |
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,8 +1,9 @@ | ||
import express from 'express'; | ||
import { getConsultingRoom } from '../controllers/consultingController.js'; // .js 확장자 포함 | ||
import { getConsultingRoom, getRoomList } from '../controllers/consultingController.js'; // .js 확장자 포함 | ||
|
||
const router = express.Router(); | ||
|
||
router.get('/api/consulting-room', getRoomList); | ||
router.post('/api/consulting-room/:roomId', getConsultingRoom); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
import consultingRoutes from './consultingRoutes.js'; | ||
|
||
export default function setupRoutes(app) { | ||
app.use(consultingRoutes); | ||
|
||
// 기본 라우트 | ||
app.get('/', (req, res) => res.send('Welcome to the Consulting API')); | ||
app.use(consultingRoutes); | ||
} |
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