Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pgConfig(url) {
- const config = {};
- let { auth, hostname, port, pathname, query } = parse(url);
- let { poolSize, poolIdleTimeout } = (query || {});
- if (auth) {
- let [user, password] = auth.split(':');
- config.user = user;
- config.password = password;
- }
- if (hostname) {
- config.host = hostname;
- }
- if (port) {
- config.port = parseInt(port, 10);
- }
- if (pathname) {
- config.database = pathname.slice(1);
- } else {
- config.database = 'wfs';
- }
- if (poolSize) {
- (config as any).poolSize = poolSize;
- }
- if (poolSize) {
- (config as any).poolIdleTimeout = poolIdleTimeout;
- }
- return config;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement