Skip to content

Commit 0e205f9

Browse files
committed
fix: default db values for localhost
1 parent 2bbaf3a commit 0e205f9

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
collectCoverageFrom: [
1111
'<rootDir>/src/**/*.{ts,js}',
1212
'!<rootDir>/src/index.{ts,js}',
13+
'!<rootDir>/src/database/**',
1314
],
1415
coverageThreshold: {
1516
global: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"start:dev": "ts-node-dev --inspect --transpile-only --ignore-watch node_modules --respawn src/index.ts",
1010
"test": "jest --runInBand",
1111
"test:dev": "node --inspect ./node_modules/jest/bin/jest.js --runInBand",
12-
"typeorm": "typeorm-ts-node-commonjs"
12+
"typeorm": "ts-node-dev ./node_modules/typeorm/cli.js"
1313
},
1414
"author": "Samuel Caçador",
1515
"license": "MIT",

src/database/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
/* istanbul ignore file */
21
import { DataSource } from 'typeorm';
32

43
const { DB_HOST, DB_PORT, DB_USERNAME, DB_PASSWORD, DB_DATABASE } = process.env;
54
const AppDataSource = new DataSource({
65
type: 'mysql',
7-
host: DB_HOST,
8-
port: Number(DB_PORT),
9-
username: DB_USERNAME,
10-
password: DB_PASSWORD,
11-
database: DB_DATABASE,
6+
host: DB_HOST ?? 'localhost',
7+
port: Number(DB_PORT) ?? 3306,
8+
username: DB_USERNAME ?? 'user',
9+
password: DB_PASSWORD ?? 'secret',
10+
database: DB_DATABASE ?? 'db',
1211
synchronize: true,
1312
logging: false,
1413
entities: ['src/entities/*.*'],

0 commit comments

Comments
 (0)