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

奧莉薇 張雅婷 Rossi #397

Open
wants to merge 319 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
319 commits
Select commit Hold shift + click to select a range
12c3afe
Merge branch 'master' into feature/adminUsers
chiangjou Aug 26, 2023
3ab0fb3
Merge pull request #17 from Melodystart/feature/adminUsers
chiangjou Aug 26, 2023
375537e
add likeCounts
Melodystart Aug 26, 2023
7e0a3f9
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
Melodystart Aug 26, 2023
3d2621c
merge conflict
Melodystart Aug 26, 2023
ea7d03b
feat: basic style setting
chiangjou Aug 26, 2023
2c42b83
Merge pull request #19 from Melodystart/feature/like
chiangjou Aug 26, 2023
d2dd079
merge conflict
chiangjou Aug 26, 2023
ff6c59d
feat: initialize api server
Melodystart Aug 26, 2023
b763022
feat: modify user signin page UI
chiangjou Aug 26, 2023
803b268
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Aug 26, 2023
93d75c6
Merge pull request #20 from Melodystart/feature/style
chiangjou Aug 26, 2023
172e948
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
Melodystart Aug 26, 2023
ed60821
Merge branch 'master' into feature/userSignin
chiangjou Aug 27, 2023
219af8e
Merge pull request #21 from Melodystart/feature/userSignin
chiangjou Aug 27, 2023
a1433ac
feat:reply modal
Melodystart Aug 27, 2023
6564ca2
feat: modify basic style
chiangjou Aug 28, 2023
905b270
feat: add font-family
chiangjou Aug 28, 2023
7f03ed5
feat: modify form-input css
chiangjou Aug 28, 2023
0d7a24f
feat: modify admin/signin.hbs
chiangjou Aug 28, 2023
6ec043e
feat: modify admin signin UI
chiangjou Aug 28, 2023
485e464
feat: mosify user signin css
chiangjou Aug 28, 2023
8069aed
Merge branch 'master' into feature/style
chiangjou Aug 28, 2023
6dfdef5
Merge branch 'master' into feature/adminSignin
chiangjou Aug 28, 2023
cfca250
Merge branch 'master' into feature/userSignup
chiangjou Aug 28, 2023
43c78a4
Merge pull request #23 from Melodystart/feature/style
Melodystart Aug 28, 2023
95c8cd6
Merge branch 'master' into feature/adminSignin
chiangjou Aug 28, 2023
f00fde2
Merge pull request #24 from Melodystart/feature/adminSignin
chiangjou Aug 28, 2023
c7e235e
Merge branch 'master' into feature/userSignup
chiangjou Aug 28, 2023
8edf7a9
Merge pull request #25 from Melodystart/feature/userSignup
chiangjou Aug 28, 2023
77c4df3
feat: modify admin-navbar
chiangjou Aug 28, 2023
8c0ec8b
feat: modify admin/tweets UI & delete tweet function
chiangjou Aug 29, 2023
575e73b
Merge pull request #26 from Melodystart/feature/adminTweets
Melodystart Aug 29, 2023
e2702e2
feat:完成部分可以瀏覽自己的貼文頁面
carola1408 Aug 29, 2023
aba0345
feat: merge ok
carola1408 Aug 29, 2023
ca22c12
feat: modify signup page UI
chiangjou Aug 29, 2023
94cbdf0
feat: modify user model
chiangjou Aug 30, 2023
8cb62ee
feat: modify like model
chiangjou Aug 30, 2023
a0777ca
feat: modify tweet model
chiangjou Aug 30, 2023
fe37fd0
feat: modify created time
chiangjou Aug 30, 2023
ddea0ee
delete commented code
chiangjou Aug 30, 2023
c979261
feat: modify created time
chiangjou Aug 30, 2023
bc10487
feat: add reply seeders
chiangjou Aug 30, 2023
44b3d1a
feat: add semicolon mark
chiangjou Aug 30, 2023
d5f5c4b
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
Melodystart Aug 30, 2023
4700620
feat: modify routes
chiangjou Aug 30, 2023
87530cd
Merge branch 'master' into feature/userSignup
chiangjou Aug 30, 2023
87d6dc5
Merge branch 'master' into feature/modelSetting
chiangjou Aug 30, 2023
95d84e8
Merge pull request #33 from Melodystart/feature/userSignup
Melodystart Aug 30, 2023
3c32ec5
merge conflict
chiangjou Aug 30, 2023
6ff9ec0
Merge pull request #28 from Melodystart/feature/tweetSeeder
Melodystart Aug 30, 2023
d0514f4
Merge pull request #29 from Melodystart/feature/replySeeder
Melodystart Aug 30, 2023
67279f8
Merge pull request #30 from Melodystart/feature/userSeeder
Melodystart Aug 30, 2023
2288338
Merge pull request #31 from Melodystart/feature/modelSetting
Melodystart Aug 30, 2023
9f59698
merge conflict
chiangjou Aug 30, 2023
2b946c1
Merge branch 'master' into feature/projectSetting
chiangjou Aug 30, 2023
bd7bef2
Merge pull request #27 from Melodystart/feature/projectSetting
chiangjou Aug 30, 2023
fb81393
feat: delete repeated file
chiangjou Aug 30, 2023
fab1ee9
feat: delete repeated file
chiangjou Aug 30, 2023
646073d
feat: add user can reply at tweets page
Melodystart Aug 30, 2023
6522949
feat: show user list
chiangjou Aug 30, 2023
6ff96ab
fix typo
chiangjou Aug 30, 2023
5eca453
feat: merge cnoflict
Melodystart Aug 30, 2023
1494c94
feat: modify style
chiangjou Aug 30, 2023
672a502
feat: merge cnoflict
Melodystart Aug 30, 2023
9112e99
feat: modify container position
chiangjou Aug 30, 2023
e3e1ad8
feat: modify container position
chiangjou Aug 30, 2023
f30c8a4
feat: modify style
chiangjou Aug 30, 2023
a025cd4
Merge pull request #35 from Melodystart/feature/reply
chiangjou Aug 30, 2023
4318d78
Merge pull request #38 from Melodystart/feature/adminTweets
Melodystart Aug 30, 2023
90e3aba
Merge branch 'master' into feature/userSignin
chiangjou Aug 30, 2023
fc0da5f
Merge pull request #37 from Melodystart/feature/adminSignin
Melodystart Aug 30, 2023
87583bd
Merge branch 'master' into feature/adminUsers
chiangjou Aug 30, 2023
2fc4719
Merge pull request #39 from Melodystart/feature/adminUsers
chiangjou Aug 30, 2023
75c0d49
Merge pull request #36 from Melodystart/feature/userSignin
chiangjou Aug 30, 2023
3a301a0
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Aug 30, 2023
4d411c6
feat: add reply page and user avatar
Melodystart Aug 31, 2023
2322e87
Merge pull request #40 from Melodystart/feature/replyPage
chiangjou Aug 31, 2023
c750774
feat: modify admin navbar
chiangjou Aug 31, 2023
b370fab
feat: add followerRecommend at tweets page
Melodystart Aug 31, 2023
f7450c3
feat: add followerRecommend at tweets page
Melodystart Aug 31, 2023
22d3df5
feat: add followerRecommend at tweets page
Melodystart Aug 31, 2023
d562480
feat: modify function about 可以瀏覽自己的貼文頁面
carola1408 Sep 1, 2023
283dab9
feat: add followerRecommend at tweet page
Melodystart Sep 1, 2023
20fe3b1
feat: add error msg
Melodystart Sep 1, 2023
f18b3d7
feat: add error msg
Melodystart Sep 1, 2023
f0e5fca
Merge pull request #42 from Melodystart/feature/followerRecommend
chiangjou Sep 1, 2023
bc8273e
feat modify nave-link color
carola1408 Sep 1, 2023
88ea1d8
feat:完成可以瀏覽自己的貼文頁面
carola1408 Sep 1, 2023
94629c4
feat: modify navbar & main page UI / fix delete tweet function
chiangjou Sep 1, 2023
90c6e2a
feat: modify admin signin UI
chiangjou Sep 1, 2023
9bfbbc0
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Sep 1, 2023
8042e53
feat: modify text color
chiangjou Sep 1, 2023
0851e9f
Merge pull request #43 from Melodystart/feature/adminTweets
chiangjou Sep 1, 2023
4a638fc
Merge branch 'master' into feature/adminSignin
chiangjou Sep 1, 2023
dc905ce
Merge pull request #44 from Melodystart/feature/adminSignin
Melodystart Sep 1, 2023
d7cdda1
feat:切回主幹拉取遠端分支
carola1408 Sep 1, 2023
21e691d
feat: modify admin users page UI
chiangjou Sep 1, 2023
43ed3a1
Merge branch 'master' into feature/adminUsers
chiangjou Sep 1, 2023
8d2feb2
feat: modify user signin page UI
chiangjou Sep 1, 2023
6bb8806
Merge branch 'master' into feature/userSignin
chiangjou Sep 1, 2023
92fc5a9
feat: modify user signup page UI
chiangjou Sep 1, 2023
65f8af3
Merge branch 'master' into feature/userSignup
chiangjou Sep 1, 2023
3167d3e
feat: 提交已解決的衝突
carola1408 Sep 1, 2023
ad163e9
feat: delete repeated file
chiangjou Sep 1, 2023
b9db321
Merge pull request #49 from Melodystart/feature/adminTweets
Melodystart Sep 1, 2023
f6d43a8
Merge pull request #46 from Melodystart/feature/adminUsers
Melodystart Sep 1, 2023
594cb9b
Merge branch 'master' into feature/userSignin
chiangjou Sep 1, 2023
0a5b6e6
Merge pull request #47 from Melodystart/feature/userSignin
chiangjou Sep 1, 2023
31f168a
Merge branch 'master' into feature/userSignup
chiangjou Sep 1, 2023
2c4c32b
Merge pull request #48 from Melodystart/feature/userSignup
chiangjou Sep 1, 2023
8a9861a
feat: revise for test failure
Melodystart Sep 1, 2023
18d5169
feat: modify routes & messages
chiangjou Sep 1, 2023
15557d2
feat: add tweet-controller.js
carola1408 Sep 2, 2023
79fe446
feat: modify handlebars-helpers.js
carola1408 Sep 2, 2023
40d11a0
feat: modify files in models
carola1408 Sep 2, 2023
dc0d1e7
feat: modify style.css
carola1408 Sep 2, 2023
dc31fe2
feat: modify time format
chiangjou Sep 2, 2023
f08cf01
feat: add api file and index.js
carola1408 Sep 2, 2023
02618a0
feat: modify modules file and index.js
carola1408 Sep 2, 2023
6cae931
feat: modify controllers file and add pages file
carola1408 Sep 2, 2023
22be510
feat: modify seeders
carola1408 Sep 2, 2023
1910aee
feat: modify admin file in viewa file
carola1408 Sep 2, 2023
7d88b94
feat: modify main.hbs in layouts file
carola1408 Sep 2, 2023
46da673
feat: modify partials file and add admin-user-card.hbs
carola1408 Sep 2, 2023
d41b2dd
feat: modify signup.hbs and add tweet.hbs
carola1408 Sep 2, 2023
5e1034e
feat: fix admin signin route
chiangjou Sep 2, 2023
8c65f14
feat: add replies-seed-file
carola1408 Sep 2, 2023
e5f2034
feat: modify admin get tweets function
chiangjou Sep 2, 2023
4c31fec
feat: modify tab exchange
chiangjou Sep 2, 2023
8da2e4c
Merge pull request #50 from Melodystart/feature/followerRecommend
chiangjou Sep 2, 2023
1d2c3bb
Merge branch 'master' into feature/projectSetting
chiangjou Sep 2, 2023
bd00158
feat: modify time format
chiangjou Sep 2, 2023
bdf513b
Merge pull request #54 from Melodystart/feature/followerRecommend
Melodystart Sep 2, 2023
60da7d9
Merge pull request #52 from Melodystart/feature/adminTweets
Melodystart Sep 2, 2023
67f7e91
Merge branch 'master' into feature/projectSetting
chiangjou Sep 2, 2023
ebd94e3
Merge pull request #51 from Melodystart/feature/projectSetting
chiangjou Sep 2, 2023
0559504
feat: modify likes count
chiangjou Sep 2, 2023
98c1d31
已經解決
carola1408 Sep 2, 2023
499e2bd
解決合併衝突:修復修改的文件
carola1408 Sep 2, 2023
4f3d68c
merge conflict
chiangjou Sep 2, 2023
e98a960
Merge remote-tracking branch 'origin/master' into feature/user
carola1408 Sep 2, 2023
c8f8ff5
feat:amend UI
Melodystart Sep 2, 2023
ac3ca72
feat: 執行 seeder
carola1408 Sep 2, 2023
f58c31c
feat:amend UI
Melodystart Sep 2, 2023
674aa95
add Procile
Melodystart Sep 2, 2023
698dd06
feat: add messages
chiangjou Sep 2, 2023
0c64b26
Merge pull request #57 from Melodystart/feature/amendUI
chiangjou Sep 2, 2023
62b1053
Merge branch 'master' into feature/adminSignin
chiangjou Sep 2, 2023
598f773
merge conflict
chiangjou Sep 2, 2023
7faec8e
feat: delete edit.hbs
carola1408 Sep 2, 2023
20a2387
Merge pull request #58 from Melodystart/feature/adminSignin
chiangjou Sep 2, 2023
cff7f7f
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Sep 2, 2023
fabc1a5
fix typo
chiangjou Sep 2, 2023
7edc37d
Merge branch 'master' into feature/userSignup
chiangjou Sep 2, 2023
ebac297
merge conflict
chiangjou Sep 2, 2023
63e0275
Merge pull request #60 from Melodystart/feature/userSignup
Melodystart Sep 2, 2023
76f5c47
feat: fix default cover size
chiangjou Sep 2, 2023
684a028
Merge branch 'master' into feature/adminUsers
chiangjou Sep 2, 2023
8000c2d
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Sep 2, 2023
31cab6a
feat: modify config for heroku
Melodystart Sep 2, 2023
7596b02
Merge pull request #62 from Melodystart/feature/setting
chiangjou Sep 2, 2023
2e8285d
Merge pull request #61 from Melodystart/feature/adminUsers
Melodystart Sep 2, 2023
fa5269a
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Sep 2, 2023
d524de6
feat: fix tab color
chiangjou Sep 2, 2023
1314b2e
Merge branch 'master' into feature/adminTweets
chiangjou Sep 2, 2023
986d1a9
Merge pull request #63 from Melodystart/feature/adminTweets
Melodystart Sep 2, 2023
24dc64c
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Sep 2, 2023
d8db778
close log and add console.log
Melodystart Sep 2, 2023
cedaa65
Merge pull request #64 from Melodystart/feature/modal
chiangjou Sep 2, 2023
6eca064
revise API path
Melodystart Sep 2, 2023
b33b1b8
feat: add form messages
chiangjou Sep 2, 2023
46ccd73
Merge pull request #65 from Melodystart/feature/modal
chiangjou Sep 2, 2023
d41ad23
feat: modify form input style
chiangjou Sep 2, 2023
e9efe70
feat: modify 使用者可以連覽自己頁面的功能
carola1408 Sep 2, 2023
2a2a228
Merge pull request #66 from Melodystart/feature/userSignup
Melodystart Sep 2, 2023
2df46e9
Commit message
carola1408 Sep 2, 2023
0e33708
Resolve conflicts in style.css
carola1408 Sep 2, 2023
e435c91
Committing local changes before merge
carola1408 Sep 2, 2023
7a6a05b
feat: fix routes
chiangjou Sep 3, 2023
b08a3c6
feat: fix user model
chiangjou Sep 3, 2023
618aa68
Merge branch 'master' into feature/user
chiangjou Sep 3, 2023
2e93c43
Merge pull request #67 from Melodystart/feature/user
Melodystart Sep 3, 2023
9b618af
feat:6~8 followInfo
Melodystart Sep 3, 2023
3fe79b4
Revert "Feature/user"
Melodystart Sep 3, 2023
c0f071e
Merge pull request #68 from Melodystart/revert-67-feature/user
chiangjou Sep 3, 2023
f47ff9f
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
Melodystart Sep 3, 2023
9bd4005
Merge pull request #69 from Melodystart/feature/followInfo
chiangjou Sep 3, 2023
f9d93c5
revise seed typo
Melodystart Sep 3, 2023
413af46
Merge pull request #70 from Melodystart/feature/seedRevise
chiangjou Sep 3, 2023
a944cf4
revise Recommend Followings
Melodystart Sep 3, 2023
e4531c6
Merge pull request #71 from Melodystart/feature/reviseRecommendFollowing
chiangjou Sep 3, 2023
6c680aa
提交合併的更改
carola1408 Sep 3, 2023
73ca294
fead: modify self.hbs
carola1408 Sep 3, 2023
29b5bea
feat: user pages controllers & routes
chiangjou Sep 3, 2023
857529d
Merge pull request #72 from Melodystart/feature/user
chiangjou Sep 3, 2023
594851c
重新合併程式碼
carola1408 Sep 3, 2023
07d29de
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Sep 3, 2023
8e55139
fix typo
chiangjou Sep 3, 2023
3432c49
Merge pull request #73 from Melodystart/feature/userSignup
Melodystart Sep 4, 2023
a6a207d
add Reply words limit
Melodystart Sep 4, 2023
410958e
Merge pull request #74 from Melodystart/amendReply
chiangjou Sep 4, 2023
37683e3
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Sep 4, 2023
eedbb3c
feat: user navbar & post modal
chiangjou Sep 4, 2023
5ae5b09
Merge branch 'feature/user'
chiangjou Sep 4, 2023
5cc10a3
Merge pull request #75 from Melodystart/feature/user
Melodystart Sep 4, 2023
f3b5390
merge conflict
chiangjou Sep 4, 2023
7557de2
merge conflict
chiangjou Sep 4, 2023
f3ce572
Merge pull request #76 from Melodystart/feature/user
Melodystart Sep 4, 2023
06d626b
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Sep 4, 2023
afdc971
delete repeated modal
chiangjou Sep 4, 2023
a2c7188
feat: fix typo
chiangjou Sep 4, 2023
573f09e
Merge pull request #77 from Melodystart/feature/adminTweets
Melodystart Sep 4, 2023
255d0fa
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Sep 4, 2023
ae0b57c
Merge pull request #78 from Melodystart/feature/user
Melodystart Sep 4, 2023
77b3d79
fix typo & post modal
chiangjou Sep 4, 2023
14f4932
Merge pull request #79 from Melodystart/feature/user
Melodystart Sep 4, 2023
aae8647
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Sep 4, 2023
e765cd6
code review
chiangjou Sep 5, 2023
c8542eb
Merge branch 'master' into feature/userSignup
chiangjou Sep 5, 2023
e54e4d7
feat: modify admin/tweets
chiangjou Aug 26, 2023
b1a9e12
feat: modify admin-navbar UI
chiangjou Aug 26, 2023
8d779d0
feat: add admin delete tweet
chiangjou Aug 27, 2023
6832451
feat: modify admin/tweets UI
chiangjou Aug 27, 2023
d6e7f7a
delete repeated file
chiangjou Sep 5, 2023
0d3697e
Merge pull request #80 from Melodystart/feature/userSignup
Melodystart Sep 5, 2023
eec49f3
Merge branch 'master' of https://github.com/Melodystart/twitter-fulls…
chiangjou Sep 5, 2023
3a09c6d
feat: modify error messages position
chiangjou Sep 5, 2023
c9b558c
feat: modify messages position & style
chiangjou Sep 5, 2023
15e711f
add more user seeders
chiangjou Sep 5, 2023
1cd9d97
Merge branch 'feature/userSeeder'
chiangjou Sep 5, 2023
1730ce8
feat: modify tweet description length
chiangjou Sep 5, 2023
739dbdf
Merge branch 'feature/tweetSeeder'
chiangjou Sep 5, 2023
e0cda0a
feat: modify tweet count
chiangjou Sep 5, 2023
d78c339
Merge branch 'feature/tweetSeeder'
chiangjou Sep 5, 2023
5aff983
feat: add tweets based on users length
chiangjou Sep 5, 2023
1ba5a79
feat: add tweets based on user length
chiangjou Sep 5, 2023
1a1387e
Merge branch 'feature/tweetSeeder'
chiangjou Sep 5, 2023
5e546ba
feat: defined text length
chiangjou Sep 5, 2023
a7386ef
Merge branch 'master' into feature/userSignup
chiangjou Sep 5, 2023
415a584
Merge branch 'master' into feature/userSeeder
chiangjou Sep 5, 2023
b6ab3bd
Merge pull request #84 from Melodystart/feature/tweetSeeder
Melodystart Sep 5, 2023
31969b0
Merge pull request #83 from Melodystart/feature/userSeeder
Melodystart Sep 5, 2023
38401f2
Merge branch 'master' into feature/style
chiangjou Sep 5, 2023
3f3d2a1
Merge pull request #81 from Melodystart/feature/style
chiangjou Sep 5, 2023
beaa862
Merge branch 'master' into feature/userSignup
chiangjou Sep 5, 2023
021922e
Merge pull request #82 from Melodystart/feature/userSignup
chiangjou Sep 5, 2023
c96a863
feat: modify user & setting page routes
chiangjou Sep 5, 2023
aad32b6
clean code
chiangjou Sep 5, 2023
d314561
Merge pull request #85 from Melodystart/feature/user
Melodystart Sep 6, 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
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
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();
function ensureAuthenticated (req) {
return req.isAuthenticated()
}

