This commit is contained in:
Sam Hadow 2025-02-09 00:07:46 +01:00
parent ba13626d46
commit 4abe5a07f2
7 changed files with 50 additions and 3 deletions

View File

@ -1,10 +1,12 @@
run: clean build run: clean build
podman run --replace -dt -p 3333:3333 --name=e2ee e2ee-messaging-service:latest podman pod create --name=e2ee -p 3333:3333
podman run -d --pod=e2ee -e POSTGRES_PASSWORD="password" -e POSTGRES_DB="e2ee" -e POSTGRES_USER="e2ee" -e POSTGRES_INITDB_ARGS="--encoding=UTF-8 --lc-collate=C --lc-ctype=C" --name=e2ee-db docker.io/library/postgres:15
podman run -d --pod=e2ee --name=e2ee-app e2ee-messaging-service:latest
build: build:
podman build -t e2ee-messaging-service . podman build -t e2ee-messaging-service .
test: test:
curl http://localhost:3333 curl http://localhost:3333
podman logs e2ee podman logs e2ee
clean: clean:
podman rm -f e2ee podman pod rm -f e2ee

View File

@ -12,6 +12,7 @@
"bootstrap": "^5.3.3", "bootstrap": "^5.3.3",
"cookie-parser": "^1.4.7", "cookie-parser": "^1.4.7",
"express": "^4.21.2", "express": "^4.21.2",
"pg": "^8.13.1",
"socket.io": "^4.8.1" "socket.io": "^4.8.1"
} }
} }

View File

@ -9,6 +9,9 @@ const mainController = {
}, },
script: (req, res) => { script: (req, res) => {
res.sendFile(path.resolve(__dirname + '/../public/script.js')); res.sendFile(path.resolve(__dirname + '/../public/script.js'));
},
ecc: (req, res) => {
res.sendFile(path.resolve(__dirname + '/../public/ecc.js'));
} }
}; };

36
src/db.js Normal file
View File

@ -0,0 +1,36 @@
const { Client } = require('pg');
const dbConfig = {
user: process.env.POSTGRES_USER || 'e2ee',
password: process.env.POSTGRES_PASSWORD,
host: process.env.POSTGRES_HOST || '127.0.0.1',
port: process.env.POSTGRES_PORT || '5432',
database: process.env.POSTGRES_DB || 'e2ee',
};
const client = new Client(dbConfig);
const database = {
init: () => {
client.connect().then(() => {
let querryString = `
CREATE table user (
uuid integer primary key,
pubkey text
);
`
client.query(querryString, (err, _) => {
if (err) {
console.error('Error executing query', err);
}
client.end().then(() => {}).catch((err) => {
console.error('Error closing connection', err);
});
});
}).catch((err) => {
console.error('Error connecting to database ', err);
});
}
};
module.exports = database;

0
src/public/ecc.js Normal file
View File

View File

@ -6,7 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/style.css"> <link rel="stylesheet" href="/style.css">
<script src="/socket.io/socket.io.js" defer></script> <script src="/socket.io/socket.io.js" defer></script>
<script src="script.js" defer></script> <script src="/script.js" defer></script>
<script src="/ecc.js" defer></script>
<!--load bootstrap--> <!--load bootstrap-->
<link rel="stylesheet" href="/css/bootstrap.min.css" /> <link rel="stylesheet" href="/css/bootstrap.min.css" />
</head> </head>

View File

@ -14,4 +14,8 @@ router
.route("/script.js") .route("/script.js")
.get(mainController.script); .get(mainController.script);
router
.route("/ecc.js")
.get(mainController.ecc);
module.exports = router; module.exports = router;