{"_id":"connection-string-parser","_rev":"6-eba806758661959e776c128be6752203","name":"connection-string-parser","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"connection-string-parser","version":"1.0.0","description":"A generic connection string parser/formatter","main":"./dist/connection-string-parser.js","types":"./dist/connection-string-parser.d.ts","scripts":{"build":"npm run tsc -- --pretty","clean":"rimraf dist","lint":"npm run tslint src/**/*.ts","prebuild":"npm run clean && npm run lint","prepare":"npm run build","tsc":"tsc","tslint":"tslint"},"repository":{"type":"git","url":"git+https://github.com/sindilevich/connection-string-parser.git"},"keywords":["database","database-connection","connection-string","parser","typescript","nodejs","browser"],"author":{"name":"Matanel Sindilevich"},"license":"MIT","bugs":{"url":"https://github.com/sindilevich/connection-string-parser/issues"},"homepage":"https://github.com/sindilevich/connection-string-parser#readme","devDependencies":{"rimraf":"^2.6.2","tslint":"^5.9.1","typescript":"^2.7.2"},"dependencies":{"tslib":"^1.9.0"},"gitHead":"7b394dac269dd4d8e5d8a8214a71cb1d3b05ad14","_id":"connection-string-parser@1.0.0","_npmVersion":"5.7.1","_nodeVersion":"9.8.0","_npmUser":{"name":"sindilevich","email":"sindilevich@gmail.com"},"dist":{"integrity":"sha512-noifwMb14VE1F+zo39Osa/eia+LprymZJtP0R1R9L6pV6rAnAx3MBxsukA/Ep5HENgib5u3A6As9xHGsVML4pg==","shasum":"4497fb88035cb9a6939b78cf7f0aafcbaa42d40e","tarball":"https://registry.npmjs.org/connection-string-parser/-/connection-string-parser-1.0.0.tgz","fileCount":7,"unpackedSize":16180,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHQhJjj+KpzoS3TsVDcLj070Jos4NDUsfa13gnOD7yqtAiEAw7Iox1AYfkvXp7P37PXv7OlNsnA+EpxYbw1xxGcftfE="}]},"maintainers":[{"name":"sindilevich","email":"sindilevich@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/connection-string-parser_1.0.0_1520798445220_0.04875171336987516"},"_hasShrinkwrap":false},"1.0.1":{"name":"connection-string-parser","version":"1.0.1","description":"A generic connection string parser/formatter","main":"./dist/connection-string-parser.js","types":"./dist/connection-string-parser.d.ts","scripts":{"build":"npm run tsc -- --pretty","clean":"rimraf dist","lint":"npm run tslint src/**/*.ts","prebuild":"npm run clean && npm run lint","prepare":"npm run build","tsc":"tsc","tslint":"tslint"},"repository":{"type":"git","url":"git+https://github.com/sindilevich/connection-string-parser.git"},"keywords":["database","database-connection","connection-string","parser","typescript","nodejs","browser"],"author":{"name":"Matanel Sindilevich"},"license":"MIT","bugs":{"url":"https://github.com/sindilevich/connection-string-parser/issues"},"homepage":"https://github.com/sindilevich/connection-string-parser#readme","devDependencies":{"rimraf":"^2.6.2","tslint":"^5.9.1","typescript":"^2.7.2"},"dependencies":{"tslib":"^1.9.0"},"gitHead":"fa2a11c64c778dbc33d33d61651a275fe6da7079","_id":"connection-string-parser@1.0.1","_npmVersion":"5.7.1","_nodeVersion":"9.8.0","_npmUser":{"name":"sindilevich","email":"sindilevich@gmail.com"},"dist":{"integrity":"sha512-rVEBB5dap2W3B+o7xBcmCPj58CW+SA3WowFYoEwfnnjGXxO+AQbcNmQdcTt1zahmLDopy8g7kUNmPf+7rVBPVg==","shasum":"c3b59f50c26890e6897437ee42ad2681d466e36f","tarball":"https://registry.npmjs.org/connection-string-parser/-/connection-string-parser-1.0.1.tgz","fileCount":7,"unpackedSize":16177,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCINo1JjDMMQB3uOL+ZPpgBNOYUDCaa4MviAbtLBIDy2AIhAMgYat+HjtQfTu8lFHnfF4pzK3OQ7t2qzM4aBnx6/1lC"}]},"maintainers":[{"name":"sindilevich","email":"sindilevich@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/connection-string-parser_1.0.1_1520799538586_0.5850570465394187"},"_hasShrinkwrap":false},"1.0.2":{"name":"connection-string-parser","version":"1.0.2","description":"A generic connection string parser/formatter","main":"./dist/connection-string-parser.js","types":"./dist/connection-string-parser.d.ts","scripts":{"build":"npm run tsc -- --pretty","clean":"rimraf dist","lint":"npm run tslint src/**/*.ts","prebuild":"npm run clean && npm run lint","prepare":"npm run build","tsc":"tsc","tslint":"tslint"},"repository":{"type":"git","url":"git+https://github.com/sindilevich/connection-string-parser.git"},"keywords":["database","database-connection","connection-string","parser","typescript","nodejs","browser"],"author":{"name":"Matanel Sindilevich"},"license":"MIT","bugs":{"url":"https://github.com/sindilevich/connection-string-parser/issues"},"homepage":"https://github.com/sindilevich/connection-string-parser#readme","devDependencies":{"rimraf":"^2.6.2","tslint":"^5.9.1","typescript":"^2.7.2"},"dependencies":{"tslib":"^1.9.0"},"gitHead":"e4a48944b98b617fe43d5bffee6fb7b0ae63be32","_id":"connection-string-parser@1.0.2","_npmVersion":"5.7.1","_nodeVersion":"9.8.0","_npmUser":{"name":"sindilevich","email":"sindilevich@gmail.com"},"dist":{"integrity":"sha512-DqNvwaGMB5A3eWSG/RZ2r/qrEyOM3QA9tqOU1tCudpOE1+fK3OrPpsf8AadctoGwdD9OmLiB387p/QOFOoEfBQ==","shasum":"0464b525d8294d691b05274b65207a03da9d2b95","tarball":"https://registry.npmjs.org/connection-string-parser/-/connection-string-parser-1.0.2.tgz","fileCount":5,"unpackedSize":15752,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA/NZ4QN8b1e//baIOvedpOvC2KM+t01dfjr+z9qWNJ4AiBqBCxie6DpCsGC80Mhb5lfwf7omtuDKGzeTzO0t4NaSA=="}]},"maintainers":[{"name":"sindilevich","email":"sindilevich@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/connection-string-parser_1.0.2_1520800483312_0.5102949360949491"},"_hasShrinkwrap":false},"1.0.3":{"name":"connection-string-parser","version":"1.0.3","description":"A generic connection string parser/formatter","main":"./dist/connection-string-parser.js","types":"./dist/connection-string-parser.d.ts","scripts":{"build":"npm run tsc -- --pretty","clean":"rimraf dist","lint":"npm run tslint src/**/*.ts","prebuild":"npm run clean && npm run lint","prepare":"npm run build","tsc":"tsc","tslint":"tslint"},"repository":{"type":"git","url":"git+https://github.com/sindilevich/connection-string-parser.git"},"keywords":["database","database-connection","connection-string","parser","typescript","nodejs","browser"],"author":{"name":"Matanel Sindilevich"},"license":"MIT","bugs":{"url":"https://github.com/sindilevich/connection-string-parser/issues"},"homepage":"https://github.com/sindilevich/connection-string-parser#readme","devDependencies":{"rimraf":"^3.0.0","tslint":"^5.20.1","typescript":"^3.7.5"},"dependencies":{"tslib":"^1.10.0"},"gitHead":"e95b0fe9e76942a1d237d5588dd243d247506bfe","_id":"connection-string-parser@1.0.3","_nodeVersion":"13.6.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-JTfzMX4NkL/kN8PqncU2NXqrIHShyzcG0KQCN+otUtWmuMhpnQuG3wihyNJw3OtbJOXPKwDoI+q8AKMhui/GFQ==","shasum":"506d2dbb1f37303081451b6f3a67a7b6ce083c8a","tarball":"https://registry.npmjs.org/connection-string-parser/-/connection-string-parser-1.0.3.tgz","fileCount":5,"unpackedSize":15971,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeI3tFCRA9TVsSAnZWagAA254P/3Cbrq3OQE5XzFWipp9h\nRbBuwlssmOpk8eb+M/ud0wXgHc7rI2DH28CArWStSZ+lyQHqLu1eqSOIp9nh\nUnULrcur49J9knVq+gGEGWimGjhA6vJR3K6Y2HIMAhvV/ooI99mDMZV+lMRs\nCL/y2La5I90IPIPXneRSy/a4BxzjCY/uy/Qu11D0yJODYfU5+vsnxq4qSdHO\nGPwqcs1NU9jKwVC46O013g/7dXW7+DLSRzSMFqB+81YXoZHUpbIDvQvlK96o\nUfGxAj6tts85t++/+AKDrgTYFoYSv18WIS3IoiWuNhkYjkut+FfUsVKO5Rhy\nFtsGL4Cyz6wqW3mtdWAp+KpqFI7YY9l07CHqwzJ0G5L+Gc5cL5XOFkZjsQ7m\nYqbzfmKLA4Zamk9pmrdmXQFwxi9X5SltSv7H/4jD3s7E8vyY9cubWDF7PJ/+\nGjtzMJv7IWche9P3I3DyjnITMZlC1tvgZTsNYJsHgOhxYxTh61r/EwG0VJtP\ntFvjPJy0JkEMcDRHdNGQdF8YCBWX8lc01cSJGHCQTOoJtUISksNRzm/00T6Y\noo5mszKxMDSXcL5gYg+gXUBoCTeyyAVmD0sqsynqsRKgm4nVw1uHvOVUvBG3\ngG/8a9/+S1+1j8QEsFuV/L7cBPzOVNDtIn8I0NcixCPvvQac2UAk/1ElHVqI\n9yo7\r\n=vdgY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBbKlQSH81JOAmqYmSoZg+a2HvPlVFvcnjqBvfLbFE9qAiEA9r2+PACuxYVirHqnyu1Jk7DIJuvc6tg4OCyoYlgw/aA="}]},"maintainers":[{"name":"sindilevich","email":"sindilevich@gmail.com"}],"_npmUser":{"name":"sindilevich","email":"sindilevich@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/connection-string-parser_1.0.3_1579383620743_0.692940926031782"},"_hasShrinkwrap":false},"1.0.4":{"name":"connection-string-parser","version":"1.0.4","description":"A generic connection string parser/formatter","main":"./dist/connection-string-parser.js","types":"./dist/connection-string-parser.d.ts","scripts":{"build":"tsc --pretty","clean":"rimraf dist","format":"prettier --write \"src/**/*.ts\"","lint":"eslint \"src/**/*.ts\" --fix","prebuild":"npm run clean && npm run lint","prepare":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/sindilevich/connection-string-parser.git"},"keywords":["database","database-connection","connection-string","parser","typescript","nodejs","browser"],"author":{"name":"Matanel Sindilevich"},"license":"MIT","bugs":{"url":"https://github.com/sindilevich/connection-string-parser/issues"},"homepage":"https://github.com/sindilevich/connection-string-parser#readme","devDependencies":{"@typescript-eslint/eslint-plugin":"^4.0.0","@typescript-eslint/parser":"^4.0.0","eslint":"^7.0.0","eslint-config-prettier":"^8.0.0","eslint-plugin-import":"^2.0.0","prettier":"^2.0.0","rimraf":"^3.0.0","typescript":"^4.0.0"},"dependencies":{"tslib":"^2.0.0"},"gitHead":"dbd6d82f3330e0030a793ad863de8289750e0e1a","_id":"connection-string-parser@1.0.4","_nodeVersion":"16.6.2","_npmVersion":"7.20.6","dist":{"integrity":"sha512-grmrIHzrZRjn53dwRqJTmtTRVc+gUiIk/tzjUrteN6aLN4l9DR6KE/IsGtjndyAlHhkmKjAHB9p7PJ0cFgO94w==","shasum":"27f1379694fccd7c1c0066db3de0960f9d0dd619","tarball":"https://registry.npmjs.org/connection-string-parser/-/connection-string-parser-1.0.4.tgz","fileCount":5,"unpackedSize":16031,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhFh+dCRA9TVsSAnZWagAAKvoP/A/ut+4LTOdhXmhDk++4\nt58Gk5cgwiG/Dw0PTOWhfOltBN2gHKRAZjx0aXnA790wxpOC0yV2SPETpJE4\nFN/AScHR8HWQkJYeZpSB6GRd90ZGRa1EX5BADIbnhmO/bX5AZtaS5zfDBBAZ\ns8M9fZS6nlSwSA34LAe8hYOg/MgHmsSR0ABg7pI6OrcPYHxNiGg2i5h0ehMo\nqjL/10T5/Gyuq5IoCC22TluiSSIL6ThIMvPHZROqAD1MHh1j3P+1paeSuc0E\nqIkQonLoDLXE68dxi81Ue03uANLEjCgGZd7PhLJBczFlsreZVDxwAFvUWXDV\n/yicNQZcTVCHUSGC4elwS/5sJQ8znpBmyBVUlyAzZ4gRhYBs0Nt1H0Hkdv4i\ntshEsUX+jwGMaN3Vsr8W4zZAIRmkBUE45KdDlDavyuqnNGKMkFKKdr8xy/h1\nrMgcHMjO6J31u6dPUxXGtT04mu8dxlSk+JmM5lkgzlRbr1njfyLnxrucZ1wS\nwqaHwvN0u7IGFw+UaPIG92i7W4a8yJ/hOcjZI5S5urG1dppermB9iVgU9H+8\nDxgQPlI4J07yrr8lSYm5ma8o78r9/xmC5VnDsaKBWfDfuFGu6TxxHU1K6+LD\nXANAY0e+cGSv+Nle0MR2yrMp2zYnaGwvNU9XfvECjHG1hupioIFt7+KX03IG\nx32G\r\n=etO3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCi9DfwY+rciITSS4ILoe156UsdBv5ttAtoIRvtw1+/kAIhAL8e16vEmRThMS+4fve8VzKzfwrDoQCLo7s9VPFXNrX6"}]},"_npmUser":{"name":"sindilevich","email":"sindilevich@gmail.com"},"directories":{},"maintainers":[{"name":"sindilevich","email":"sindilevich@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/connection-string-parser_1.0.4_1628839837252_0.2543032626662505"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-11T20:00:45.219Z","1.0.0":"2018-03-11T20:00:45.349Z","modified":"2022-04-27T15:51:54.998Z","1.0.1":"2018-03-11T20:18:59.293Z","1.0.2":"2018-03-11T20:34:43.361Z","1.0.3":"2020-01-18T21:40:20.888Z","1.0.4":"2021-08-13T07:30:37.439Z"},"maintainers":[{"name":"sindilevich","email":"sindilevich@gmail.com"}],"description":"A generic connection string parser/formatter","homepage":"https://github.com/sindilevich/connection-string-parser#readme","keywords":["database","database-connection","connection-string","parser","typescript","nodejs","browser"],"repository":{"type":"git","url":"git+https://github.com/sindilevich/connection-string-parser.git"},"author":{"name":"Matanel Sindilevich"},"bugs":{"url":"https://github.com/sindilevich/connection-string-parser/issues"},"license":"MIT","readme":"# Connection String Parser\nThis project aims to provide a connection string parser/formatter for `node.js` and browser.\n\n# The Need\nMostly, connecting to a database requires to provide some sort of a connection string: a URI that points to one or more database hosts, supplies connection credentials, and allows to further configure the connection via database-specific options.\n\nAs an example, here is a `MongoDB` connection string: `mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]`. It nicely combines a large set of database connection information and configuration data into a compact implementation. Let's look at the connection string components:\n\n* Scheme: `mongodb://`\n* Credentials: `username:password`\n* List of hosts: `host1[:port1][,host2[:port2],...[,hostN[:portN]]]`\n* Database name: `database`\n* Connection-specific options: `options`\n\nHere is another example, a `MySQL` connection string this time: `mysql://user:password@host:port/db?debug=true&charset=BIG5_CHINESE_CI&timezone=-0700`. It features the same components as the `MongoDB` connection string, and closely resembles all other possible connection strings, expressed as a URI.\n\nYet the most intriguing part, is that a project creator can invent his own URI-based connection string and use it to convey his project-specific configurations and options as long as they fit a URI concept and format.\n\nSay, developing a project that needs to connect to a `Hazelcast` cluster. Why not require the project consumer to supply the needed connection information: credentials, host(s), options, etc. as a URI-based connection string? Such as the one below: `hazelcast://[user:[password@]]host1[:port1][,host2:[port2],...[,hostN:[portN]]][[/]?options]`.\n\nSo, it seems like connection strings are good means to represent connection information and configuration in a compact form. An added value in a connection string is the simplicity with which it can be passed to the consumer: an environmental variable, a command line parameter, a one-liner in a configuration file of some sort.\n\n# The Problem\nThe problem with a URI-based connection string that immediately arises - is that not every connection provider: database, in-memory cluster, etc. supports connecting to it with a connection string. Many of such tools work with connection objects only. A connection object conveys the represents the same connection information as a connection string, though in JSON format.\n\nThus, a question emerge: *How to convert a convenient URI-based connection string to a JSON-based connection object?*\n\n# The Solution\nHere a generic connection string parser comes to rescue. One that take in a URI-based connection string and parse it into a JSON object. Or take in a JSON-based connection object and format it as a connection string.\n\nAnd this is the ultimate aim of this project: **A generic connection string parser/formatter**.\n\n# Say No More and How to Use It\nThe project is written in `Typescript`. Below usage examples for `Typescript`-based projects.\n\n## Add to the project\nSimply run `npm install connection-string-parser` in your project's folder.\n\n## Parse\nWith a connection string as the input, let's convert it to a connection object for further use.\n\nEach component of a connection string **has to be URI-encoded** with the `encodeURIComponent` method or its analogues.\n\nThe result connection object will have each component automatically decoded with the `decodeURIComponent` method.\n\n```typescript\nimport { ConnectionStringParser } from \"connection-string-parser\";\n\nconst connectionStringParser = new ConnectionStringParser({\n\tscheme: \"mongodb\",\n\thosts: []\n});\n\nconst connectionObject = connectionStringParser.parse(\"mongodb://s%23perus%24r:unbr%23k%40bl%24@ho%24t:1234/%24my-db?replicaSet=%24super%40\");\n```\n\nThe code above should yield a connection object with the following information:\n\n```typescript\n{\n\t\"scheme\": \"mongodb\",\n\t\"hosts\": [{\n\t\t\"host\": \"ho$t\",\n\t\t\"port\": 1234\n\t}],\n\t\"username\": \"s#perus$r\",\n\t\"password\": \"unbr#k@bl$\",\n\t\"endpoint\": \"$my-db\",\n\t\"options\": {\n\t\t\"replicaSet\": \"$super@\"\n\t}\n}\n```\n\n## Format\nWith a connection object as the input, let's convert it to a connection string for further use.\n\nThe result connection string will have each of its component automatically encoded with the `encodeURIComponent` method.\n\n```typescript\nimport { ConnectionStringParser } from \"connection-string-parser\";\n\nconst connectionStringParser = new ConnectionStringParser({\n\tscheme: \"mongodb\",\n\thosts: []\n});\n\nconst connectionString = connectionStringParser.format({\n\t\"scheme\": \"mongodb\",\n\t\"hosts\": [{\n\t\t\"host\": \"ho$t\",\n\t\t\"port\": 1234\n\t}],\n\t\"username\": \"s#perus$r\",\n\t\"password\": \"unbr#k@bl$\",\n\t\"endpoint\": \"$my-db\",\n\t\"options\": {\n\t\t\"replicaSet\": \"$super@\"\n\t}\n});\n```\n\nThe code above should yield a connection string with the following information:\n\n```typescript\n\"mongodb://s%23perus%24r:unbr%23k%40bl%24@ho%24t:1234/%24my-db?replicaSet=%24super%40\"\n```\n\n# Acknowledgments\nThe [mongodb-uri](https://github.com/mongolab/mongodb-uri-node) project.","readmeFilename":"README.md"}