Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-066
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
2022-066
2022-066
Commits
cbb339e0
Commit
cbb339e0
authored
Apr 30, 2022
by
Navodya Pasqual
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into IT19408316
parents
a32a848c
77870571
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
195 additions
and
194 deletions
+195
-194
Backend/Node/package-lock.json
Backend/Node/package-lock.json
+195
-86
Backend/Node/server.js
Backend/Node/server.js
+0
-108
No files found.
Backend/Node/package-lock.json
View file @
cbb339e0
This diff is collapsed.
Click to expand it.
Backend/Node/server.js
deleted
100644 → 0
View file @
a32a848c
const
express
=
require
(
'
express
'
);
const
mongoose
=
require
(
'
mongoose
'
);
const
dotenv
=
require
(
'
dotenv
'
);
const
cors
=
require
(
'
cors
'
);
const
bodyParser
=
require
(
'
body-parser
'
);
//Importing chatbot api
const
chatbotAPI
=
require
(
'
./src/routes/chatbot/dialogFlow
'
);
dotenv
.
config
();
const
app
=
express
();
app
.
use
(
cors
());
// parse requests of content-type - application/json
app
.
use
(
bodyParser
.
json
());
// parse requests of content-type - application/x-www-form-urlencoded
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
const
PORT
=
process
.
env
.
PORT
||
8081
;
/**
* Get MONGODB_URI from .env
*/
const
MONGODB_URI
=
process
.
env
.
MONGODB_URI
;
mongoose
.
connect
(
MONGODB_URI
,
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
},
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
Database Error:
'
,
error
.
message
);
console
.
log
(
'
######################################################
'
);
}
});
mongoose
.
connection
.
once
(
'
open
'
,
()
=>
{
console
.
log
(
'
Database Connected...
'
);
initial
();
console
.
log
(
'
######################################################
'
);
});
app
.
route
(
'
/
'
).
get
((
req
,
res
)
=>
{
res
.
send
(
'
Research Project
'
);
});
require
(
'
./src/routes/auth.routes
'
)(
app
);
require
(
'
./src/routes/user.routes
'
)(
app
);
app
.
use
(
'
/api/dialogflow
'
,
chatbotAPI
);
app
.
listen
(
PORT
,
()
=>
{
console
.
log
(
'
######################################################
'
);
console
.
log
(
`Server is ON and running on PORT :
${
PORT
}
`
);
console
.
log
(
'
...Wait DB connecting...
'
);
});
const
db
=
require
(
"
./src/modules
"
);
const
Role
=
db
.
role
;
function
initial
()
{
Role
.
estimatedDocumentCount
((
err
,
count
)
=>
{
if
(
!
err
&&
count
===
0
)
{
new
Role
({
name
:
"
user
"
}).
save
(
err
=>
{
if
(
err
)
{
console
.
log
(
"
error
"
,
err
);
}
console
.
log
(
"
added 'user' to roles collection
"
);
});
new
Role
({
name
:
"
manager
"
}).
save
(
err
=>
{
if
(
err
)
{
console
.
log
(
"
error
"
,
err
);
}
console
.
log
(
"
added 'manager' to roles collection
"
);
});
new
Role
({
name
:
"
student
"
}).
save
(
err
=>
{
if
(
err
)
{
console
.
log
(
"
error
"
,
err
);
}
console
.
log
(
"
added 'student' to roles collection
"
);
});
new
Role
({
name
:
"
admin
"
}).
save
(
err
=>
{
if
(
err
)
{
console
.
log
(
"
error
"
,
err
);
}
console
.
log
(
"
added 'admin' to roles collection
"
);
console
.
log
(
'
######################################################
'
);
});
}
});
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment