Toggle navigation
Toggle navigation
This project
Loading...
Sign in
황선혁
/
weather_chatbot
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
Eric Whale
2022-05-23 21:46:17 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6c61940859c3018e5f868354cee1278d47b773c1
6c619408
1 parent
5ab0d0f1
Add mongoDB and it's config
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
2 deletions
actions/userActions.js
config/db.js
models/userModel.js
actions/userActions.js
View file @
6c61940
const
jwt
=
require
(
"jsonwebtoken"
);
const
bcrypt
=
require
(
"bcryptjs"
);
// handles "exception" inside of async express routes
// (Used for mongoDB error in this project)
const
asyncHandler
=
require
(
"express-async-handler"
);
// @desc Signup new user
...
...
@@ -29,7 +31,10 @@ const loginUser = asyncHandler(async (req, res) => {
// Send response
});
const
getSelf
=
asyncHandler
(
async
(
req
,
res
)
=>
{});
module
.
exports
=
{
signupUser
,
loginUser
,
getSelf
,
};
...
...
config/db.js
View file @
6c61940
const
colors
=
require
(
"colors"
);
const
mongoose
=
require
(
"mongoose"
);
const
colors
=
require
(
"colors"
);
const
connectDB
=
async
()
=>
{};
const
connectDB
=
async
()
=>
{
try
{
const
conn
=
await
mongoose
.
connect
(
process
.
env
.
MONGO_URI
);
console
.
log
(
`MongoDB Connected:
${
conn
.
connection
.
host
}
`
.
cyan
.
underline
);
}
catch
(
error
)
{
console
.
log
(
error
);
process
.
exit
(
1
);
}
};
module
.
exports
=
connectDB
;
...
...
models/userModel.js
0 → 100644
View file @
6c61940
const
mongoose
=
require
(
"mongoose"
);
const
userSchema
=
mongoose
.
Schema
(
{
username
:
{
type
:
String
,
required
:
[
true
,
"Please add a username"
],
},
email
:
{
type
:
String
,
required
:
[
true
,
"Please add a email"
],
},
password
:
{
type
:
String
,
required
:
[
true
,
"Please add a password"
],
},
},
{
timestamps
:
true
,
}
);
const
userModel
=
mongoose
.
model
(
"User"
,
userSchema
);
module
.
exports
=
userModel
;
Please
register
or
login
to post a comment