Show HN: Connparse, a tool to parse DSNs, URLs, file paths, and cloud storage

  • Posted 1 hour ago by modelorona
  • 3 points
https://github.com/clidey/connparse
Hello!

This is a tool I created on the side that is able to parse connection strings for various data sources including SQL, NoSQL, files, cloud storage (s3, etc), and more.

I created it because I wanted to add automatic parsing for WhoDB (day job) so that users do not have to type in each detail individually when they add a new data source.

The parser currently supports SQL, NoSQL, file-based, and cloud storage connection strings (Postgres, MySQL, MongoDB, Redis, S3, SQLite, and more).

Each datasource is defined via YAML:

- required fields

- optional fields

- credential handling

- query params

- validation rules

Usage is simple:

const result = parse('postgres://user:pass@localhost:5432/app?sslmode=require');

and the result:

{ "scheme": "postgres", "type": "database", "authority": { "host": "localhost", "port": 5432 }, "resource": { "type": "database", "name": "app" }, "path": "", "query": { "sslmode": "require" }, "fragment": null, "credentials": { "username": "user", "password": "pass" }, "options": {}, "raw": "postgres://user:pass@localhost:5432/app?sslmode=require", "safe": "postgres://user:**@localhost:5432/app?sslmode=require" }

which can they be used directly in the application.

0 comments