-
To use MongoDB Atlas, make dev.js file inside config folder. If you are not registered, sign up https://www.mongodb.com/ and create Database.
-
Put mongoDB info into dev.js file
- sample
module.exports = {
mongoURI: 'mongodb+srv://<Your Database Acess ID>:<PASSWORD>@beomjin.8iply.mongodb.net/myFirstDatabase?retryWrites=true&w=majority'
}
-
Type "npm install" inside the root directory ( Download Server Dependencies )
-
Type "npm install" inside the client directory ( Download Front-end Dependencies )
-
Type "npm run dev" inside the root directory, then you can use this Chat App
client
├── ...
├── src
... ├─ _actions
│ ├─ chat_actions.js
│ ├─ friends_actions.js
│ ├─ user_actions.js
│ └─ types.js
│
├─ _reducers
│ ├─ chat-reducer.js
│ ├─ friends_reducer.js
│ ├─ user_reducer.js
│ └─ index.js
│
├─ components
... ├─ views
... ├─ ...
├─ ChatPage
│ ├─ Section
│ │ └─ ChatCard.js
│ └─ ChatPage.js
├─ MainPage
... ├─ Section
│ ├─ ChatList.js
│ ├─ FriendsList.js
│ └─ SearchFriends.js
└─ MainPage.js
server
├── config
│ ├─ dev.js
│ ├─ key.js
│ └─ prod.js
├── middleware
│ └─ auth.js
├── models
│ └─ User.js
├── routes
│ └─ users.js
├──index.js
...
name: {
type:String,
maxlength:50
},
email: {
type:String,
trim:true,
unique: 1
},
password: {
type: String,
minglength: 5
},
lastname: {
type:String,
maxlength: 50
},
role : {
type:Number,
default: 0
},
image: String,
token : {
type: String,
},
tokenExp :{
type: Number
},
friends: [{
name: { type: String },
id: { type: String },
socket: { type: String, default: null}
}],
chats: [{
socketId: { type: String },
receiverId: { type: String },
receiverName: { type: String },
chat: [{
senderId: { type: String },
senderName: { type: String },
message: { type: String },
time: { type: String },
type: { type: String },
read: { type: Boolean }
}],
}]
First, click login button and sign up
After Login, you can see the main page