Advertisement
Guest User

Untitled

a guest
Jun 26th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1.  
  2.  
  3. function pgConfig(url) {
  4. const config = {};
  5.  
  6. let { auth, hostname, port, pathname, query } = parse(url);
  7. let { poolSize, poolIdleTimeout } = (query || {});
  8.  
  9. if (auth) {
  10. let [user, password] = auth.split(':');
  11. config.user = user;
  12. config.password = password;
  13. }
  14.  
  15. if (hostname) {
  16. config.host = hostname;
  17. }
  18.  
  19. if (port) {
  20. config.port = parseInt(port, 10);
  21. }
  22.  
  23. if (pathname) {
  24. config.database = pathname.slice(1);
  25. } else {
  26. config.database = 'wfs';
  27. }
  28.  
  29. if (poolSize) {
  30. (config as any).poolSize = poolSize;
  31. }
  32.  
  33. if (poolSize) {
  34. (config as any).poolIdleTimeout = poolIdleTimeout;
  35. }
  36.  
  37. return config;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement