code refactor and added socket.io
This commit is contained in:
@@ -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
13
frontend/routes/chat.html
Normal 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>
|
||||
12
index.js
12
index.js
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user