feat: add port to MySQL config

pull/249/head
Sylvie 12 months ago
parent 7126ad957a
commit 7791af03c1
No known key found for this signature in database
GPG Key ID: 75AB0FE5B983A3AF

@ -57,6 +57,7 @@ const Checkers: UserConfigTypeChecker = {
user: basicStringChecker,
password: basicStringChecker,
database: basicStringChecker,
port: (val) => numChecker(val) && val >= 1 && val <= 65535
},
postgres: {
port: (val) => numChecker(val) && val >= 1 && val <= 65535
@ -114,6 +115,7 @@ export class UserConfig {
if (!Checkers.sql.mySql.user(config.database.options.user)) throw new Error('Invalid databse user');
if (!Checkers.sql.mySql.password(config.database.options.password)) throw new Error('Invalid database password');
if (!Checkers.sql.mySql.database(config.database.options.database)) throw new Error('Invalid database');
if (!Checkers.sql.mySql.port(config.database.options.port)) throw new Error('Invalid database port');
if (config.database.kind == 'postgres') {
if (!Checkers.sql.postgres.port((config.database.options as PostgresConfiguration).port)) {
throw new Error("Invalid database port");

2
common/types.d.ts vendored

@ -58,6 +58,7 @@ declare module 'ass' {
interface MySQLConfiguration {
host: string;
port: number;
user: string;
password: string;
database: string;
@ -126,6 +127,7 @@ declare module 'ass' {
sql: {
mySql: {
host: (val: any) => boolean;
port: (val: any) => boolean;
user: (val: any) => boolean;
password: (val: any) => boolean;
database: (val: any) => boolean;

@ -45,6 +45,7 @@ document.addEventListener('DOMContentLoaded', () => {
mySqlTab: document.querySelector('#mysql-tab') as SlTab,
mySqlHost: document.querySelector('#mysql-host') as SlInput,
mySqlPort: document.querySelector('#mysql-port') as SlInput,
mySqlUser: document.querySelector('#mysql-user') as SlInput,
mySqlPassword: document.querySelector('#mysql-password') as SlInput,
mySqlDatabase: document.querySelector('#mysql-database') as SlInput,
@ -108,8 +109,9 @@ document.addEventListener('DOMContentLoaded', () => {
config.database = {
kind: 'mysql',
options: {
host: Elements.mySqlHost.value,
user: Elements.mySqlUser.value,
host: Elements.mySqlHost.value,
port: parseInt(Elements.mySqlPort.value),
user: Elements.mySqlUser.value,
password: Elements.mySqlPassword.value,
database: Elements.mySqlDatabase.value
}
@ -120,9 +122,9 @@ document.addEventListener('DOMContentLoaded', () => {
config.database = {
kind: 'postgres',
options: {
host: Elements.pgsqlHost.value,
port: parseInt(Elements.pgsqlPort.value),
user: Elements.pgsqlUser.value,
host: Elements.pgsqlHost.value,
port: parseInt(Elements.pgsqlPort.value),
user: Elements.pgsqlUser.value,
password: Elements.pgsqlPassword.value,
database: Elements.pgsqlDatabase.value
}

@ -44,6 +44,8 @@ block content
sl-tab-panel(name='mysql')
h3.setup-text-item-title Host
sl-input#mysql-host(type='text' placeholder='mysql.example.com' clearable): sl-icon(slot='prefix' name='fas-server' library='fa')
h3.setup-text-item-title Port
sl-input#mysql-port(type='number' placeholder='3306' min='1' max='65535' no-spin-buttons clearable): sl-icon(slot='prefix' name='fas-hashtag' library='fa')
h3.setup-text-item-title User
sl-input#mysql-user(type='text' placeholder='myassql' clearable): sl-icon(slot='prefix' name='fas-user' library='fa')
h3.setup-text-item-title Password

Loading…
Cancel
Save