Skip to content

Commit d065b93

Browse files
authored
refactor: implement config class from utils (#11)
* refactor: implement config class from utils * fix: remove @secjs/logger * ci: run test with NODE_TS=true * fix: update @secjs/env
1 parent abd840d commit d065b93

11 files changed

Lines changed: 34 additions & 229 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The intention behind this repository is to always maintain a `Storage` class to
2929
> it keeps as dev dependency because one day `@secjs/core` will install everything once.
3030
3131
```bash
32-
npm install @secjs/env @secjs/config @secjs/utils @secjs/logger @secjs/contracts @secjs/exceptions
32+
npm install @secjs/env @secjs/utils @secjs/contracts @secjs/exceptions
3333
```
3434

3535
> Then you can install the package using:

package-lock.json

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

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@secjs/storage",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "Handle your application files in Node.js",
55
"license": "MIT",
66
"author": "João Lenon <lenon@secjs.com.br>",
@@ -9,7 +9,7 @@
99
"homepage": "https://github.com/secjs/SecJS#readme",
1010
"scripts": {
1111
"build": "tsc",
12-
"test": "NODE_ENV= jest --verbose",
12+
"test": "NODE_ENV= NODE_TS=true jest --verbose",
1313
"test:debug": "DEBUG=* jest --verbose",
1414
"lint:fix": "eslint \"{src,tests}/**/*.ts\" --fix"
1515
},
@@ -20,11 +20,9 @@
2020
"nodejs"
2121
],
2222
"devDependencies": {
23-
"@secjs/config": "1.0.7",
24-
"@secjs/env": "1.2.5",
23+
"@secjs/env": "1.3.0",
2524
"@secjs/exceptions": "1.0.4",
26-
"@secjs/logger": "1.2.2",
27-
"@secjs/utils": "1.6.9",
25+
"@secjs/utils": "1.7.6",
2826
"@types/jest": "27.0.1",
2927
"@types/mime-types": "2.1.1",
3028
"@types/node": "14.17.0",

src/Drivers/GCSDriver.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
* file that was distributed with this source code.
88
*/
99

10-
import { Config } from '@secjs/config'
11-
import { File } from '@secjs/utils'
10+
import { join } from 'path'
11+
import { tmpdir } from 'os'
12+
import { promises } from 'fs'
13+
import { File, Config } from '@secjs/utils'
1214
import { Storage } from '@google-cloud/storage'
1315
import { InternalServerException } from '@secjs/exceptions'
1416
import { DriverContract } from '../Contracts/DriverContract'
15-
import { promises } from 'fs'
16-
import { join } from 'path'
17-
import { tmpdir } from 'os'
1817

1918
export class GCSDriver implements DriverContract {
2019
private gcsClient: Storage

src/Drivers/LocalDriver.ts

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

1010
import { promises } from 'fs'
11-
import { File } from '@secjs/utils'
12-
import { Config } from '@secjs/config'
11+
import { File, Config } from '@secjs/utils'
1312
import { InternalServerException } from '@secjs/exceptions'
1413
import { DriverContract } from '../Contracts/DriverContract'
1514

src/Drivers/S3Driver.ts

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

1010
import { S3 } from 'aws-sdk'
11-
import { File } from '@secjs/utils'
12-
import { Config } from '@secjs/config'
11+
import { File, Config } from '@secjs/utils'
1312
import { InternalServerException } from '@secjs/exceptions'
1413
import { DriverContract } from '../Contracts/DriverContract'
1514

src/Storage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import {
1414

1515
import { tmpdir } from 'os'
1616
import { promises } from 'fs'
17-
import { File } from '@secjs/utils'
18-
import { Config } from '@secjs/config'
1917
import { isAbsolute, join } from 'path'
18+
import { File, Config, Path } from '@secjs/utils'
2019
import { Drivers } from './Drivers/Drivers'
2120
import { DriverContract } from './Contracts/DriverContract'
2221

@@ -62,6 +61,8 @@ export class Storage {
6261
}
6362

6463
constructor(runtimeConfig: any = {}) {
64+
new Config().safeLoad(Path.config('filesystem'))
65+
6566
this.runtimeConfig = runtimeConfig
6667
this.driver = this.createDriverInstance()
6768
}

tests/build-storage.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { existsSync } from 'fs'
2-
import { Config } from '@secjs/config'
32
import { Storage } from '../src/Storage'
43
import { Folder, Path } from '@secjs/utils'
54
import { LocalDriver } from '../src/Drivers/LocalDriver'
@@ -10,8 +9,6 @@ describe('\n Build Drive Storage Class', () => {
109
const bigContent = Buffer.alloc(Math.max(0, 1024 * 1024 * 200 - 2), 'l')
1110

1211
beforeEach(async () => {
13-
await new Config().load()
14-
1512
storage = new Storage()
1613
})
1714

0 commit comments

Comments
 (0)