chore(postgresql): rename app folder and add icon
This commit is contained in:
75
packages/backend/src/apps/postgresql/auth/index.ts
Normal file
75
packages/backend/src/apps/postgresql/auth/index.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'version',
|
||||
label: 'PostgreSQL version',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description:
|
||||
'The version of PostgreSQL database that user want to connect with.',
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'host',
|
||||
label: 'Host',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: '127.0.0.1',
|
||||
placeholder: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'port',
|
||||
label: 'Port',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: '5432',
|
||||
placeholder: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'database',
|
||||
label: 'Database Name',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'user',
|
||||
label: 'Database username',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description:
|
||||
'The user who has access on postgres database.',
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'password',
|
||||
label: 'Password',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
|
||||
],
|
||||
|
||||
verifyCredentials,
|
||||
isStillVerified
|
||||
};
|
@@ -0,0 +1,10 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
await verifyCredentials($);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -0,0 +1,23 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import logger from '../../../helpers/logger';
|
||||
import getClient from '../common/postgres-client';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const pgClient = getClient($);
|
||||
const checkConnection = await pgClient.raw('SELECT 1');
|
||||
|
||||
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),
|
||||
user: $.auth.data.user,
|
||||
password: $.auth.data.password,
|
||||
database: $.auth.data.database
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
Reference in New Issue
Block a user