diff --git a/package.json b/package.json index 916957f..24c6823 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nexys/fetchr", - "version": "0.4.1", + "version": "0.5.0", "license": "AGPL-3.0-or-later", "main": "dist/index.js", "files": [ diff --git a/src/lib/database/connection.ts b/src/lib/database/connection.ts index 0490e84..1c7b0df 100644 --- a/src/lib/database/connection.ts +++ b/src/lib/database/connection.ts @@ -1,4 +1,5 @@ import mysql from "mysql2"; +import { PoolOptions, SslOptions } from "mysql2/typings/mysql"; import * as T from "./type"; // see: https://dev.mysql.com/doc/mysql-port-reference/en/mysql-ports-reference-tables.html#mysql-client-server-ports @@ -8,20 +9,29 @@ export class SQL { //connection: mysql.Connection; pool: T.Pool; - constructor( - host: string, - user: string, - password: string, - database: string, - port: number = mysqlDefaultPort - ) { - const config = { + constructor({ + host, + user, + password, + database, + port = mysqlDefaultPort, + ssl, + }: { + host: string; + user: string; + password: string; + database: string; + port: number; + ssl?: string | SslOptions; + }) { + const config: PoolOptions = { host, user, password, database, port, multipleStatements: true, + ssl, }; // https://www.npmjs.com/package/mysql2#using-connection-pools