init for chats and api
This commit is contained in:
354
stubs/api/chat/chats.json
Normal file
354
stubs/api/chat/chats.json
Normal file
@@ -0,0 +1,354 @@
|
||||
[
|
||||
{
|
||||
"id1": "alice",
|
||||
"id2": "bobsm",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Hello Bob!",
|
||||
"senderId": "alice"
|
||||
},
|
||||
{
|
||||
"data": "Hey Alice, how are you?",
|
||||
"senderId": "bobsm"
|
||||
},
|
||||
{
|
||||
"data": "I'm good, thanks for asking.",
|
||||
"senderId": "alice"
|
||||
},
|
||||
{
|
||||
"data": "Glad to hear!",
|
||||
"senderId": "bobsm"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "alice",
|
||||
"id2": "charl",
|
||||
"messages": [
|
||||
{
|
||||
"data": "How's the project going?",
|
||||
"senderId": "alice"
|
||||
},
|
||||
{
|
||||
"data": "It's coming along, almost done!",
|
||||
"senderId": "charl"
|
||||
},
|
||||
{
|
||||
"data": "That's great to hear!",
|
||||
"senderId": "alice"
|
||||
},
|
||||
{
|
||||
"data": "Thanks for checking in.",
|
||||
"senderId": "charl"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "alice",
|
||||
"id2": "david",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Did you get the files?",
|
||||
"senderId": "david"
|
||||
},
|
||||
{
|
||||
"data": "Yes, I did. Thank you!",
|
||||
"senderId": "alice"
|
||||
},
|
||||
{
|
||||
"data": "You're welcome.",
|
||||
"senderId": "david"
|
||||
},
|
||||
{
|
||||
"data": "Let me know if you need anything else.",
|
||||
"senderId": "alice"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "bobsm",
|
||||
"id2": "charl",
|
||||
"messages": [
|
||||
{
|
||||
"data": "How's everything going?",
|
||||
"senderId": "bobsm"
|
||||
},
|
||||
{
|
||||
"data": "Pretty good, how about you?",
|
||||
"senderId": "charl"
|
||||
},
|
||||
{
|
||||
"data": "Can't complain!",
|
||||
"senderId": "bobsm"
|
||||
},
|
||||
{
|
||||
"data": "Glad to hear that.",
|
||||
"senderId": "charl"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "bobsm",
|
||||
"id2": "david",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Can you send the report?",
|
||||
"senderId": "bobsm"
|
||||
},
|
||||
{
|
||||
"data": "I'll send it in an hour.",
|
||||
"senderId": "david"
|
||||
},
|
||||
{
|
||||
"data": "Perfect, thanks.",
|
||||
"senderId": "bobsm"
|
||||
},
|
||||
{
|
||||
"data": "No problem.",
|
||||
"senderId": "david"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "charl",
|
||||
"id2": "evead",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Hey Eve, how's it going?",
|
||||
"senderId": "charl"
|
||||
},
|
||||
{
|
||||
"data": "Good, how about you?",
|
||||
"senderId": "evead"
|
||||
},
|
||||
{
|
||||
"data": "Can't complain!",
|
||||
"senderId": "charl"
|
||||
},
|
||||
{
|
||||
"data": "Glad to hear.",
|
||||
"senderId": "evead"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "charl",
|
||||
"id2": "frank",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Do you have time to talk today?",
|
||||
"senderId": "charl"
|
||||
},
|
||||
{
|
||||
"data": "I have a meeting, but I can chat afterward.",
|
||||
"senderId": "frank"
|
||||
},
|
||||
{
|
||||
"data": "Sounds good.",
|
||||
"senderId": "charl"
|
||||
},
|
||||
{
|
||||
"data": "I'll message you after.",
|
||||
"senderId": "frank"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "david",
|
||||
"id2": "frank",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Did you review the document?",
|
||||
"senderId": "david"
|
||||
},
|
||||
{
|
||||
"data": "Yes, it's all good.",
|
||||
"senderId": "frank"
|
||||
},
|
||||
{
|
||||
"data": "Great, thanks for the quick turnaround!",
|
||||
"senderId": "david"
|
||||
},
|
||||
{
|
||||
"data": "No worries!",
|
||||
"senderId": "frank"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "david",
|
||||
"id2": "grace",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Grace, can you send the updated schedule?",
|
||||
"senderId": "david"
|
||||
},
|
||||
{
|
||||
"data": "Yes, I'll send it in a few minutes.",
|
||||
"senderId": "grace"
|
||||
},
|
||||
{
|
||||
"data": "Thanks, much appreciated!",
|
||||
"senderId": "david"
|
||||
},
|
||||
{
|
||||
"data": "You're welcome!",
|
||||
"senderId": "grace"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "frank",
|
||||
"id2": "grace",
|
||||
"messages": [
|
||||
{
|
||||
"data": "How are you today?",
|
||||
"senderId": "frank"
|
||||
},
|
||||
{
|
||||
"data": "I'm doing well, thanks for asking.",
|
||||
"senderId": "grace"
|
||||
},
|
||||
{
|
||||
"data": "Glad to hear that.",
|
||||
"senderId": "frank"
|
||||
},
|
||||
{
|
||||
"data": "How about you?",
|
||||
"senderId": "grace"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "frank",
|
||||
"id2": "hanna",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Did you attend the meeting?",
|
||||
"senderId": "frank"
|
||||
},
|
||||
{
|
||||
"data": "Yes, it was productive.",
|
||||
"senderId": "hanna"
|
||||
},
|
||||
{
|
||||
"data": "Good to hear!",
|
||||
"senderId": "frank"
|
||||
},
|
||||
{
|
||||
"data": "Indeed, lots to follow up on.",
|
||||
"senderId": "hanna"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "grace",
|
||||
"id2": "hanna",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Can we meet later today?",
|
||||
"senderId": "grace"
|
||||
},
|
||||
{
|
||||
"data": "Sure, what's a good time?",
|
||||
"senderId": "hanna"
|
||||
},
|
||||
{
|
||||
"data": "How about 3 PM?",
|
||||
"senderId": "grace"
|
||||
},
|
||||
{
|
||||
"data": "Works for me.",
|
||||
"senderId": "hanna"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "grace",
|
||||
"id2": "ianda",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Ian, did you get the message I sent?",
|
||||
"senderId": "grace"
|
||||
},
|
||||
{
|
||||
"data": "Yes, I'll respond soon.",
|
||||
"senderId": "ianda"
|
||||
},
|
||||
{
|
||||
"data": "Thanks, appreciate it!",
|
||||
"senderId": "grace"
|
||||
},
|
||||
{
|
||||
"data": "You're welcome!",
|
||||
"senderId": "ianda"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "hanna",
|
||||
"id2": "ianda",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Ian, do you have a minute?",
|
||||
"senderId": "hanna"
|
||||
},
|
||||
{
|
||||
"data": "Yes, what do you need?",
|
||||
"senderId": "ianda"
|
||||
},
|
||||
{
|
||||
"data": "Just a quick update on the project.",
|
||||
"senderId": "hanna"
|
||||
},
|
||||
{
|
||||
"data": "I'll email you the details.",
|
||||
"senderId": "ianda"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "hanna",
|
||||
"id2": "jillt",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Jill, can we talk tomorrow?",
|
||||
"senderId": "hanna"
|
||||
},
|
||||
{
|
||||
"data": "Yes, I'm free after 2 PM.",
|
||||
"senderId": "jillt"
|
||||
},
|
||||
{
|
||||
"data": "Perfect, see you then.",
|
||||
"senderId": "hanna"
|
||||
},
|
||||
{
|
||||
"data": "Looking forward to it.",
|
||||
"senderId": "jillt"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id1": "ianda",
|
||||
"id2": "jillt",
|
||||
"messages": [
|
||||
{
|
||||
"data": "Jill, I have the files you requested.",
|
||||
"senderId": "ianda"
|
||||
},
|
||||
{
|
||||
"data": "Thanks, please send them over.",
|
||||
"senderId": "jillt"
|
||||
},
|
||||
{
|
||||
"data": "I'll send them right now.",
|
||||
"senderId": "ianda"
|
||||
},
|
||||
{
|
||||
"data": "Great, thanks again!",
|
||||
"senderId": "jillt"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
17
stubs/api/chat/index.js
Normal file
17
stubs/api/chat/index.js
Normal file
@@ -0,0 +1,17 @@
|
||||
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'});
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user