adba
Version:
Any DataBase to API
42 lines (41 loc) • 1.13 kB
TypeScript
import { Knex } from 'knex';
/**
* Interface for SSH Tunnel options
*/
export interface TunnelSSHOptions {
privateKey: string;
passphrase?: string;
username: string;
host: string;
port: number;
localhost?: string;
}
/**
* Interface for additional knex connection config
*/
export interface KnexInstanceOptions {
host?: string;
user?: string;
password?: string;
database?: string;
tunnel?: boolean | TunnelSSHOptions;
knexConfig?: Partial<Knex.Config>;
knexConnection?: Partial<Knex.MySqlConnectionConfig>;
}
/**
* Interface for extends knex object
*/
export interface RefDblDB {
current: Knex<any, any[]>;
}
/**
* Generate knex instance with optional SSH tunneling
* @param host DB Host
* @param user DB User
* @param password DB Password
* @param database DB Name
* @param conf Additional config including tunnel, knexConfig and connection
* @returns Object with `.current` knex instance or false
*/
declare function knexInstances({ host, user, password, database, ...conf }?: KnexInstanceOptions): Promise<RefDblDB | false>;
export default knexInstances;