diff --git a/.env b/.env new file mode 100644 index 0000000..5a1a22b --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +ACTUAL_ENV=dev +DB_USER=root +DB_PASSWORD=password +DB_NAME=battleship +DB_HOST=localhost +COOKIE_SECRET_KEY=secret_key diff --git a/.gitignore b/.gitignore index 6597792..dc2aa9e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ node_modules/ .vscode/ -.env nginx.conf nginx/ secrets/ diff --git a/README.md b/README.md index 10a74f2..8a7031b 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ To use maettleship you'll need the following app on your computer * node js and npm * mysql +* docker # Installation @@ -45,12 +46,12 @@ touch .env The .env file should look like that ``` -ACTUAL_ENV=dev +echo "ACTUAL_ENV=dev DB_USER=root DB_PASSWORD=password DB_NAME=battleship DB_HOST=localhost -COOKIE_SECRET_KEY=secret_key +COOKIE_SECRET_KEY=secret_key" > .env ``` You can use the env file as it is in my example but if you want make it yours just don't forget to have the same variable in your env file that in you mysql config. diff --git a/database.js b/database.js index 9effe5a..f84b098 100644 --- a/database.js +++ b/database.js @@ -10,15 +10,15 @@ try { db_user = process.env.DB_USER db_user_password = process.env.DB_PASSWORD } else { - const db_user_password = fs.readFileSync(process.env.DB_USER_PASSWORD_FILE, 'utf8').replace(/\r?\n|\r/g, ""); - const db_user = fs.readFileSync(process.env.DB_USER_FILE, 'utf8').replace(/\r?\n|\r/g, ""); + db_user_password = fs.readFileSync(process.env.DB_USER_PASSWORD_FILE, 'utf8').replace(/\r?\n|\r/g, ""); + db_user = fs.readFileSync(process.env.DB_USER_FILE, 'utf8').replace(/\r?\n|\r/g, ""); } const connection = mysql.createPool({ - host: process.env.DB_HOST, - user: db_user, + host: process.env.DB_HOST, + user: db_user, password: db_user_password, - database: process.env.DB_NAME, + database: process.env.DB_NAME, }); module.exports = connection; diff --git a/index.js b/index.js index 6ea5d45..57242e8 100644 --- a/index.js +++ b/index.js @@ -25,6 +25,10 @@ app.get('/', (req, res) => { return res.sendFile(path.normalize(path.join(__dirname, '/public/pages/connectionView.html'))) }) +app.get('/scoreboard', (req, res) => { + return res.sendFile(path.normalize(path.join(__dirname, 'public/pages/scoreboardView.html'))) +}) + app.get('/register', (req, res) => { return res.sendFile(path.normalize(path.join(__dirname, '/public/pages/signupView.html'))) }) @@ -201,8 +205,9 @@ io.on("connection", (socket) => { socket.on("first connection", (socketId) => { const cookies = socket.request.headers.cookie; - const authToken = cookies.split('; ').find(cookie => cookie.startsWith('authToken=')).split('=')[1]; + if (!cookies) return + const authToken = cookies.split('; ').find(cookie => cookie.startsWith('authToken=')).split('=')[1]; if (authToken) { try { const decoded = jwt.verify(authToken, secretKey); diff --git a/public/assets/styles/background.css b/public/assets/styles/background.css new file mode 100644 index 0000000..b1f6d17 --- /dev/null +++ b/public/assets/styles/background.css @@ -0,0 +1,6 @@ +body{ + background-image: url("../images/background.jpeg"); + background-position: center; + background-repeat: no-repeat; + background-size: cover; +} \ No newline at end of file diff --git a/public/assets/styles/global.css b/public/assets/styles/global.css index 4c7d430..4895fea 100644 --- a/public/assets/styles/global.css +++ b/public/assets/styles/global.css @@ -10,10 +10,6 @@ html, body{ background-color: #ffffff; - background-image: url("../images/background.jpeg"); - background-position: center; - background-repeat: no-repeat; - background-size: cover; margin: 0; height: 100%; overflow: hidden; diff --git a/public/assets/styles/style.css b/public/assets/styles/style.css index 42065a0..049366b 100644 --- a/public/assets/styles/style.css +++ b/public/assets/styles/style.css @@ -52,6 +52,6 @@ .board-container { display: flex; align-items: center; - justify-content: column; - justify-content: space-evenly; + justify-content: center; + gap: 1rem; } \ No newline at end of file diff --git a/public/pages/connectionView.html b/public/pages/connectionView.html index 50f0e76..ed7cfb9 100644 --- a/public/pages/connectionView.html +++ b/public/pages/connectionView.html @@ -5,6 +5,7 @@ +