A small library that parses mssql connection string and returns database configuration for given libraries:
npm install mssql-connection-string
const parser = require('mssql-connection-string');
const connectionString = "Data Source=tcp:database.com,1433;Initial Catalog=numbers;User [email protected];Password=qwerty;";
const knexDb = parser(connectionString);
import parse from 'mssql-connection-string';
const connectionString = "Data Source=tcp:database.com,1433;Initial Catalog=numbers;User [email protected];Password=qwerty;";
const knexDb = parser(connectionString);
{
"host": "database.com",
"options": {
"database": "numbers",
"encrypt": true,
"port": "1433"
},
"password": "qwerty",
"user": "service"
}
The protocol and port in 'Data Source' are optional. If the 'User Id' contains an email, only the login will be used as user.
npm install
npm test
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.