Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
messenger
Commits
5bd01525
Commit
5bd01525
authored
Jan 02, 2021
by
Soo Hyun Kim
Browse files
soo임시저장0102
parent
d05bb4f0
Changes
24
Hide whitespace changes
Inline
Side-by-side
server/models/chat.js
0 → 100644
View file @
5bd01525
import
mongoose
from
'
mongoose
'
const
{
String
}
=
mongoose
.
Schema
.
Types
const
ChatSchema
=
new
mongoose
.
Schema
({
name
:
{
type
:
String
,
required
:
true
,
},
interest
:
{
type
:
String
,
required
:
true
,
select
:
false
},
isOpen
:
{
type
:
String
,
required
:
true
,
default
:
'
user
'
,
enum
:
[
'
user
'
,
'
admin
'
,
'
root
'
]
}
},
{
timestamps
:
true
})
export
default
mongoose
.
models
.
User
||
mongoose
.
model
(
'
chat
'
,
ChatSchema
)
\ No newline at end of file
server/routes/User.routers.js
0 → 100644
View file @
5bd01525
import
express
from
'
express
'
import
userCtrl
from
'
../controllers/user.controllers.js
'
const
router
=
express
.
Router
()
router
.
route
(
'
/api/users/signup
'
)
.
post
(
userCtrl
.
signup
)
.
get
(
userCtrl
.
hello
)
export
default
router
\ No newline at end of file
server/server.js
0 → 100644
View file @
5bd01525
import
express
from
'
express
'
import
connectDb
from
'
./utils/connectDb.js
'
import
userRouter
from
'
./routes/user.routers.js
'
connectDb
()
const
app
=
express
()
app
.
use
(
express
.
json
())
app
.
use
(
userRouter
)
app
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
res
.
sendFile
(
'
../client/src/index.js
'
)
})
app
.
listen
(
3001
,
()
=>
{
console
.
log
(
'
Listening on port 3001
'
)
})
\ No newline at end of file
server/utils/connectDb.js
0 → 100644
View file @
5bd01525
import
mongoose
from
'
mongoose
'
import
config
from
'
../config.js
'
const
connection
=
{}
async
function
connectDb
()
{
if
(
connection
.
isConnected
){
return
}
const
db
=
await
mongoose
.
connect
(
config
.
mongoDbUri
,{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
useFindAndModify
:
false
,
useCreateIndex
:
true
})
connection
.
isConnected
=
db
.
connections
[
0
].
readyState
}
export
default
connectDb
\ No newline at end of file
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment