Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ts 1000 #360

Open
wants to merge 226 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
226 commits
Select commit Hold shift + click to select a range
82b4a3d
feat: project init
evaaaaawu Jun 8, 2023
78ce236
Merge pull request #1 from thpss91103/TS-24
thpss91103 Jun 8, 2023
de7dba2
Ts-25 (#2)
gary86442 Jun 8, 2023
22b744d
feat:add tweets page and tweet modal
arubakingpikachu Jun 9, 2023
5cdc621
feat:add reply modal
arubakingpikachu Jun 9, 2023
ca5bf56
feat: add signup process
evaaaaawu Jun 9, 2023
dc21879
feat: use flash messages on signup page
evaaaaawu Jun 9, 2023
e168fc1
feat: add admin login page
thpss91103 Jun 9, 2023
db2a170
feat: add style.css and admin tweets page
thpss91103 Jun 9, 2023
174f3c5
feat: add admin users page
thpss91103 Jun 9, 2023
329736d
Merge pull request #4 from thpss91103/TS-3
thpss91103 Jun 9, 2023
27e50bb
feat:add followship page
arubakingpikachu Jun 9, 2023
75b1fb5
Ts-39 (#3)
gary86442 Jun 9, 2023
1857d8e
Merge branch 'main' into TS-52
gary86442 Jun 9, 2023
328012b
Merge pull request #5 from thpss91103/TS-52
gary86442 Jun 9, 2023
7c09d5a
feat:add follow or unfollow botton
arubakingpikachu Jun 9, 2023
5980747
feat: add user-other page
thpss91103 Jun 10, 2023
40892e2
feat: add user-self page
thpss91103 Jun 10, 2023
3db9be3
style: modify user/self/follower & following pages
evaaaaawu Jun 10, 2023
0fc93e4
fix: git merge origin/main conflict
evaaaaawu Jun 10, 2023
e6c4aab
Merge remote-tracking branch 'origin/TS-8'
evaaaaawu Jun 10, 2023
f594190
feat: modify user-tab route & other user page
thpss91103 Jun 10, 2023
ce5da0e
feat: add admin route
thpss91103 Jun 10, 2023
5b93681
Merge pull request #7 from thpss91103/TS-44
gary86442 Jun 10, 2023
aa967b5
Merge branch 'main' into TS-40
gary86442 Jun 10, 2023
323eea2
Merge pull request #8 from thpss91103/TS-40
gary86442 Jun 10, 2023
486e493
feat: add admin login function
thpss91103 Jun 10, 2023
3bbcc4b
feat:add view all tweets feat
arubakingpikachu Jun 10, 2023
5825cbe
Merge branch 'main' into TS-31
gary86442 Jun 11, 2023
5a83484
Merge pull request #9 from thpss91103/TS-31
gary86442 Jun 11, 2023
16156bc
feat:add _helper
arubakingpikachu Jun 11, 2023
c72e735
feat:add authenticated
arubakingpikachu Jun 11, 2023
873be1f
Merge remote-tracking branch 'origin/TS-21'
evaaaaawu Jun 11, 2023
edf14e6
style: eslint format
evaaaaawu Jun 11, 2023
2aa150b
feat: add signin and logout process
evaaaaawu Jun 11, 2023
cc55251
feat: admin can read all tweets
thpss91103 Jun 11, 2023
6b4284c
feat: use flash messages on sigin page
evaaaaawu Jun 11, 2023
18ee790
feat:add view tweet and replies
arubakingpikachu Jun 11, 2023
c9e4ed2
feat: finished admin page render user
thpss91103 Jun 11, 2023
942f1c3
Ts- 48 (#12)
gary86442 Jun 11, 2023
e584c0e
feat: modify admin controller
thpss91103 Jun 11, 2023
0d98c69
feat: modify message cover view
thpss91103 Jun 11, 2023
1f09dd2
Merge branch 'main' into TS-36
gary86442 Jun 11, 2023
b10d249
Merge pull request #14 from thpss91103/TS-36
gary86442 Jun 11, 2023
3681db5
Merge branch 'main' into TS-28
thpss91103 Jun 11, 2023
b3c48c9
Merge pull request #11 from thpss91103/TS-28
thpss91103 Jun 11, 2023
7bb58ce
feat: debug other-user and self-user page
thpss91103 Jun 11, 2023
4398dfc
Merge pull request #16 from thpss91103/TS-60
gary86442 Jun 12, 2023
074cc5a
fix: user controller 標點符號錯誤 (#17)
gary86442 Jun 12, 2023
0bf1f26
feat: modify models user.js isEmail data
thpss91103 Jun 12, 2023
f405201
feat:add default user avatar
arubakingpikachu Jun 12, 2023
225cc9f
fix2
arubakingpikachu Jun 12, 2023
c63938f
feat:add reply page likequantity
arubakingpikachu Jun 12, 2023
ca3f3af
feat: add edit account feature
evaaaaawu Jun 12, 2023
6d2e7dd
Merge pull request #13 from thpss91103/TS-33
evaaaaawu Jun 12, 2023
ed5cc16
Merge remote-tracking branch 'origin/TS-26' into TS-30
evaaaaawu Jun 12, 2023
4de7f9a
Merge remote-tracking branch 'origin/main' into TS-26
evaaaaawu Jun 12, 2023
c25acb9
feat:update right sidebar render by top-10-followers user
gary86442 Jun 12, 2023
d0622d9
Merge branch 'main' into TS-63
thpss91103 Jun 12, 2023
01df7f4
feat: modify models user isEmail
thpss91103 Jun 12, 2023
1aa67fc
Merge pull request #19 from thpss91103/TS-63
thpss91103 Jun 12, 2023
2e5c3a9
Merge pull request #20 from thpss91103/TS-62
gary86442 Jun 12, 2023
676e95d
Merge branch 'main' into TS-26
thpss91103 Jun 12, 2023
f1121e5
Merge pull request #18 from thpss91103/TS-26
thpss91103 Jun 12, 2023
10da205
feat: authenticated debug
thpss91103 Jun 12, 2023
add0a40
Merge branch 'main' into TS-62
thpss91103 Jun 12, 2023
9b3b2d1
feat: authenticated debug
thpss91103 Jun 12, 2023
7a3bda6
feat: debug tweets and user test.spec
thpss91103 Jun 12, 2023
6c35e22
Merge pull request #21 from thpss91103/TS-62
thpss91103 Jun 12, 2023
8d611d9
feat: done
thpss91103 Jun 12, 2023
9087b6f
feat: add edit user profile feature
evaaaaawu Jun 12, 2023
7a8edc5
Merge branch 'main' into TS-65
thpss91103 Jun 12, 2023
0de5243
Merge pull request #22 from thpss91103/TS-65
gary86442 Jun 12, 2023
847a47d
feat: add edit user profile feature
evaaaaawu Jun 12, 2023
934b7da
fix:解決衝突
gary86442 Jun 12, 2023
e942993
feat:add tweet reply page modal
arubakingpikachu Jun 13, 2023
27f26ab
style: eslint format
evaaaaawu Jun 13, 2023
e75d141
Merge branch 'main' into TS-30
evaaaaawu Jun 13, 2023
176fa40
fix: handlebars else doesn't match if
evaaaaawu Jun 13, 2023
5746df2
feat:modify config for heroku (#25)
gary86442 Jun 13, 2023
ad08a35
style: modify user edit modal
evaaaaawu Jun 13, 2023
cf1b77d
Merge branch 'TS-30' of https://github.com/thpss91103/twitter-fullsta…
gary86442 Jun 13, 2023
a57d7ce
feat: modify left sidebar active
thpss91103 Jun 13, 2023
a9cd710
Merge pull request #23 from thpss91103/TS-30
thpss91103 Jun 13, 2023
088ca5f
fix:user-edit-modal name of introduction
gary86442 Jun 13, 2023
3411f70
fix: update introduction
evaaaaawu Jun 13, 2023
bbba302
Merge branch 'TS-67' of https://github.com/thpss91103/twitter-fullsta…
gary86442 Jun 13, 2023
327e739
Merge pull request #26 from thpss91103/TS-67
gary86442 Jun 13, 2023
140b72d
Merge branch 'TS-34' of https://github.com/thpss91103/twitter-fullsta…
gary86442 Jun 13, 2023
61231c6
feat:add reply modal
gary86442 Jun 13, 2023
bc38b42
feat: modify page position
thpss91103 Jun 13, 2023
e720e1f
feat: modify all page position
thpss91103 Jun 13, 2023
b9e49ee
Merge branch 'main' into TS-59
thpss91103 Jun 13, 2023
372f35e
fix: reply routes
evaaaaawu Jun 13, 2023
d232da9
Merge pull request #28 from thpss91103/TS-59
gary86442 Jun 13, 2023
fffe285
Merge pull request #27 from thpss91103/TS-30
thpss91103 Jun 13, 2023
fad0932
Merge branch 'TS-34'
evaaaaawu Jun 13, 2023
a249de9
fix: The partial reply-modal could not be found
evaaaaawu Jun 13, 2023
bf1f227
Merge pull request #29 from thpss91103/TS-1
gary86442 Jun 13, 2023
ae61ad5
fix: tweets right-sidebar
evaaaaawu Jun 13, 2023
9296e65
Merge pull request #30 from thpss91103/TS-1
gary86442 Jun 13, 2023
e6e4ec8
feat: add admin user sort
thpss91103 Jun 13, 2023
bc39651
Merge pull request #31 from thpss91103/TS-66
gary86442 Jun 13, 2023
34c744a
feat: modify left sidebar
thpss91103 Jun 13, 2023
a844544
Merge pull request #32 from thpss91103/TS-2
gary86442 Jun 13, 2023
dd65ce5
feat: add imgur api
evaaaaawu Jun 13, 2023
71c53a2
fix: tweets logo link
evaaaaawu Jun 13, 2023
a58e08f
Merge pull request #33 from thpss91103/TS-72
gary86442 Jun 13, 2023
de49093
feat:add tweet post
arubakingpikachu Jun 13, 2023
ea52731
feat:add enter profife by avatar
arubakingpikachu Jun 13, 2023
3b8bf52
fix:fix view
arubakingpikachu Jun 13, 2023
a897d11
fix: user can not see other users profile
evaaaaawu Jun 14, 2023
ef834a4
Merge pull request #37 from thpss91103/TS-37
evaaaaawu Jun 14, 2023
9c5c73b
fix:fix error messages
arubakingpikachu Jun 14, 2023
7abd49a
Merge remote-tracking branch 'origin/main' into TS-73
evaaaaawu Jun 14, 2023
2948b5f
feat: add back icon button
evaaaaawu Jun 14, 2023
07f488a
feat: click tweet button and see #tweetModal
evaaaaawu Jun 14, 2023
77ce828
Merge pull request #40 from thpss91103/TS-73
thpss91103 Jun 14, 2023
52cbd9b
Ts 75 (#39)
gary86442 Jun 14, 2023
ed077a1
feat: add user self tweet page
thpss91103 Jun 14, 2023
5c4d4a5
feat: add user-self-tweets page and user-tab-active
thpss91103 Jun 14, 2023
d7509fb
feat:修改TWEETS 的回復數量和,喜歡數量,並且把喜歡功能導入。 (#41)
gary86442 Jun 14, 2023
d63ae24
feat: modify user-tab-active
thpss91103 Jun 14, 2023
747e622
Merge pull request #42 from thpss91103/TS-76
gary86442 Jun 14, 2023
65633bc
fix:fix buttons outline
arubakingpikachu Jun 14, 2023
4e02d3a
fix:追蹤功能,修改路由等功能以符合測試檔案,目前全數通過,但追蹤自己的處理未完成。 (#43)
gary86442 Jun 14, 2023
65786eb
feat: add user-self-replies page
thpss91103 Jun 14, 2023
83270d6
Merge branch 'main' into TS-81
thpss91103 Jun 14, 2023
d837eb6
Merge pull request #44 from thpss91103/TS-81
gary86442 Jun 15, 2023
2f8f26b
Merge remote-tracking branch 'origin/main' into TS-84
arubakingpikachu Jun 15, 2023
4a25571
fix:fix sign up by add role field
arubakingpikachu Jun 15, 2023
ef84ab2
Merge branch 'main' into TS-84
arubakingpikachu Jun 15, 2023
49f1120
feat: add user-self-likes page
thpss91103 Jun 15, 2023
9f4f428
Merge pull request #45 from thpss91103/TS-84
evaaaaawu Jun 15, 2023
a6b6ef7
feat: modify admin x-mark and user avatar import
thpss91103 Jun 15, 2023
5527469
Merge pull request #46 from thpss91103/TS-82
gary86442 Jun 15, 2023
5d9106c
Merge pull request #47 from thpss91103/TS-90
gary86442 Jun 15, 2023
5cea2f4
fix:change the color of bottons and textarea border
arubakingpikachu Jun 15, 2023
260ce20
feat: modify avatar style & account add @ & setting viwe
thpss91103 Jun 15, 2023
794b94a
Ts 86 (#48)
gary86442 Jun 15, 2023
0e3b200
feat: add following and follower list
evaaaaawu Jun 15, 2023
1d9c450
Ts 101 (#50)
gary86442 Jun 15, 2023
ac853be
Merge branch 'main' into TS-79
evaaaaawu Jun 15, 2023
8199ed8
Merge pull request #49 from thpss91103/TS-79
evaaaaawu Jun 15, 2023
5190beb
Merge branch 'main' into TS-88
thpss91103 Jun 15, 2023
90274cb
Merge pull request #51 from thpss91103/TS-88
thpss91103 Jun 15, 2023
46f005a
fix:add hr
arubakingpikachu Jun 15, 2023
bb05106
fix:change border color of buttons
arubakingpikachu Jun 15, 2023
8bd67be
feat: modify avatar radius & add @ to account & setting page add spac…
thpss91103 Jun 15, 2023
91c1fd9
fix: eslint style
evaaaaawu Jun 15, 2023
3a3da00
Merge branch 'main' into TS-95
thpss91103 Jun 15, 2023
943d043
Merge remote-tracking branch 'origin/main'
evaaaaawu Jun 15, 2023
b91bfa3
feat: add link on avatar to user profile
evaaaaawu Jun 15, 2023
6b4dda6
Merge pull request #53 from thpss91103/TS-87
thpss91103 Jun 15, 2023
c10c5b1
fix:再次補上追蹤功能 (#54)
gary86442 Jun 15, 2023
143c594
fix: sidebar-right confloc
gary86442 Jun 15, 2023
5d9aab3
fix:解決衝突sidebars-right
gary86442 Jun 15, 2023
f38cd08
Merge pull request #52 from thpss91103/TS-95
gary86442 Jun 15, 2023
34f72d6
Ts-109 再補上一次 修正過的追隨功能... (#55)
gary86442 Jun 15, 2023
8c009ca
feat:add likeicon svg
arubakingpikachu Jun 15, 2023
7044345
fix:修復透過發文框使用者頭像查看使用者個人資料功能
arubakingpikachu Jun 15, 2023
ac2e565
fix:修復like機制
arubakingpikachu Jun 15, 2023
d82298a
fix:修正輸入框文字數量限制
arubakingpikachu Jun 15, 2023
d4dbd5e
fix:將單一推文頁的路由加回去
arubakingpikachu Jun 15, 2023
ac8df05
fix:修復點擊首頁推文查看單一貼文頁
arubakingpikachu Jun 15, 2023
b1fb672
fix:修改按鈕、輸入格外框樣式,使點擊時不會出現藍色框線
arubakingpikachu Jun 15, 2023
dc60e12
Merge pull request #56 from thpss91103/TS-111
evaaaaawu Jun 16, 2023
707c9e2
feat: modify tweet reply page
thpss91103 Jun 16, 2023
110b3f6
fix: some redirect feature
evaaaaawu Jun 16, 2023
1951a78
fix-加粗推文回覆區塊和tweets間的bar
arubakingpikachu Jun 16, 2023
b941294
fix: following & follower pages follow button feature
evaaaaawu Jun 16, 2023
ff580fa
Merge pull request #59 from thpss91103/TS-100
thpss91103 Jun 16, 2023
03ede55
Merge pull request #60 from thpss91103/TS-113
thpss91103 Jun 16, 2023
c275731
Merge pull request #57 from thpss91103/TS-111
gary86442 Jun 16, 2023
427e2b6
feat: modify follower & following page
thpss91103 Jun 16, 2023
baf86dd
Merge pull request #61 from thpss91103/TS-106
gary86442 Jun 16, 2023
098c9f6
TS-104 修改 右邊欄 VIEWS : 不能追蹤自己 (#63)
gary86442 Jun 16, 2023
98e3b4c
feat: modify right-sidebar & follow page add right-sidebar & modify p…
thpss91103 Jun 16, 2023
00bcdb0
feat:修正單篇tweet頁無法unlike問題
arubakingpikachu Jun 16, 2023
53ff8bd
fix:解除畫面衝突
arubakingpikachu Jun 16, 2023
2eb235f
fix:更新like狀態改變時的按鈕圖片
arubakingpikachu Jun 16, 2023
3b88084
fix: delete . on each tweet description
evaaaaawu Jun 16, 2023
64dde08
Merge pull request #65 from thpss91103/TS-112
evaaaaawu Jun 16, 2023
5ce60da
feat: modify admin-user page avatar & modal avatar
thpss91103 Jun 16, 2023
98e4681
Merge pull request #64 from thpss91103/TS-114
gary86442 Jun 16, 2023
7a4d6ce
Merge pull request #66 from thpss91103/TS-117
gary86442 Jun 16, 2023
0b433bb
fix:can not triger reply modal event listener
gary86442 Jun 16, 2023
2e9bed6
Merge pull request #67 from thpss91103/TS-123
thpss91103 Jun 16, 2023
2d283db
fix:調整頁面不能讀取到,登入的使用者問題,並依據此調整相依追隨喜愛等功能 (#68)
gary86442 Jun 16, 2023
56954c9
fix:修正首頁推文回覆modal使用者頭像無法顯示問題
arubakingpikachu Jun 17, 2023
1c7d84b
Merge pull request #69 from thpss91103/TS-126
evaaaaawu Jun 17, 2023
f1a4420
feat: debug post modal avatar
thpss91103 Jun 17, 2023
1c94a67
feat: debug reply-list modal
thpss91103 Jun 17, 2023
f8f711d
Merge pull request #70 from thpss91103/TS-124
thpss91103 Jun 17, 2023
50c7619
feat: pass user login spec
thpss91103 Jun 17, 2023
acec73a
Merge pull request #71 from thpss91103/TS-128
gary86442 Jun 17, 2023
09bb979
docs: update README
evaaaaawu Jun 17, 2023
459499d
Merge branch 'main' into TS-69
evaaaaawu Jun 17, 2023
395d79e
Ts 125 修繕所有區域的 喜愛及回復MODAL資料帶入 (#73)
gary86442 Jun 17, 2023
10a04ab
feat: pass #like & #nulike 1
thpss91103 Jun 17, 2023
5d9e209
Merge pull request #72 from thpss91103/TS-69
thpss91103 Jun 17, 2023
190df5f
fix:user/tweets 頁面的 modal大頭貼、其他modal的大頭貼。 (#74)
gary86442 Jun 17, 2023
722b2de
feat: debug login test
thpss91103 Jun 17, 2023
6a9f6d5
Merge pull request #75 from thpss91103/TS-135
gary86442 Jun 17, 2023
2bde8c0
Merge pull request #76 from thpss91103/TS-139
gary86442 Jun 17, 2023
6c8a777
feat: debug tweet test unlike
thpss91103 Jun 17, 2023
579e8ea
fix:修正reply各項變數以符合測試檔案 (#77)
gary86442 Jun 17, 2023
5ec7ac9
Merge pull request #78 from thpss91103/TS-136
gary86442 Jun 17, 2023
7316c69
fix:調整postTweet,已通過測試。 (#79)
gary86442 Jun 18, 2023
079def0
feat: tweet tset all pass
thpss91103 Jun 18, 2023
2dd8db0
Merge pull request #80 from thpss91103/TS-142
gary86442 Jun 18, 2023
ce7f606
feat: modify font-size & a tag text line
thpss91103 Jun 18, 2023
981a968
feat: fix followship test
thpss91103 Jun 18, 2023
31d7e27
Merge pull request #81 from thpss91103/TS-143
gary86442 Jun 18, 2023
26c3c52
Merge pull request #82 from thpss91103/TS-144
gary86442 Jun 18, 2023
488aced
fix:add order in users:tweets, replies, likes. and getTweet's replies…
gary86442 Jun 18, 2023
86fd856
feat: user test all pass
thpss91103 Jun 18, 2023
9d64af3
Merge pull request #84 from thpss91103/TS-147
gary86442 Jun 18, 2023
0e0278a
fix:修正其他使用者頁按鈕破圖問題
arubakingpikachu Jun 18, 2023
34cf694
Merge pull request #85 from thpss91103/TS-150
evaaaaawu Jun 18, 2023
a40ef72
feat: modify session
thpss91103 Jun 18, 2023
d260af1
docs: update README
evaaaaawu Jun 18, 2023
5dfa124
Merge pull request #86 from thpss91103/TS-148
gary86442 Jun 18, 2023
246f373
Merge pull request #87 from thpss91103/TS-4
thpss91103 Jun 18, 2023
d08dd26
feat:add return at userController signinpage... (#88)
gary86442 Jun 18, 2023
9f514ec
fix: delete passport successRedirect
evaaaaawu Jun 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
IMGUR_CLIENT_ID=
PORT=
SESSION_SECRET=
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/*
/test/*
12 changes: 12 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
env:
browser: true
commonjs: true
es2021: true
extends:
- standard
parserOptions:
ecmaVersion: 12
rules:
arrow-parens:
- warn
- as-needed
53 changes: 53 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
* text=auto

# Source code
*.css text diff=css
*.html text diff=html
*.js text
*.json text

# Documentation
*.markdown text diff=markdown
*.md text diff=markdown
*.txt text

# Templates
*.handlebars text
*.hbs text

# Configs
*.cnf text
*.conf text
*.config text
.editorconfig text
.env text
.env.* text
.gitattributes text
.gitconfig text
*.lock text -diff
package.json text eol=lf
package-lock.json text -diff
yarn.lock text -diff
*.yaml text
*.yml text
browserslist text

# Heroku
Procfile text

# Graphics
*.gif binary
*.ico binary
*.jpg binary
*.jpeg binary
*.pdf binary
*.png binary
# SVG treated as an asset (binary) by default.
*.svg text
# If you want to treat it as binary,
# use the following line instead.
# *.svg binary
*.webp binary

# Ignore files (like .npmignore or .gitignore)
*.*ignore text
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,7 @@ typings/
.fusebox/

# DynamoDB Local files
.dynamodb/
.dynamodb/

temp
upload
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cSpell.words": [
"signin",
"Followship"
]
}
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: NODE_ENV=production node app.js
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Simple Twitter

## **Introduction 專案簡介**

使用 Node.js + Express + MySQL 製作的簡易社群網站,使用者可以註冊帳號、登入,並進行發文、瀏覽他人推文、回覆他人留言、對別人的推文按 Like,以及追蹤其他使用者等。

![](public/screenshots/tweets.jpg)

### 雲端試用

- 試用連結: [https://glacial-reef-40489.herokuapp.com](https://vast-basin-23192.herokuapp.com/)
- 前台試用帳密
- 帳號: user1
- 密碼: 12345678
- 後台試用帳密
- 帳號: root
- 密碼: 12345678

## **Features 功能**

- 使用者可以註冊,並登入帳號使用網站服務
- 使用者能在首頁瀏覽所有的推文 (tweet)
- 使用者能新增推文
- 使用者能回覆別人的推文
- 使用者能對別人的推文按 Like/Unlike
- 使用者可以追蹤/取消追蹤其他使用者
- 使用者能編輯自己的名稱、自我介紹、個人頭像與封面

## **Prerequisites 環境設置**

- [VScode](https://code.visualstudio.com/)
- [Git](https://git-scm.com/downloads)
- [Node.js](https://nodejs.org/en/)
- [nodemon](https://www.npmjs.com/package/nodemon)
- [MySQL Workbench](https://dev.mysql.com/downloads/workbench/)

## **Installation 開始使用**

```
# 開啟終端機 並 Clone 此專案至本機
$ git clone https://github.com/thpss91103/twitter-fullstack-2023.git

# 於終端機進入存放本專案的資料夾
$ cd xxxxx

# 安裝 npm 套件
$ npm install

# 新增.env檔案,並請根據.env.example檔案內資訊設置環境變數

# 修改 config.json 中的 development 設定,使用個人 MySQL 的 username、password 和 database
development": {
"username": "<your username>",
"password": "<your password>",
"database": "<your database>",
"host": "127.0.0.1",
"dialect": "mysql"
}

# 新增資料表和種子資料
$ npx sequelize db:migrate
$ npx sequelize db:seed:all

# 啟動伺服器,執行 app.js 檔案
$ npm run dev

# 若在終端機看到下方訊息代表順利運行,於瀏覽器中輸入該網址(http://localhost:3000)即可開始使用本網站
"App is running on http://localhost:3000"
```

## **Contributors 貢獻者**

[evaaaaawu](https://github.com/evaaaaawu) | [gary86442](https://github.com/gary86442) | [thpss91103](https://github.com/thpss91103) | [arubakingpikachu](https://github.com/arubakingpikachu)
12 changes: 6 additions & 6 deletions _helpers.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function ensureAuthenticated(req) {
return req.isAuthenticated();
const ensureAuthenticated = req => {
return req.isAuthenticated()
}

function getUser(req) {
return req.user;
const getUser = req => {
return req.user || null
}

module.exports = {
ensureAuthenticated,
getUser,
};
getUser
}
50 changes: 46 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,55 @@
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config()
}

const path = require('path')
const express = require('express')
const helpers = require('./_helpers');
const exphbs = require('express-handlebars')
const routes = require('./routes')
const methodOverride = require('method-override')
const session = require('express-session')
const passport = require('./config/passport')
const flash = require('connect-flash')
const helpers = require('./_helpers')
const handlebarsHelpers = require('./helpers/handlebars-helpers')

const app = express()
const port = 3000
const port = process.env.PORT || 3000
const SESSION_SECRET = process.env.SESSION_SECRET || 'ThisIsMySecret'

app.engine(
'hbs',
exphbs({ defaultLayout: 'main', extname: '.hbs', helpers: handlebarsHelpers })
)
app.set('view engine', 'hbs')

app.use(express.static('public'))
app.use(express.urlencoded({ extended: true }))
app.use(
session({
secret: SESSION_SECRET,
resave: false,
saveUninitialized: true
})
)
app.use(passport.initialize())
app.use(passport.session())
app.use(flash())
app.use(methodOverride('_method'))
app.use('/upload', express.static(path.join(__dirname, 'upload')))
app.use((req, res, next) => {
res.locals.success_messages = req.flash('success_messages')
res.locals.error_messages = req.flash('error_messages')
res.locals.user = helpers.getUser(req)
next()
})
// use helpers.getUser(req) to replace req.user
// use helpers.ensureAuthenticated(req) to replace req.isAuthenticated()

app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
app.use(routes)

app.listen(port, () =>
console.log(`App is running on http://localhost:${port}`)
)

module.exports = app
8 changes: 2 additions & 6 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
"logging": false
},
"production": {
"username": "root",
"password": null,
"database": "database_production",
"host": "127.0.0.1",
"dialect": "mysql"
"use_env_variable": "CLEARDB_DATABASE_URL"
},
"travis": {
"username": "travis",
Expand All @@ -28,4 +24,4 @@
"dialect": "mysql",
"logging": false
}
}
}
68 changes: 68 additions & 0 deletions config/passport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const passport = require('passport')
const LocalStrategy = require('passport-local')
const bcrypt = require('bcryptjs')
const { User, Like } = require('../models')
// set up Passport strategy
passport.use(
'user',
new LocalStrategy(
// customize user field
{
usernameField: 'account',
passwordField: 'password',
passReqToCallback: true
},
// authenticate user
(req, account, password, cb) => {
User.findOne({ where: { account, role: 'user' } }).then(user => {
if (!user) { return cb(null, false, req.flash('error_messages', '帳號尚未註冊!')) }
bcrypt.compare(password, user.password).then(res => {
if (!res) { return cb(null, false, req.flash('error_messages', '密碼錯誤!')) }
return cb(null, user)
})
})
}
)
)
passport.use(
'admin',
new LocalStrategy(
// customize user field
{
usernameField: 'account',
passwordField: 'password',
passReqToCallback: true
},
// authenticate admin
(req, account, password, cb) => {
User.findOne({ where: { account, role: 'admin' } }).then(admin => {
if (!admin) { return cb(null, false, req.flash('error_messages', '此帳號不是admin!')) }
bcrypt.compare(password, admin.password).then(res => {
if (!res) { return cb(null, false, req.flash('error_messages', '密碼錯誤!')) }
return cb(null, admin)
})
})
}
)
)
// serialize and deserialize user
passport.serializeUser((user, cb) => {
cb(null, user.id)
})
passport.deserializeUser(async (id, cb) => {
try {
const user = await User.findByPk(id, {
include: [
// 關聯資料
{ model: Like },
{ model: User, as: 'Followers' },
{ model: User, as: 'Followings' }
]
})
return cb(null, user.toJSON())
} catch (err) {
cb(err)
}
})

module.exports = passport
Loading