Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021_dev-profile
/
dev-profile
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Lee SeJin
2021-05-14 17:04:25 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7c736d652429ffe2475f9a0f6749c6ef489096bf
7c736d65
1 parent
30e0a124
mongodb schema update
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
4 deletions
package.json
src/controllers/userController.js
src/db.js
src/init.js
src/models/User.js
src/server.js
package.json
View file @
7c736d6
...
...
@@ -3,7 +3,7 @@
"version"
:
"1.0.0"
,
"description"
:
"2021 OSS Project Using node!"
,
"scripts"
:
{
"dev:server"
:
"nodemon --exec babel-node src/
server
"
"dev:server"
:
"nodemon --exec babel-node src/
init
"
},
"repository"
:
{
"type"
:
"git"
,
...
...
@@ -17,6 +17,7 @@
"@babel/preset-env"
:
"^7.14.1"
,
"axios"
:
"^0.21.1"
,
"express"
:
"^4.17.1"
,
"mongoose"
:
"^5.12.9"
,
"morgan"
:
"^1.10.0"
,
"nodemon"
:
"^2.0.7"
,
"pug"
:
"^3.0.2"
...
...
src/controllers/userController.js
View file @
7c736d6
import
axios
from
"axios"
;
import
User
from
"../models/User"
;
const
getQuote
=
async
(
req
,
res
)
=>
{
const
url
=
"http://quotes.stormconsultancy.co.uk/random.json"
;
...
...
src/db.js
0 → 100644
View file @
7c736d6
import
mongoose
from
"mongoose"
;
mongoose
.
connect
(
"mongodb://127.0.0.1:27017/dev-profile"
,{
useNewUrlParser
:
true
,
useFindAndModify
:
false
,
useUnifiedTopology
:
true
}
);
const
db
=
mongoose
.
connection
;
const
handleOpen
=
()
=>
console
.
log
(
"✅ Connected to DB"
);
const
handleError
=
(
error
)
=>
console
.
log
(
`❌ Error on DB Connection:
${
error
}
`
);
db
.
once
(
"open"
,
handleOpen
);
db
.
on
(
"eror"
,
handleError
);
\ No newline at end of file
src/init.js
0 → 100644
View file @
7c736d6
import
"./db"
;
import
"./models/User"
;
import
app
from
"./server"
;
const
PORT
=
5500
;
const
handleListening
=
()
=>
console
.
log
(
`✅ Server running : http://localhost:
${
PORT
}
`
);
app
.
listen
(
PORT
,
handleListening
);
\ No newline at end of file
src/models/User.js
0 → 100644
View file @
7c736d6
import
mongoose
from
"mongoose"
;
const
UserSchema
=
new
mongoose
.
Schema
({
name
:
{
type
:
String
,
trim
:
true
},
email
:
{
type
:
String
,
trim
:
true
},
avatarUrl
:
String
,
githubId
:
{
type
:
Number
,
required
:
"GitHub id is required"
},
githubName
:
{
type
:
String
,
required
:
"Github nickname is required"
,
trim
:
true
},
school
:
{
type
:
String
,
trim
:
true
},
tech
:
[{
type
:
String
,
trim
:
true
}],
career
:
[{
type
:
String
,
trim
:
true
}],
introduction
:
String
,
createdAt
:
{
type
:
Date
,
default
:
Date
.
now
},
blogUrl
:
{
type
:
String
,
default
:
"#"
},
githubUrl
:
{
type
:
String
,
default
:
"#"
}
});
const
User
=
mongoose
.
model
(
"User"
,
UserSchema
);
export
default
User
;
\ No newline at end of file
src/server.js
View file @
7c736d6
...
...
@@ -5,7 +5,8 @@ import globalRouter from "./routers/globalRouter";
import
userRouter
from
"./routers/userRouter"
;
import
{
localsMiddleware
}
from
"./middlewares"
;
const
PORT
=
5500
;
const
app
=
express
();
...
...
@@ -23,7 +24,6 @@ app.use("/users", userRouter);
const
handleListening
=
()
=>
console
.
log
(
`✅ Server running : http://localhost:
${
PORT
}
`
);
app
.
listen
(
PORT
,
handleListening
);
export
default
app
;
\ No newline at end of file
...
...
Please
register
or
login
to post a comment