diff --git a/client/components/LiveStreams.js b/client/components/LiveStreams.js index 4e75fe5..cf94c1b 100644 --- a/client/components/LiveStreams.js +++ b/client/components/LiveStreams.js @@ -19,7 +19,8 @@ export default class Navbar extends React.Component { } getLiveStreams() { - axios.get('http://127.0.0.1:' + config.rtmp_server.http.port + '/api/streams') + let streamApi = 'http://' + config.server.host + ':' + config.rtmp_server.http.port + '/api/streams'; + axios.get(streamApi) .then(res => { let streams = res.data; if (typeof (streams['live'] !== 'undefined')) { diff --git a/readme.md b/readme.md index c61bc90..f4babec 100644 --- a/readme.md +++ b/readme.md @@ -28,6 +28,16 @@ $ ffmpeg --version [Mac](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/) +#### Setup mongodb with docker + +``` +docker run -d -it --name mongodb \ + -p 27017:27017 \ + -e MONGO_INITDB_ROOT_USERNAME=admin \ + -e MONGO_INITDB_ROOT_PASSWORD=admin \ + mongo +``` + #### Configuration Change ffmpeg path in node media server configuration to your own installed path. @@ -40,7 +50,15 @@ cd nodeStream && nano /server/config/default.js const config = { server: { secret: 'kjVkuti2xAyF3JGCzSZTk0YWM5JhI9mgQW4rytXc', - port : 3333 + port: '3333', + host: 'localhost', + }, + mongodb: { + host: 'localhost', + port: '27017', + userName: 'admin', + password: 'admin', + }, rtmp_server: { rtmp: { diff --git a/server/app.js b/server/app.js index 7983e38..ba69fa8 100755 --- a/server/app.js +++ b/server/app.js @@ -54,6 +54,6 @@ app.get('*', middleware.ensureLoggedIn(), (req, res) => { res.render('index'); }); -app.listen(port, () => console.log(`App listening on ${port}!`)); +app.listen(port, () => console.log(`App listening on ${config.server.host}:${port}!`)); node_media_server.run(); thumbnail_generator.start(); diff --git a/server/config/default.js b/server/config/default.js index 14691c5..0e34ab3 100755 --- a/server/config/default.js +++ b/server/config/default.js @@ -1,7 +1,15 @@ const config = { server: { secret: 'kjVkuti2xAyF3JGCzSZTk0YWM5JhI9mgQW4rytXc', - port : 3333 + port: '3333', + host: 'localhost', + }, + mongodb: { + host: 'localhost', + port: '27017', + userName: 'admin', + password: 'admin', + }, rtmp_server: { rtmp: { diff --git a/server/database/Schema.js b/server/database/Schema.js index 0a3ec9f..064f375 100755 --- a/server/database/Schema.js +++ b/server/database/Schema.js @@ -1,3 +1,20 @@ let mongoose = require('mongoose'); +const config = require('../config/default'); + +const connectMongoDB = () => { + mongoose.connect( + `mongodb://${config.mongodb.userName}:${config.mongodb.password}@${config.mongodb.host}:${config.mongodb.port}`, + { + useNewUrlParser: true, + useUnifiedTopology: true + } + ).then(() => { + console.log("Connected to mongodb"); + }).catch((err) => { + console.log(err); + }); +} + +connectMongoDB(); exports.User = mongoose.model('User', require('./UserSchema'));