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
09af2954
Commit
09af2954
authored
Jan 02, 2021
by
Soo Hyun Kim
Browse files
Merge remote-tracking branch 'origin/young' into soo-12-28
parents
b7b9b6c2
c4848cf1
Changes
22
Hide whitespace changes
Inline
Side-by-side
server/server.js
View file @
09af2954
import
express
from
'
express
'
import
connectDb
from
'
./utils/connectDb.js
'
import
userRouter
from
'
./routes/user.route
r
s.js
'
import
userRouter
from
'
./routes/user.routes.js
'
connectDb
()
const
app
=
express
()
app
.
use
(
express
.
json
())
//이부분을 body 파싱함
//express가 req.body라는곳을 자동으로만들어서 json형식으로 보낸것을 객체형식으로 넣음
//이부분 다음부터는 req.body라는 부분을 실행할 수 있음
app
.
use
(
userRouter
)
//userRouter로 이동
app
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
res
.
send
File
(
'
../client/src/index.js
'
)
res
.
send
(
'
Hello World. 안녕하세요
'
)
})
app
.
listen
(
3001
,
()
=>
{
console
.
log
(
'
Listening on port 3001
'
)
})
\ No newline at end of file
app
.
listen
(
3030
,
()
=>
{
console
.
log
(
'
Listening on port 3030
'
)
})
server/utils/connectDb.js
View file @
09af2954
...
...
@@ -4,11 +4,11 @@ import config from '../config.js'
const
connection
=
{}
async
function
connectDb
()
{
if
(
connection
.
isConnected
){
return
if
(
connection
.
isConnected
)
{
return
}
const
db
=
await
mongoose
.
connect
(
config
.
mongoDbUri
,{
const
db
=
await
mongoose
.
connect
(
config
.
mongoDbUri
,
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
useFindAndModify
:
false
,
...
...
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