front/stubs/api/chat/index.js
2024-10-04 00:06:44 +03:00

18 lines
418 B
JavaScript

const chatRouter = require('express').Router();
module.exports = chatRouter;
const { users, chats, getUserFromDB, getChatFromDB } = require('../db');
chatRouter.get('/:id1/:id2', (req, res) => {
const { id1, id2 } = req.params;
const chat = getChatFromDB(id1, id2);
if (chat) {
res.status(200).send({chat});
} else {
res.status(404).send({message: 'Chat was not found'});
}
})