Added database check.

This commit is contained in:
Mike Cao 2022-06-22 01:50:33 -07:00
parent 3122bab419
commit ac3017b2e4
6 changed files with 104 additions and 40 deletions

View file

@ -2,7 +2,7 @@ require('dotenv').config();
const fse = require('fs-extra');
const path = require('path');
function getDatabase() {
function getDatabaseType() {
const type =
process.env.DATABASE_TYPE ||
(process.env.DATABASE_URL && process.env.DATABASE_URL.split(':')[0]);
@ -14,7 +14,7 @@ function getDatabase() {
return type;
}
const databaseType = getDatabase();
const databaseType = getDatabaseType();
if (!databaseType || !['mysql', 'postgresql'].includes(databaseType)) {
throw new Error('Missing or invalid database');