function getUser(req) {
return req.user;
function getUser (req) {
return req.user
}

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

const express = require('express')
const helpers = require('./_helpers');
const helpers = require('./_helpers')
const exphbs = require('express-handlebars')
const { pages, apis } = require('./routes')
const methodOverride = require('method-override')
const session = require('express-session')
const passport = require('./config/passport')
const flash = require('connect-flash')
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 || 'twitterSECRET'

require('./models/index')

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

// public
app.use(express.static('public'))

// body-parser
app.use(express.urlencoded({ extended: true }))

// json
app.use(express.json())

// session
app.use(session({
secret: SESSION_SECRET,
resave: false,
saveUninitialized: false
}))

// passport
app.use(passport.initialize())
app.use(passport.session())

// method-override
app.use(methodOverride('_method'))

// flash
app.use(flash())
app.use((req, res, next) => {
res.locals.success_messages = req.flash('success_messages')
res.locals.error_messages = req.flash('error_messages')
res.locals.warning_messages = req.flash('warning_messages')
res.locals.info_messages = req.flash('info_messages')
res.locals.signinUser = helpers.getUser(req)
next()
})

// use helpers.getUser(req) to replace req.user
// use helpers.ensureAuthenticated(req) to replace req.isAuthenticated()
app.use('/api', apis)
app.use(pages)

app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
app.listen(port, () => console.log(`App is running on http://localhost:${port}`))

module.exports = app
10 changes: 4 additions & 6 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"password": "password",
"database": "ac_twitter_workspace",
"host": "127.0.0.1",
"dialect": "mysql"
"dialect": "mysql",
"logging": false
},
"test": {
"username": "root",
Expand All @@ -15,11 +16,8 @@
"logging": false
},
"production": {
"username": "root",
"password": null,
"database": "database_production",
"host": "127.0.0.1",
"dialect": "mysql"
"use_env_variable": "MYSQL_DATABASE_URL",
"logging": false
},
"travis": {
"username": "travis",
Expand Down
66 changes: 66 additions & 0 deletions config/passport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const passport = require('passport')
const LocalStrategy = require('passport-local').Strategy
const bcrypt = require('bcryptjs')
const { User, Like } = require('../models')

passport.use('userSignin', new LocalStrategy(
{
usernameField: 'account',
passwordField: 'password',
passReqToCallback: true
},
async (req, account, password, cb) => {
try {
const user = await User.findOne({ where: { account } })
if (!user) return cb(null, false, req.flash('error_messages', '此帳號不存在'))
if (user.role !== 'user') return cb(null, false, req.flash('error_messages', '此帳號不存在'))

const passwordCompare = await bcrypt.compare(password, user.password)
if (!passwordCompare) return cb(null, false, req.flash('error_messages', '帳號或密碼輸入錯誤'))
return cb(null, user)
} catch (err) {
return cb(err)
}
})
)

passport.use('adminSignin', new LocalStrategy({
usernameField: 'account',
passwordField: 'password',
passReqToCallback: true
},
async (req, account, password, cb) => {
try {
const user = await User.findOne({ where: { account } })
if (!user) return cb(null, false, req.flash('error_messages', '此帳號不存在'))
if (user.role !== 'admin') return cb(null, false, req.flash('error_messages', '此帳號不存在'))

const passwordCompare = await bcrypt.compare(password, user.password)
if (!passwordCompare) return cb(null, false, req.flash('error_messages', '帳號或密碼輸入錯誤'))
return cb(null, user)
} catch (err) {
return cb(err)
}
})
)

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
29 changes: 29 additions & 0 deletions controllers/apis/tweet-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { Tweet, User } = require('../../models')
const helpers = require('../../_helpers')

const tweetController = {
getTweet: (req, res, next) => {
return Tweet.findByPk(req.params.id, {
raw: true
})
.then(tweet => {
if (!tweet) throw new Error("Tweet didn't exist!")
User.findByPk(tweet.UserId, {
raw: true
})
.then(user => {
return res.json({
name: user.name,
account: user.account,
avatar: user.avatar,
tweet_id: tweet.id,
createdAt: tweet.createdAt,
description: tweet.description,
loginUserAvatar: helpers.getUser(req).avatar
})
})
})
.catch(err => next(err))
}
}
module.exports = tweetController
Loading