mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
Connection test
This commit is contained in:
24
src/main/ipc-api/connection.js
Normal file
24
src/main/ipc-api/connection.js
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
import { ipcMain } from 'electron';
|
||||
import knex from 'knex';
|
||||
|
||||
export default () => {
|
||||
ipcMain.handle('testConnection', async (event, conn) => {
|
||||
try {
|
||||
await knex({
|
||||
client: conn.client,
|
||||
connection: {
|
||||
host: conn.host,
|
||||
port: +conn.port,
|
||||
user: conn.user,
|
||||
password: conn.password
|
||||
}
|
||||
}).raw('SELECT 1+1 AS result');
|
||||
|
||||
return { status: 'success' };
|
||||
}
|
||||
catch (err) {
|
||||
return { status: 'error', response: err };
|
||||
}
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user