File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,17 @@ import * as mysql from 'mysql';
2
2
import { promisify } from 'util' ;
3
3
import { SessionProps , StoreData } from '../../types' ;
4
4
5
+ const MYSQL_CONFIG = {
6
+ host : process . env . MYSQL_HOST ,
7
+ database : process . env . MYSQL_DATABASE ,
8
+ user : process . env . MYSQL_USERNAME ,
9
+ password : process . env . MYSQL_PASSWORD ,
10
+ ...( process . env . MYSQL_PORT && { port : process . env . MYSQL_PORT } ) ,
11
+ } ;
12
+
5
13
// For use with Heroku ClearDB
6
14
// Other mysql: https://www.npmjs.com/package/mysql#establishing-connections
7
- const connection = mysql . createConnection ( process . env . CLEARDB_DATABASE_URL ) ;
15
+ const connection = mysql . createConnection ( process . env . CLEARDB_DATABASE_URL ? process . env . CLEARDB_DATABASE_URL : MYSQL_CONFIG ) ;
8
16
const query = promisify ( connection . query . bind ( connection ) ) ;
9
17
10
18
// Use setUser for storing global user data (persists between installs)
Original file line number Diff line number Diff line change 1
1
const mysql = require ( 'mysql' ) ;
2
2
const util = require ( 'util' ) ;
3
3
4
- const connection = mysql . createConnection ( process . env . CLEARDB_DATABASE_URL ) ;
4
+ const MYSQL_CONFIG = {
5
+ host : process . env . MYSQL_HOST ,
6
+ database : process . env . MYSQL_DATABASE ,
7
+ user : process . env . MYSQL_USERNAME ,
8
+ password : process . env . MYSQL_PASSWORD ,
9
+ ...( process . env . MYSQL_PORT && { port : process . env . MYSQL_PORT } ) ,
10
+ } ;
11
+
12
+ const connection = mysql . createConnection ( process . env . CLEARDB_DATABASE_URL ? process . env . CLEARDB_DATABASE_URL : MYSQL_CONFIG ) ;
5
13
const query = util . promisify ( connection . query . bind ( connection ) ) ;
6
14
7
15
const usersCreate = query ( 'CREATE TABLE `users` (\n' +
You can’t perform that action at this time.
0 commit comments