Skip to content

Commit 1279802

Browse files
authored
Merge pull request #4 from SecJS/refactor/len-impl-config-utils
refactor: remove @secjs/config dependency and use config from utils
2 parents 5985530 + 45dac32 commit 1279802

7 files changed

Lines changed: 17 additions & 36 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ driver (SQL and NoSQL).
3030
> it keeps as dev dependency because one day `@secjs/core` will install everything once.
3131
3232
```bash
33-
npm install @secjs/env @secjs/utils @secjs/config @secjs/exceptions
33+
npm install @secjs/env @secjs/utils @secjs/exceptions
3434
```
3535

3636
> Then you can install the package using:

package-lock.json

Lines changed: 9 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@secjs/database",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Handle your application database with factories, seeders and query builder in Node.js",
55
"license": "MIT",
66
"author": "João Lenon <lenon@secjs.com.br>",
@@ -24,10 +24,9 @@
2424
"query-builder"
2525
],
2626
"devDependencies": {
27-
"@secjs/config": "1.1.4",
2827
"@secjs/env": "1.2.8",
2928
"@secjs/exceptions": "1.0.4",
30-
"@secjs/utils": "1.7.3",
29+
"@secjs/utils": "1.7.6",
3130
"@types/jest": "27.0.1",
3231
"@types/knex": "0.16.1",
3332
"@types/mime-types": "2.1.1",

src/Database.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import {
1111
InternalServerException,
1212
NotImplementedException,
1313
} from '@secjs/exceptions'
14-
import { Config } from '@secjs/config'
14+
1515
import { Drivers } from './Drivers/Drivers'
1616
import { JoinType } from './Contracts/JoinType'
17-
import { PaginatedResponse } from '@secjs/utils'
17+
import { Config, PaginatedResponse, Path } from '@secjs/utils'
1818
import { DriverContract } from './Contracts/DriverContract'
1919
import { DatabaseContract } from './Contracts/DatabaseContract'
2020
import { TransactionContract } from './Contracts/TransactionContract'
@@ -66,6 +66,8 @@ export class Database implements DatabaseContract {
6666
}
6767

6868
constructor(runtimeConfig: any = {}) {
69+
new Config().safeLoad(Path.config('database'))
70+
6971
this.runtimeConfig = runtimeConfig
7072
this.driver = this.createDriverInstance()
7173
}

src/Utils/ConnectionResolver.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
*/
99

1010
import knex, { Knex } from 'knex'
11-
import { Config } from '@secjs/config'
12-
import { Parser } from '@secjs/utils'
1311
import { createConnection } from 'mongoose'
12+
import { Config, Parser } from '@secjs/utils'
1413
import { InternalServerException } from '@secjs/exceptions'
1514

1615
export class ConnectionResolver {

tests/database-mongodb.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import '@secjs/env/src/utils/global'
1111

12-
import { Config } from '@secjs/config'
1312
import { Database } from '../src/Database'
1413
import { MongoMemoryReplSet } from 'mongodb-memory-server'
1514
import { TableBuilder } from '../src/Builders/TableBuilder'
@@ -40,8 +39,6 @@ describe('\n Database Mongo Class', () => {
4039
process.env.DB_USERNAME = ''
4140
process.env.DB_PASSWORD = ''
4241
process.env.DB_FILENAME = ':memory:'
43-
44-
await new Config().load()
4542
})
4643

4744
beforeEach(async () => {

tests/database-postgresql.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import '@secjs/env/src/utils/global'
1111

1212
import { Knex } from 'knex'
13-
import { Config } from '@secjs/config'
1413
import { Database } from '../src/Database'
1514
import { DatabaseContract } from '../src/Contracts/DatabaseContract'
1615

@@ -24,8 +23,6 @@ describe('\n Database PostgreSQL Class', () => {
2423
process.env.DB_USERNAME = 'postgres'
2524
process.env.DB_PASSWORD = 'root'
2625
process.env.DB_FILENAME = ':memory:'
27-
28-
await new Config().load()
2926
})
3027

3128
beforeEach(async () => {

0 commit comments

Comments
 (0)