Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이세진
/
dev-profile
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
10
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Lee SeJin
2021-06-08 02:18:00 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
29bf598150cae96a66bedfd7613ed1dbbb04997d
29bf5981
1 parent
dbeca84d
Connect AWS s3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
5 deletions
package.json
src/controllers/userController.js
src/middlewares.js
src/views/editProfile.pug
src/views/userDetail.pug
package.json
View file @
29bf598
...
...
@@ -17,6 +17,7 @@
"author"
:
"Lee SeJin"
,
"license"
:
"MIT"
,
"dependencies"
:
{
"aws-sdk"
:
"^2.922.0"
,
"axios"
:
"^0.21.1"
,
"connect-mongo"
:
"^4.4.1"
,
"dotenv"
:
"^9.0.2"
,
...
...
@@ -25,6 +26,7 @@
"mongoose"
:
"^5.12.9"
,
"morgan"
:
"^1.10.0"
,
"multer"
:
"^1.4.2"
,
"multer-s3"
:
"^2.9.0"
,
"node-fetch"
:
"^2.6.1"
,
"nodemon"
:
"^2.0.7"
,
"passport"
:
"^0.4.1"
,
...
...
src/controllers/userController.js
View file @
29bf598
...
...
@@ -29,7 +29,7 @@ export const getUserDetail = async (req, res) => {
const
user
=
await
User
.
findById
(
id
);
const
totalCon
=
await
getContributions
(
user
.
githubName
);
res
.
render
(
"userDetail"
,
{
page
t
Title
:
"User Detail"
,
pageTitle
:
"User Detail"
,
quote
:
quote
.
quote
,
author
:
quote
.
author
,
user
,
...
...
@@ -67,7 +67,7 @@ export const postEditProfile = async (req, res) => {
const
updatedUser
=
await
User
.
findByIdAndUpdate
(
id
,
{
avatarUrl
:
file
?
file
.
path
:
req
.
session
.
passport
.
user
.
avatarUrl
,
avatarUrl
:
file
?
file
.
location
:
req
.
session
.
passport
.
user
.
avatarUrl
,
name
,
email
,
school
,
...
...
src/middlewares.js
View file @
29bf598
import
multer
from
"multer"
;
import
multerS3
from
"multer-s3"
;
import
aws
from
"aws-sdk"
;
const
s3
=
new
aws
.
S3
({
credentials
:
{
accessKeyId
:
process
.
env
.
AWS_ID
,
secretAccessKey
:
process
.
env
.
AWS_SECRET
}
});
const
multerUploader
=
multerS3
({
s3
:
s3
,
bucket
:
"developer-profile-oss"
,
acl
:
"public-read"
,
})
export
const
localsMiddleware
=
(
req
,
res
,
next
)
=>
{
res
.
locals
.
siteName
=
"Dev Profile"
;
...
...
@@ -27,5 +42,6 @@ export const uploadFiles = multer({
dest
:
"uploads/"
,
limits
:
{
fileSize
:
3000000
}
},
storage
:
multerUploader
});
\ No newline at end of file
...
...
src/views/editProfile.pug
View file @
29bf598
...
...
@@ -3,7 +3,7 @@ extends layouts/main
block content
.form-container
form(action="/users/edit-profile", method="POST", enctype="multipart/form-data")
img(src=`
/
${loggedUser.avatarUrl}`)
img(src=`${loggedUser.avatarUrl}`)
.fileUpload
input(type="file", id="photo", name="photo", accept="image/*")
label(for="photo") Photo
...
...
src/views/userDetail.pug
View file @
29bf598
...
...
@@ -9,7 +9,7 @@ block content
.pageLayout
.user-profile
.user-profile__column
img(src=`
/
${user.avatarUrl}`)
img(src=`${user.avatarUrl}`)
.user-profile__link
a(href=user.githubUrl target="_blank") GitHub
i.fab.fa-github
...
...
Please
register
or
login
to post a comment