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
JungSeungHyun
2021-06-08 14:19:13 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
18946d6c84700f54bfa6ebf584ddb3767b064c8f
18946d6c
2 parents
815f505d
7f9c1b32
Merge remote-tracking branch 'origin' into feature/frontend-js
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
50 additions
and
20 deletions
.gitignore
.vscode/settings.json
package.json
src/client/js/main.js
src/controllers/userController.js
src/init.js
src/middlewares.js
src/passport.js
src/server.js
src/views/editProfile.pug
src/views/userDetail.pug
webpack.config.js
.gitignore
View file @
18946d6
...
...
@@ -120,5 +120,5 @@ dist
package-lock.json
/uploads
/assets
build
/
build
.vscode
\ No newline at end of file
...
...
.vscode/settings.json
deleted
100644 → 0
View file @
815f505
{
"git.ignoreLimitWarning"
:
true
}
\ No newline at end of file
package.json
View file @
18946d6
...
...
@@ -3,8 +3,12 @@
"version"
:
"1.0.0"
,
"description"
:
"2021 OSS Project Using node!"
,
"scripts"
:
{
"start"
:
"node build/init.js"
,
"build"
:
"npm run build:server && npm run build:assets"
,
"build:server"
:
"babel src -d build"
,
"build:assets"
:
"webpack --mode=production"
,
"dev:server"
:
"nodemon"
,
"dev:assets"
:
"webpack"
"dev:assets"
:
"webpack
--mode=development -w
"
},
"repository"
:
{
"type"
:
"git"
,
...
...
@@ -13,9 +17,7 @@
"author"
:
"Lee SeJin"
,
"license"
:
"MIT"
,
"dependencies"
:
{
"@babel/core"
:
"^7.14.0"
,
"@babel/node"
:
"^7.13.13"
,
"@babel/preset-env"
:
"^7.14.1"
,
"aws-sdk"
:
"^2.922.0"
,
"axios"
:
"^0.21.1"
,
"connect-mongo"
:
"^4.4.1"
,
"dotenv"
:
"^9.0.2"
,
...
...
@@ -24,13 +26,19 @@
"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"
,
"passport-github2"
:
"^0.1.12"
,
"pug"
:
"^3.0.2"
"pug"
:
"^3.0.2"
,
"regenerator-runtime"
:
"^0.13.7"
},
"devDependencies"
:
{
"@babel/core"
:
"^7.14.0"
,
"@babel/node"
:
"^7.13.13"
,
"@babel/preset-env"
:
"^7.14.1"
,
"@babel/cli"
:
"^7.14.3"
,
"babel-loader"
:
"^8.2.2"
,
"css-loader"
:
"^5.2.6"
,
"eslint-config-prettier"
:
"^8.3.0"
,
...
...
src/client/js/main.js
View file @
18946d6
import
"regenerator-runtime"
;
import
"../scss/styles.scss"
;
console
.
log
(
"main"
);
...
...
src/controllers/userController.js
View file @
18946d6
...
...
@@ -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
,
...
...
@@ -63,11 +63,12 @@ export const postEditProfile = async (req, res) => {
body
:
{
name
,
email
,
school
,
blogUrl
,
tech
,
career
,
introduction
},
file
,
}
=
req
;
const
isHeroku
=
process
.
env
.
NODE_ENV
===
"production"
;
try
{
const
updatedUser
=
await
User
.
findByIdAndUpdate
(
id
,
{
avatarUrl
:
file
?
file
.
path
:
req
.
session
.
passport
.
user
.
avatarUrl
,
avatarUrl
:
file
?
(
isHeroku
?
file
.
location
:
file
.
path
)
:
req
.
session
.
passport
.
user
.
avatarUrl
,
name
,
email
,
school
,
...
...
src/init.js
View file @
18946d6
import
"regenerator-runtime"
;
import
"dotenv/config"
;
import
"./db"
;
import
"./models/User"
;
import
app
from
"./server"
;
const
PORT
=
5500
;
const
PORT
=
process
.
env
.
PORT
||
5500
;
const
handleListening
=
()
=>
console
.
log
(
`✅ Server running : http://localhost:
${
PORT
}
`
);
app
.
listen
(
PORT
,
handleListening
);
\ No newline at end of file
...
...
src/middlewares.js
View file @
18946d6
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
isHeroku
=
process
.
env
.
NODE_ENV
===
"production"
;
const
multerUploader
=
multerS3
({
s3
:
s3
,
bucket
:
"developer-profile-oss"
,
acl
:
"public-read"
,
})
export
const
localsMiddleware
=
(
req
,
res
,
next
)
=>
{
res
.
locals
.
siteName
=
"Dev Profile"
;
res
.
locals
.
loggedUser
=
req
.
user
||
null
;
res
.
locals
.
isHeroku
=
isHeroku
;
next
();
};
...
...
@@ -27,5 +44,6 @@ export const uploadFiles = multer({
dest
:
"uploads/"
,
limits
:
{
fileSize
:
3000000
}
},
storage
:
isHeroku
?
multerUploader
:
undefined
,
});
\ No newline at end of file
...
...
src/passport.js
View file @
18946d6
...
...
@@ -7,7 +7,7 @@ passport.use(new GithubStrategy(
{
clientID
:
process
.
env
.
GH_ID
,
clientSecret
:
process
.
env
.
GH_SECRET
,
callbackURL
:
`http
://localhost:5500
/auth/github/callback`
callbackURL
:
`http
s://dev-profile-2021.herokuapp.com
/auth/github/callback`
},
githubLoginCallback
)
...
...
src/server.js
View file @
18946d6
...
...
@@ -14,7 +14,7 @@ const app = express();
app
.
set
(
"view engine"
,
"pug"
);
app
.
set
(
"views"
,
p
ath
.
join
(
__dirname
,
"views"
)
);
app
.
set
(
"views"
,
p
rocess
.
cwd
()
+
"/src/views"
);
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
"static"
)));
app
.
use
(
morgan
(
"dev"
));
app
.
use
(
express
.
json
());
...
...
src/views/editProfile.pug
View file @
18946d6
...
...
@@ -3,7 +3,10 @@ extends layouts/main
block content
.form-container
form(action="/users/edit-profile", method="POST", enctype="multipart/form-data")
img(src=`/${loggedUser.avatarUrl}`)
if isHeroku
img(src=`${user.avatarUrl}`)
else
img(src=`/${user.avatarUrl}`)
.fileUpload
input(type="file", id="photo", name="photo", accept="image/*")
label(for="photo") Photo
...
...
src/views/userDetail.pug
View file @
18946d6
...
...
@@ -9,6 +9,9 @@ block content
.pageLayout
.user-profile
.user-profile__column
if isHeroku
img(src=`${user.avatarUrl}`)
else
img(src=`/${user.avatarUrl}`)
.user-profile__link
a(href=user.githubUrl target="_blank") GitHub
...
...
webpack.config.js
View file @
18946d6
...
...
@@ -8,8 +8,6 @@ module.exports = {
githubInfo
:
"./src/client/js/githubInfo.js"
,
search
:
"./src/client/js/search.js"
,
},
mode
:
"development"
,
watch
:
true
,
plugins
:
[
new
MiniCssExtractPlugin
({
filename
:
"css/styles.css"
,
...
...
Please
register
or
login
to post a comment