Connection string smart parser
connection-parser
What is it
Simple module to convert URLs into set of parameters using default or custom rules. Useful for application which whant to provide single connection string instead of lot of parameters.
For example: DATABASE_URL=neo4j://user:password@server.com/database?timeout=100&nocache=true node ./bin/server.js
Install
# npm install connection-parser
Usage
Parser from string template with default options:
const createParser = const parser = const options = console
will output:
{ proto: 'database:',
host: 'remote-server',
port: '333',
path: '/my-base',
options: { timeout: '999', params: { verbose: 'false' } },
login: 'user',
password: 'password' }
JSON Schema format:
Parser described inconst createParser = const parser = const options = console
will convert port into integer value and add default missing parameter:
{ proto: 'database:',
host: 'remote-server',
port: 333,
path: '/my-base',
options: { timeout: 1000 } }
License
Project has a MIT license so you can innovate without restrictions. Any contribuitions are welcome.