https://github.com/nullthefirst/postgres-parser
Parses PostgreSQL database URL string and returns values for `user`, `password`, `host`, `port` and database `name`.
https://github.com/nullthefirst/postgres-parser
Last synced: about 1 year ago
JSON representation
Parses PostgreSQL database URL string and returns values for `user`, `password`, `host`, `port` and database `name`.
- Host: GitHub
- URL: https://github.com/nullthefirst/postgres-parser
- Owner: nullthefirst
- Created: 2021-08-20T16:08:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-21T10:20:18.000Z (over 4 years ago)
- Last Synced: 2025-02-18T11:43:06.088Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@usheninte/postgres-parser
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# postgres-parser
Parses PostgreSQL database URL string and returns values for `user`, `password`, `host`, `port` and database `name`.
## Installation
```
npm install @usheninte/postgres-parser
// OR
yarn add @usheninte/postgres-parser
```
> Do the following to use the package
```js
const dbstring = require('@usheninte/postgres-parser');
const { user, password, host, port, name } = dbstring(
'postgres://USER:PASSWORD@HOST:PORT/NAME',
);
```
Output from the following test string `postgres://USER:PASSWORD@HOST:PORT/NAME`
```json
{
"user": "USER",
"password": "PASSWORD",
"host": "HOST",
"port": "PORT",
"name": "NAME"
}
```