From b0c1dff0e6259c51f17fc263da50142b4883278b Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Wed, 3 Apr 2019 20:22:43 -0400 Subject: [PATCH] added dotenv, setup for proper server timezone --- client/src/Header/Schedules/index.js | 1 + server/.env.example | 14 ++++++++++++ server/.gitignore | 1 + server/index.js | 21 ++++++------------ server/mediaServerConfig.js | 32 ++++++++++++++++++++++++++++ server/package-lock.json | 5 +++++ server/package.json | 1 + 7 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 server/.env.example create mode 100644 server/mediaServerConfig.js diff --git a/client/src/Header/Schedules/index.js b/client/src/Header/Schedules/index.js index a48980c..7f3ffe9 100644 --- a/client/src/Header/Schedules/index.js +++ b/client/src/Header/Schedules/index.js @@ -25,6 +25,7 @@ const Schedules = ({ schedules }) => {

Today's Schedule

+

opensourceradio is proudly hosted in Toronto Canada. All times are in EST.

diff --git a/server/.env.example b/server/.env.example new file mode 100644 index 0000000..3c3b611 --- /dev/null +++ b/server/.env.example @@ -0,0 +1,14 @@ +SERVER_PORT=3001 +TZ=America/Toronto + +RTMP_PORT=1935 +RTMP_CHUNK_SIZE=60000 +RTMP_GOP_CACHE=true +RTMP_PING=60 +RTMP_PING_TIMEOUT=30 + +RTMP_HTTP_PORT=8000 +RTMP_ALLOW_ORIGIN=* + +RTMP_HTTP_USER=admin +RTMP_HTTP_PASS=verycoolcat \ No newline at end of file diff --git a/server/.gitignore b/server/.gitignore index 4e90e6f..1814fb6 100644 --- a/server/.gitignore +++ b/server/.gitignore @@ -1,2 +1,3 @@ node_modules/* *.sqlite3 +.env diff --git a/server/index.js b/server/index.js index dcd8d28..55344a0 100644 --- a/server/index.js +++ b/server/index.js @@ -1,3 +1,4 @@ +require('dotenv').config(); const express = require('express'); const http = require('http'); const socketio = require('socket.io'); @@ -5,25 +6,15 @@ const app = express(); const cors = require('cors'); const morgan = require('morgan') const { NodeMediaServer } = require('node-media-server'); +const mediaServerConfig = require('./mediaServerConfig') + +const { + SERVER_PORT +} = process.env; -const SERVER_PORT = 3001; const api = require('./routes/api'); const { saveMessage } = require('./util'); -const mediaServerConfig = { - rtmp: { - port: 1935, - chunk_size: 60000, - gop_cache: true, - ping: 60, - ping_timeout: 30 - }, - http: { - port: 8000, - allow_origin: '*' - } -}; - const server = http.createServer(app); const io = socketio(server); diff --git a/server/mediaServerConfig.js b/server/mediaServerConfig.js new file mode 100644 index 0000000..f1320c2 --- /dev/null +++ b/server/mediaServerConfig.js @@ -0,0 +1,32 @@ +const { + RTMP_PORT, + RTMP_CHUNK_SIZE, + RTMP_GOP_CACHE, + RTMP_PING, + RTMP_PING_TIMEOUT, + RTMP_HTTP_PORT, + RTMP_ALLOW_ORIGIN, + RTMP_HTTP_USER, + RTMP_HTTP_PASS +} = process.env; + +const mediaServerConfig = { + rtmp: { + port: RTMP_PORT, + chunk_size: RTMP_CHUNK_SIZE, + gop_cache: RTMP_GOP_CACHE, + ping: RTMP_PING, + ping_timeout: RTMP_PING_TIMEOUT + }, + http: { + port: RTMP_HTTP_PORT, + allow_origin: RTMP_ALLOW_ORIGIN, + }, + auth: { + api : true, + api_user: RTMP_HTTP_USER, + api_pass: RTMP_HTTP_PASS, + } +}; + +module.exports = mediaServerConfig; diff --git a/server/package-lock.json b/server/package-lock.json index 7123ef8..fcebf34 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -616,6 +616,11 @@ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" }, + "dotenv": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-7.0.0.tgz", + "integrity": "sha512-M3NhsLbV1i6HuGzBUH8vXrtxOk+tWmzWKDMbAVSUp3Zsjm7ywFeuwrUXhmhQyRK1q5B5GGy7hcXPbj3bnfZg2g==" + }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", diff --git a/server/package.json b/server/package.json index bb4e093..e3d8b72 100644 --- a/server/package.json +++ b/server/package.json @@ -11,6 +11,7 @@ "dependencies": { "bookshelf": "^0.14.2", "cors": "^2.8.5", + "dotenv": "^7.0.0", "express": "^4.16.4", "joi": "^14.3.1", "knex": "^0.16.3",