EMS: move DB connection to env
This commit is contained in:
@ -1,25 +1,30 @@
|
||||
import { Connection, ConnectionConfiguration, Request } from "tedious";
|
||||
import 'dotenv/config'
|
||||
|
||||
const MSSQL_HOST = process.env.MSSQL_HOST || 'localhost'
|
||||
const MSSQL_LOGIN = process.env.MSSQL_LOGIN || 'sa'
|
||||
const MSSQL_PASSWORD = process.env.MSSQL_PASSWORD || ''
|
||||
const MSSQL_DB = process.env.MSSQL_DB || 'nGeneral'
|
||||
const MSSQL_PORT = Number(process.env.MSSQL_PORT) || 1433
|
||||
|
||||
const tediousConfig: ConnectionConfiguration = {
|
||||
server: 'localhost',
|
||||
server: MSSQL_HOST,
|
||||
options: {
|
||||
trustServerCertificate: true,
|
||||
port: 1433,
|
||||
database: 'nGeneral'
|
||||
port: MSSQL_PORT,
|
||||
database: MSSQL_DB
|
||||
},
|
||||
authentication: {
|
||||
type: 'default',
|
||||
options: {
|
||||
userName: 'SA',
|
||||
password: 'oMhthmsvbYHc'
|
||||
userName: MSSQL_LOGIN,
|
||||
password: MSSQL_PASSWORD
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function tediousQuery(query: string) {
|
||||
// Read all rows from table
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const connection = new Connection(tediousConfig)
|
||||
|
||||
|
Reference in New Issue
Block a user