code refactor and added socket.io

This commit is contained in:
slawk0
2024-08-21 17:58:31 +02:00
parent 0c8e844aaf
commit f635325911
4 changed files with 24 additions and 5 deletions

View File

@@ -42,6 +42,7 @@ async function insertUser(username, password){
console.log('Account created:', signupData.rows[0].username);
} catch (err) {
console.error('Error inserting data:', err.stack);
throw err;
}
}

13
frontend/routes/chat.html Normal file
View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Chat</title>
</head>
<body>
</body>
</html>

View File

@@ -1,14 +1,18 @@
const express = require('express');
const session = require('express-session');
const path = require('path');
const { client } = require('./backend/db');
const port = 3000
const app = express()
const { insertUser, isUserExists } = require('./backend/db');
const path = require('path');
const { insertUser, isUserExists, client } = require('./backend/db');
const bcrypt = require('bcrypt');
const {hash} = require("bcrypt");
const saltRounds = 10;
const { Server } = require("socket.io");
const { createServer } = require('node:http');
const server = createServer(app);
const { join } = require('node:path');
require('dotenv').config()
//TODO change password option will be cool

View File

@@ -12,6 +12,7 @@
"dotenv": "^16.4.5",
"express": "^4.19.2",
"express-session": "^1.18.0",
"pg": "^8.12.0"
"pg": "^8.12.0",
"socket.io": "^4.7.5"
}
}