Toggle navigation
Toggle navigation
This project
Loading...
Sign in
정승호
/
Hexa_for_you_renewal
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
정승호
2020-05-21 23:22:27 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c0070fe7109f620c42d0808d158f06d2f46078da
c0070fe7
1 parent
b35c0007
post 기능 추가
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletions
index.js
package.json
index.js
View file @
c0070fe
const
express
=
require
(
'express'
)
const
app
=
express
()
const
bodyParser
=
require
(
'body-parser'
);
const
port
=
5000
const
{
User
}
=
require
(
'/models/Users'
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
use
(
bodyParser
.
json
());
const
mongoose
=
require
(
'mongoose'
)
mongoose
.
connect
(
'mongodb+srv://platoon07:wony9795!!@2020oss-ysxss.mongodb.net/test?retryWrites=true&w=majority'
,{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
useCreateIndex
:
true
,
useFindAndModify
:
false
...
...
@@ -12,7 +19,22 @@ mongoose.connect('mongodb+srv://platoon07:wony9795!!@2020oss-ysxss.mongodb.net/t
app
.
get
(
'/'
,
(
req
,
res
)
=>
res
.
send
(
'Hello world!!'
))
app
.
listen
(
port
,
()
=>
console
.
log
(
'example app listen on port ${port} !'
))
app
.
post
(
'/register'
,
(
req
,
res
)
=>
{
// 회원 가입시 필요한 정보들을 client에서 가져오면
// 그것들을 데이터베이스에 넣어준다.
const
user
=
new
User
(
req
.
body
)
user
.
save
((
err
,
userInfo
)
=>
{
if
(
err
)
return
res
.
json
({
success
:
false
,
err
})
return
res
.
status
(
200
).
json
({
success
:
true
})
})
// MongoDb에 저징
})
app
.
listen
(
port
,
()
=>
console
.
log
(
'example app listen on port ${port}!'
))
// mongodb+srv://platoon07:<password>@2020oss-ysxss.mongodb.net/test?retryWrites=true&w=majority
\ No newline at end of file
...
...
package.json
View file @
c0070fe
...
...
@@ -14,6 +14,7 @@
"author"
:
"seungho"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"body-parser"
:
"^1.19.0"
,
"express"
:
"^4.17.1"
,
"mongoose"
:
"^5.9.15"
}
...
...
Please
register
or
login
to post a comment