Remove credentials

This commit is contained in:
Nikola Petrov 2024-07-17 00:41:22 +02:00
parent 47a3cad3a8
commit b1babe3c50
4 changed files with 38 additions and 8 deletions

1
app.ts
View File

@ -1,6 +1,7 @@
import express from "express";
import path from 'path'
import morgan from 'morgan'
import 'dotenv/config'
const hostname = '127.0.0.1';
const httpPort = 4080;

View File

@ -1,11 +1,34 @@
import mysql from 'mysql2/promise'
import mysql, { type PoolOptions } from 'mysql2/promise'
const pool = mysql.createPool({
host: '192.168.0.11',
port: 3306,
user: 'myUsage',
password: 'vEj8lFj22srB_(VG',
database: 'my_general_db'
});
const poolOptions: PoolOptions = {
host: "",
port: 0,
user: "",
password: "",
database: ""
}
if (process.env.DBIP) {
poolOptions.host = process.env.DBIP;
}
if (process.env.DBPort) {
poolOptions.port = parseInt(process.env.DBPort);
}
if (process.env.DBUser) {
poolOptions.user = process.env.DBUser;
}
if (process.env.DBPassword) {
poolOptions.password = process.env.DBPassword;
}
if (process.env.DBDatabase) {
poolOptions.database = process.env.DBDatabase;
}
const pool = mysql.createPool(poolOptions);
export default pool;

View File

@ -9,6 +9,7 @@
"dependencies": {
"@types/express": "^4.17.21",
"@types/morgan": "^1.9.9",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"hbs": "^4.2.0",
"morgan": "~1.9.1",

5
templ.env Normal file
View File

@ -0,0 +1,5 @@
DBIP=
DBPort=
DBUser=
DBPassword=
DBDatabase=