Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
5
59110440259
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
senior-prj-62
59110440259
Commits
b8172a1d
Commit
b8172a1d
authored
Feb 05, 2020
by
Piyaphorn Arphornsri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add db
parent
fc71b457
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
135 additions
and
74 deletions
+135
-74
index.js
Backend/controllers/auth/index.js
+28
-9
index.js
Backend/models/booking/index.js
+2
-2
index.js
Backend/models/list/index.js
+1
-1
index.js
Backend/models/promotion/index.js
+1
-1
index.js
Backend/models/shop/index.js
+5
-2
package-lock.json
Backend/package-lock.json
+96
-59
package.json
Backend/package.json
+2
-0
No files found.
Backend/controllers/auth/index.js
View file @
b8172a1d
const
User
=
require
(
'../../models/user'
);
const
User
=
require
(
"../../models/user"
);
const
bcryptjs
=
require
(
'bcryptjs'
);
const
JWT
=
require
(
'jsonwebtoken'
);
const
config
=
require
(
'../../config'
)
exports
.
getUserById
=
async
(
req
,
res
)
=>
{
try
{
...
...
@@ -8,18 +11,35 @@ exports.getUserById = async (req, res) => {
});
res
.
status
(
200
).
send
(
user
);
}
catch
(
err
)
{
console
.
log
(
err
)
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
}
};
createToken
=
id
=>
{
return
JWT
.
sign
({
id
},
config
.
JWT_SECRET
);
};
exports
.
register
=
async
(
req
,
res
)
=>
{
try
{
const
data
=
req
.
body
;
await
User
.
create
(
data
)
res
.
status
(
200
).
send
(
"Token"
);
const
registerData
=
req
.
body
;
const
user
=
await
User
.
findOne
({
where
:
{
email
:
registerData
.
email
}
});
if
(
user
)
{
return
res
.
status
(
400
).
json
({
message
:
"อีเมลนี้ถูกใช้งานแล้ว"
});
}
else
{
const
passwordHash
=
await
bcryptjs
.
hash
(
registerData
.
password
,
10
);
const
newUser
=
await
User
.
create
({
name
:
registerData
.
name
,
email
:
registerData
.
email
,
password
:
passwordHash
});
const
token
=
await
createToken
(
newUser
.
id
);
res
.
status
(
200
).
send
(
"success"
);
}
}
catch
(
err
)
{
console
.
log
(
err
)
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
}
\ No newline at end of file
};
Backend/models/booking/index.js
View file @
b8172a1d
...
...
@@ -17,9 +17,9 @@ module.exports = db.sequelize.define("users", {
type
:
Sequelize
.
INTEGER
},
bookingDete
:
{
type
:
Sequelize
.
STRING
type
:
Sequelize
.
DATE
},
bookingTime
:
{
type
:
Sequelize
.
STRING
type
:
Sequelize
.
TIME
}
});
Backend/models/list/index.js
View file @
b8172a1d
...
...
@@ -14,7 +14,7 @@ module.exports = db.sequelize.define("users", {
type
:
Sequelize
.
INTEGER
},
listTime
:
{
type
:
Sequelize
.
STRING
type
:
Sequelize
.
INTEGER
},
shopID
:
{
type
:
Sequelize
.
INTEGER
...
...
Backend/models/promotion/index.js
View file @
b8172a1d
...
...
@@ -9,7 +9,7 @@ module.exports = db.sequelize.define("users", {
},
promotionDete
:
{
type
:
Sequelize
.
STRING
type
:
Sequelize
.
DATE
},
shopID
:
{
type
:
Sequelize
.
INTEGER
...
...
Backend/models/shop/index.js
View file @
b8172a1d
...
...
@@ -12,10 +12,10 @@ module.exports = db.sequelize.define("users", {
type
:
Sequelize
.
INTEGER
},
shopTimeopen
:
{
type
:
Sequelize
.
STRING
type
:
Sequelize
.
TIME
},
shopTimeClose
:
{
type
:
Sequelize
.
STRING
type
:
Sequelize
.
TIME
},
shopAddress
:
{
type
:
Sequelize
.
STRING
...
...
@@ -28,5 +28,8 @@ module.exports = db.sequelize.define("users", {
},
shopMap
:
{
type
:
Sequelize
.
STRING
},
shopType
:
{
type
:
Sequelize
.
ENUM
(
'สปาและนวด'
,
'ผิวหน้า'
,
'ขนตาและคิ้ว'
,
'ทำเล็บ'
,
'ชาลอน'
,
'แต่งหน้าทำผม'
)
}
});
Backend/package-lock.json
View file @
b8172a1d
...
...
@@ -79,10 +79,10 @@
"integrity"
:
"sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
,
"dev"
:
true
},
"b
ignumber.
js"
:
{
"version"
:
"
9.0.0
"
,
"resolved"
:
"https://registry.npmjs.org/b
ignumber.js/-/bignumber.js-9.0.0
.tgz"
,
"integrity"
:
"sha
512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A=
="
"b
crypt
js"
:
{
"version"
:
"
2.4.3
"
,
"resolved"
:
"https://registry.npmjs.org/b
cryptjs/-/bcryptjs-2.4.3
.tgz"
,
"integrity"
:
"sha
1-mrVie5PmBiH/fNrF2pczAn3x0Ms
="
},
"binary-extensions"
:
{
"version"
:
"2.0.0"
,
...
...
@@ -146,6 +146,11 @@
"fill-range"
:
"^7.0.1"
}
},
"buffer-equal-constant-time"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz"
,
"integrity"
:
"sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk="
},
"bytes"
:
{
"version"
:
"3.1.0"
,
"resolved"
:
"https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz"
,
...
...
@@ -278,11 +283,6 @@
"resolved"
:
"https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz"
,
"integrity"
:
"sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
},
"core-util-is"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz"
,
"integrity"
:
"sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"cors"
:
{
"version"
:
"2.8.5"
,
"resolved"
:
"https://registry.npmjs.org/cors/-/cors-2.8.5.tgz"
,
...
...
@@ -375,6 +375,14 @@
"integrity"
:
"sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI="
,
"dev"
:
true
},
"ecdsa-sig-formatter"
:
{
"version"
:
"1.0.11"
,
"resolved"
:
"https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz"
,
"integrity"
:
"sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ=="
,
"requires"
:
{
"safe-buffer"
:
"^5.0.1"
}
},
"ee-first"
:
{
"version"
:
"1.1.1"
,
"resolved"
:
"https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz"
,
...
...
@@ -806,17 +814,55 @@
"has-symbols"
:
"^1.0.1"
}
},
"isarray"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
,
"integrity"
:
"sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"isexe"
:
{
"version"
:
"2.0.0"
,
"resolved"
:
"https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz"
,
"integrity"
:
"sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
,
"dev"
:
true
},
"jsonwebtoken"
:
{
"version"
:
"8.5.1"
,
"resolved"
:
"https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz"
,
"integrity"
:
"sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w=="
,
"requires"
:
{
"jws"
:
"^3.2.2"
,
"lodash.includes"
:
"^4.3.0"
,
"lodash.isboolean"
:
"^3.0.3"
,
"lodash.isinteger"
:
"^4.0.4"
,
"lodash.isnumber"
:
"^3.0.3"
,
"lodash.isplainobject"
:
"^4.0.6"
,
"lodash.isstring"
:
"^4.0.1"
,
"lodash.once"
:
"^4.0.0"
,
"ms"
:
"^2.1.1"
,
"semver"
:
"^5.6.0"
},
"dependencies"
:
{
"ms"
:
{
"version"
:
"2.1.2"
,
"resolved"
:
"https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
,
"integrity"
:
"sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"jwa"
:
{
"version"
:
"1.4.1"
,
"resolved"
:
"https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz"
,
"integrity"
:
"sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA=="
,
"requires"
:
{
"buffer-equal-constant-time"
:
"1.0.1"
,
"ecdsa-sig-formatter"
:
"1.0.11"
,
"safe-buffer"
:
"^5.0.1"
}
},
"jws"
:
{
"version"
:
"3.2.2"
,
"resolved"
:
"https://registry.npmjs.org/jws/-/jws-3.2.2.tgz"
,
"integrity"
:
"sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA=="
,
"requires"
:
{
"jwa"
:
"^1.4.1"
,
"safe-buffer"
:
"^5.0.1"
}
},
"latest-version"
:
{
"version"
:
"3.1.0"
,
"resolved"
:
"https://registry.npmjs.org/latest-version/-/latest-version-3.1.0.tgz"
,
...
...
@@ -831,6 +877,41 @@
"resolved"
:
"https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz"
,
"integrity"
:
"sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
},
"lodash.includes"
:
{
"version"
:
"4.3.0"
,
"resolved"
:
"https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz"
,
"integrity"
:
"sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8="
},
"lodash.isboolean"
:
{
"version"
:
"3.0.3"
,
"resolved"
:
"https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz"
,
"integrity"
:
"sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY="
},
"lodash.isinteger"
:
{
"version"
:
"4.0.4"
,
"resolved"
:
"https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz"
,
"integrity"
:
"sha1-YZwK89A/iwTDH1iChAt3sRzWg0M="
},
"lodash.isnumber"
:
{
"version"
:
"3.0.3"
,
"resolved"
:
"https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz"
,
"integrity"
:
"sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w="
},
"lodash.isplainobject"
:
{
"version"
:
"4.0.6"
,
"resolved"
:
"https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz"
,
"integrity"
:
"sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs="
},
"lodash.isstring"
:
{
"version"
:
"4.0.1"
,
"resolved"
:
"https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz"
,
"integrity"
:
"sha1-1SfftUVuynzJu5XV2ur4i6VKVFE="
},
"lodash.once"
:
{
"version"
:
"4.1.1"
,
"resolved"
:
"https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz"
,
"integrity"
:
"sha1-DdOXEhPHxW34gJd9UEyI+0cal6w="
},
"long"
:
{
"version"
:
"4.0.0"
,
"resolved"
:
"https://registry.npmjs.org/long/-/long-4.0.0.tgz"
,
...
...
@@ -926,17 +1007,6 @@
"resolved"
:
"https://registry.npmjs.org/ms/-/ms-2.0.0.tgz"
,
"integrity"
:
"sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"mysql"
:
{
"version"
:
"2.18.1"
,
"resolved"
:
"https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz"
,
"integrity"
:
"sha512-Bca+gk2YWmqp2Uf6k5NFEurwY/0td0cpebAucFpY/3jhrwrVGuxU2uQFCHjU19SJfje0yQvi+rVWdq78hR5lig=="
,
"requires"
:
{
"bignumber.js"
:
"9.0.0"
,
"readable-stream"
:
"2.3.7"
,
"safe-buffer"
:
"5.1.2"
,
"sqlstring"
:
"2.3.1"
}
},
"mysql2"
:
{
"version"
:
"2.1.0"
,
"resolved"
:
"https://registry.npmjs.org/mysql2/-/mysql2-2.1.0.tgz"
,
...
...
@@ -1151,11 +1221,6 @@
"integrity"
:
"sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw="
,
"dev"
:
true
},
"process-nextick-args"
:
{
"version"
:
"2.0.1"
,
"resolved"
:
"https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz"
,
"integrity"
:
"sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
},
"proxy-addr"
:
{
"version"
:
"2.0.5"
,
"resolved"
:
"https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz"
,
...
...
@@ -1209,20 +1274,6 @@
"strip-json-comments"
:
"~2.0.1"
}
},
"readable-stream"
:
{
"version"
:
"2.3.7"
,
"resolved"
:
"https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz"
,
"integrity"
:
"sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw=="
,
"requires"
:
{
"core-util-is"
:
"~1.0.0"
,
"inherits"
:
"~2.0.3"
,
"isarray"
:
"~1.0.0"
,
"process-nextick-args"
:
"~2.0.0"
,
"safe-buffer"
:
"~5.1.1"
,
"string_decoder"
:
"~1.1.1"
,
"util-deprecate"
:
"~1.0.1"
}
},
"readdirp"
:
{
"version"
:
"3.3.0"
,
"resolved"
:
"https://registry.npmjs.org/readdirp/-/readdirp-3.3.0.tgz"
,
...
...
@@ -1280,8 +1331,7 @@
"semver"
:
{
"version"
:
"5.7.1"
,
"resolved"
:
"https://registry.npmjs.org/semver/-/semver-5.7.1.tgz"
,
"integrity"
:
"sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
,
"dev"
:
true
"integrity"
:
"sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
},
"semver-diff"
:
{
"version"
:
"2.1.0"
,
...
...
@@ -1451,14 +1501,6 @@
"function-bind"
:
"^1.1.1"
}
},
"string_decoder"
:
{
"version"
:
"1.1.1"
,
"resolved"
:
"https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz"
,
"integrity"
:
"sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg=="
,
"requires"
:
{
"safe-buffer"
:
"~5.1.0"
}
},
"strip-ansi"
:
{
"version"
:
"4.0.0"
,
"resolved"
:
"https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz"
,
...
...
@@ -1609,11 +1651,6 @@
"safe-buffer"
:
"^5.1.2"
}
},
"util-deprecate"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
,
"integrity"
:
"sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"utils-merge"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz"
,
...
...
Backend/package.json
View file @
b8172a1d
...
...
@@ -4,9 +4,11 @@
"description"
:
""
,
"main"
:
"server.js"
,
"dependencies"
:
{
"bcryptjs"
:
"^2.4.3"
,
"body-parser"
:
"^1.19.0"
,
"cors"
:
"^2.8.5"
,
"express"
:
"^4.17.1"
,
"jsonwebtoken"
:
"^8.5.1"
,
"mysql2"
:
"^2.1.0"
,
"sequelize"
:
"^5.21.3"
,
"util"
:
"^0.12.1"
...
...
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