feat: Convert all app files to JS
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import knex from 'knex';
|
||||
|
||||
const getClient = ($) => {
|
||||
const client = knex({
|
||||
client: 'pg',
|
||||
version: $.auth.data.version,
|
||||
connection: {
|
||||
host: $.auth.data.host,
|
||||
port: Number($.auth.data.port),
|
||||
ssl: $.auth.data.enableSsl === 'true' || $.auth.data.enableSsl === true,
|
||||
user: $.auth.data.user,
|
||||
password: $.auth.data.password,
|
||||
database: $.auth.data.database,
|
||||
},
|
||||
});
|
||||
|
||||
return client;
|
||||
};
|
||||
|
||||
export default getClient;
|
@@ -1,22 +0,0 @@
|
||||
import knex, { Knex } from 'knex';
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const getClient = ($: IGlobalVariable): Knex<any, unknown[]> => {
|
||||
const client = knex({
|
||||
client: 'pg',
|
||||
version: $.auth.data.version as string,
|
||||
connection: {
|
||||
host: $.auth.data.host as string,
|
||||
port: Number($.auth.data.port),
|
||||
ssl: ($.auth.data.enableSsl === 'true' ||
|
||||
$.auth.data.enableSsl === true) as boolean,
|
||||
user: $.auth.data.user as string,
|
||||
password: $.auth.data.password as string,
|
||||
database: $.auth.data.database as string,
|
||||
},
|
||||
});
|
||||
|
||||
return client;
|
||||
};
|
||||
|
||||
export default getClient;
|
@@ -0,0 +1,14 @@
|
||||
const setParams = async (client, params) => {
|
||||
for (const { parameter, value } of params) {
|
||||
if (parameter) {
|
||||
const bindings = {
|
||||
parameter,
|
||||
value,
|
||||
};
|
||||
|
||||
await client.raw('SET :parameter: = :value:', bindings);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default setParams;
|
@@ -1,19 +0,0 @@
|
||||
import { Knex } from 'knex';
|
||||
import { type IJSONValue } from '@automatisch/types';
|
||||
|
||||
type TParams = { parameter: string; value: string; }[];
|
||||
|
||||
const setParams = async (client: Knex<any, unknown[]>, params: IJSONValue = []): Promise<void> => {
|
||||
for (const { parameter, value } of (params as TParams)) {
|
||||
if (parameter) {
|
||||
const bindings = {
|
||||
parameter,
|
||||
value,
|
||||
};
|
||||
|
||||
await client.raw('SET :parameter: = :value:', bindings);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default setParams;
|
Reference in New Issue
Block a user