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
shopping-mall
Commits
0da1ed33
Commit
0da1ed33
authored
Jan 06, 2021
by
이재연
Browse files
Merge remote-tracking branch 'origin/ourMaster' into jaeyeon
parents
814fb4cf
3ba7cf83
Changes
28
Hide whitespace changes
Inline
Side-by-side
server/config.js
View file @
0da1ed33
...
...
@@ -2,7 +2,16 @@ const config = {
env
:
process
.
env
.
NODEENV
||
'
development
'
,
port
:
process
.
env
.
PORT
||
3001
,
jwtSecret
:
process
.
env
.
JWT_SECRET
||
'
My_Secret_Key
'
,
mongoDbUri
:
process
.
env
.
MONGEDB_URI
||
'
mongodb://localhost/shopping-mall
'
mongoDbUri
:
process
.
env
.
MONGEDB_URI
||
'
mongodb://localhost/shopping-mall
'
,
kakaoAdminKey
:
'
b2dda7685c5b2990684d813e362cff07
'
}
export
default
config
\ No newline at end of file
// const config = {
// port: 3001,
// kakaoAdminKey: 'b2dda7685c5b2990684d813e362cff07',
// }
export
default
config
// export default config
\ No newline at end of file
server/controllers/kakaopay.controller.js
0 → 100644
View file @
0da1ed33
// import { RequestHandler } from "express";
import
fetch
from
'
node-fetch
'
import
config
from
"
../config.js
"
;
const
success
=
(
req
,
res
)
=>
{
console
.
log
(
'
kakaopay success route
'
)
console
.
log
(
'
req body:
'
,
req
.
body
)
return
res
.
json
({
message
:
'
Success
'
})
}
const
fail
=
(
req
,
res
)
=>
{
console
.
log
(
'
kakaopay fail route
'
)
console
.
log
(
'
req body:
'
,
req
.
body
)
return
res
.
json
({
message
:
'
Failed
'
})
}
const
cancel
=
(
req
,
res
)
=>
{
console
.
log
(
'
kakaopay cancel route
'
)
console
.
log
(
'
req body:
'
,
req
.
body
)
return
res
.
json
({
message
:
'
Canceled
'
})
}
const
singleTest
=
async
(
req
,
res
)
=>
{
console
.
log
(
"
asdaf
"
)
console
.
log
(
req
.
body
)
const
item
=
req
.
body
// set data
const
data
=
[]
for
(
let
property
in
item
)
{
let
encodedKey
=
encodeURIComponent
(
property
);
let
encodedValue
=
encodeURIComponent
(
item
[
property
]);
data
.
push
(
encodedKey
+
"
=
"
+
encodedValue
);
}
const
bodyData
=
data
.
join
(
'
&
'
)
// encode data (application/x-www-form-urlencoded)
const
response
=
await
fetch
(
'
https://kapi.kakao.com/v1/payment/ready
'
,
{
method
:
'
POST
'
,
headers
:
{
'
Authorization
'
:
`KakaoAK
${
config
.
kakaoAdminKey
}
`
,
'
Content-Type
'
:
'
application/x-www-form-urlencoded;charset=UTF-8
'
,
},
body
:
bodyData
,
})
// console.log(response)
const
resp
=
await
response
.
json
()
console
.
log
(
resp
)
res
.
json
({
redirect_url
:
resp
.
next_redirect_pc_url
})
}
export
default
{
success
,
fail
,
cancel
,
singleTest
,
}
server/controllers/product.controller.js
0 → 100644
View file @
0da1ed33
import
Product
from
"
../schemas/Product.js
"
;
const
regist
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
req.body=
'
,
req
.
body
)
const
{
pro_name
,
price
,
stock
,
main_category
,
sub_category
,
description
,
main_image
,
detail_image
}
=
req
.
body
.
product
try
{
const
newProduct
=
await
new
Product
({
pro_name
,
price
,
stock
,
main_category
,
sub_category
,
description
,
main_image
,
detail_image
}).
save
()
console
.
log
(
newProduct
)
res
.
json
(
newProduct
)
}
catch
(
error
)
{
console
.
log
(
error
)
res
.
status
(
500
).
send
(
'
죄송합니다. 다시 입력해 주십시오.
'
)
}
}
export
default
{
regist
}
\ No newline at end of file
server/package.json
View file @
0da1ed33
...
...
@@ -12,9 +12,12 @@
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"cors"
:
"^2.8.5"
,
"express"
:
"^4.17.1"
,
"mongoose"
:
"^5.11.9"
,
"node-fetch"
:
"^2.6.1"
,
"nodemon"
:
"^2.0.6"
,
"validator"
:
"^13.5.2"
"validator"
:
"^13.5.2"
,
"multer"
:
"^1.4.2"
}
}
server/routes/kakaopay.routes.js
0 → 100644
View file @
0da1ed33
import
express
from
'
express
'
import
kakaopayCtrl
from
'
../controllers/kakaopay.controller.js
'
const
router
=
express
.
Router
()
router
.
route
(
'
/kakaopay/success
'
)
.
get
(
kakaopayCtrl
.
success
)
router
.
route
(
'
/api/kakaopay/fail
'
)
.
get
(
kakaopayCtrl
.
fail
)
router
.
route
(
'
/api/kakaopay/cancel
'
)
.
get
(
kakaopayCtrl
.
cancel
)
router
.
route
(
'
/api/kakaopay/test/single
'
)
.
post
(
kakaopayCtrl
.
singleTest
)
export
default
router
server/routes/product.routes.js
0 → 100644
View file @
0da1ed33
import
express
from
"
express
"
;
import
productCtrl
from
'
../controllers/product.controller.js
'
;
const
router
=
express
.
Router
()
router
.
route
(
'
/regist
'
)
.
post
(
productCtrl
.
regist
)
export
default
router
\ No newline at end of file
server/schemas/Product.js
0 → 100644
View file @
0da1ed33
import
mongoose
from
'
mongoose
'
const
{
String
,
Number
,
Array
}
=
mongoose
.
Schema
.
Types
const
ProductSchema
=
new
mongoose
.
Schema
({
pro_name
:
{
type
:
String
,
required
:
true
,
},
price
:
{
type
:
String
,
required
:
true
,
},
stock
:
{
type
:
String
,
required
:
true
},
purchase
:
{
type
:
String
,
required
:
true
,
default
:
0
},
main_category
:
{
type
:
String
,
required
:
true
,
},
sub_category
:
{
type
:
String
,
required
:
true
,
},
description
:
{
type
:
String
,
required
:
true
,
},
main_image
:
{
type
:
String
,
required
:
true
,
},
detail_image
:
{
type
:
String
,
required
:
true
,
}
},
{
timestamps
:
true
})
export
default
mongoose
.
models
.
Product
||
mongoose
.
model
(
'
Product
'
,
ProductSchema
)
\ No newline at end of file
server/schemas/User.js
0 → 100644
View file @
0da1ed33
import
mongoose
from
'
mongoose
'
const
{
String
}
=
mongoose
.
Schema
.
Types
const
UserSchema
=
new
mongoose
.
Schema
({
name
:
{
type
:
String
,
required
:
true
,
},
id
:
{
type
:
String
,
required
:
true
,
unique
:
true
},
password
:
{
type
:
String
,
required
:
true
,
select
:
false
},
confirm_password
:{
type
:
String
,
required
:
true
,
select
:
false
},
phoneNumber
:
{
type
:
String
,
required
:
true
,
},
role
:
{
type
:
String
,
required
:
true
,
default
:
'
user
'
,
enum
:
[
'
user
'
,
'
admin
'
,
'
root
'
]
},
birth
:
{
type
:
String
,
required
:
true
,
},
sex
:
{
type
:
String
,
required
:
true
,
}
},
{
timestamps
:
true
})
export
default
mongoose
.
models
.
User
||
mongoose
.
model
(
'
User
'
,
UserSchema
)
\ 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