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
Show whitespace changes
Inline
Side-by-side
server/server.js
View file @
09af2954
import
express
from
'
express
'
import
express
from
'
express
'
import
connectDb
from
'
./utils/connectDb.js
'
import
connectDb
from
'
./utils/connectDb.js
'
import
userRouter
from
'
./routes/user.route
r
s.js
'
import
userRouter
from
'
./routes/user.routes.js
'
connectDb
()
connectDb
()
const
app
=
express
()
const
app
=
express
()
app
.
use
(
express
.
json
())
app
.
use
(
express
.
json
())
//이부분을 body 파싱함
//express가 req.body라는곳을 자동으로만들어서 json형식으로 보낸것을 객체형식으로 넣음
//이부분 다음부터는 req.body라는 부분을 실행할 수 있음
app
.
use
(
userRouter
)
app
.
use
(
userRouter
)
//userRouter로 이동
app
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
app
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
res
.
send
File
(
'
../client/src/index.js
'
)
res
.
send
(
'
Hello World. 안녕하세요
'
)
})
})
app
.
listen
(
300
1
,
()
=>
{
app
.
listen
(
30
3
0
,
()
=>
{
console
.
log
(
'
Listening on port 300
1
'
)
console
.
log
(
'
Listening on port 30
3
0
'
)
})
})
server/utils/connectDb.js
View file @
09af2954
...
@@ -4,11 +4,11 @@ import config from '../config.js'
...
@@ -4,11 +4,11 @@ import config from '../config.js'
const
connection
=
{}
const
connection
=
{}
async
function
connectDb
()
{
async
function
connectDb
()
{
if
(
connection
.
isConnected
){
if
(
connection
.
isConnected
)
{
return
return
}
}
const
db
=
await
mongoose
.
connect
(
config
.
mongoDbUri
,{
const
db
=
await
mongoose
.
connect
(
config
.
mongoDbUri
,
{
useNewUrlParser
:
true
,
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
useUnifiedTopology
:
true
,
useFindAndModify
:
false
,
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