File size: 760 Bytes
3206347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import logger from '../../../helpers/logger.js';
import getClient from '../common/postgres-client.js';

const verifyCredentials = async ($) => {
  const client = getClient($);
  const checkConnection = await client.raw('SELECT 1');
  client.destroy();

  logger.debug(checkConnection);

  await $.auth.set({
    screenName: `${$.auth.data.user}@${$.auth.data.host}:${$.auth.data.port}/${$.auth.data.database}`,
    client: 'pg',
    version: $.auth.data.version,
    host: $.auth.data.host,
    port: Number($.auth.data.port),
    enableSsl:
      $.auth.data.enableSsl === 'true' || $.auth.data.enableSsl === true,
    user: $.auth.data.user,
    password: $.auth.data.password,
    database: $.auth.data.database,
  });
};

export default verifyCredentials;