first commit
SAP-ERP Portal CI/CD / build (push) Failing after 5m20s

This commit is contained in:
John
2026-09-23 17:31:02 +05:30
commit 69b4e68baf
51657 changed files with 3864077 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
// backend/db/sql.js
const sql = require('mssql');
const config = {
server: process.env.SQL_HOST,
port: parseInt(process.env.SQL_PORT),
user: process.env.SQL_USER,
password: process.env.SQL_PASSWORD,
database: process.env.SQL_DATABASE,
options: {
encrypt: true,
trustServerCertificate: true,
},
};
let pool = null;
async function getConnection() {
if (pool) return pool;
pool = await sql.connect(config);
console.log('✅ Connected to SAP SQL Server');
return pool;
}
async function query(sqlQuery, params = []) {
const conn = await getConnection();
const request = conn.request();
// Assuming params is an array of values, but mssql uses named params or input()
// For simplicity, if params are positional, need to adjust
// But in current code, params are passed as array, so perhaps use input with placeholders
// For now, assume sqlQuery has ? and params array
params.forEach((param, index) => {
request.input(`param${index}`, param);
});
const result = await request.query(sqlQuery.replace(/\?/g, (match, offset) => `@param${offset}`));
return result.recordset;
}
module.exports = { getConnection, query };