Skip to content

Commit

Permalink
add ssl options
Browse files Browse the repository at this point in the history
  • Loading branch information
John B committed Mar 31, 2022
1 parent 5d47d6f commit 59b6f12
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
26 changes: 18 additions & 8 deletions src/lib/database/connection.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 59b6f12

Please sign in to comment.