Skip to content

Commit

Permalink
refactor: implement config class from utils (#11)
Browse files Browse the repository at this point in the history
* refactor: implement config class from utils

* fix: remove @secjs/logger

* ci: run test with NODE_TS=true

* fix: update @secjs/env
  • Loading branch information
jlenon7 authored Mar 6, 2022
1 parent abd840d commit d065b93
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 229 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The intention behind this repository is to always maintain a `Storage` class to
> it keeps as dev dependency because one day `@secjs/core` will install everything once.
```bash
npm install @secjs/env @secjs/config @secjs/utils @secjs/logger @secjs/contracts @secjs/exceptions
npm install @secjs/env @secjs/utils @secjs/contracts @secjs/exceptions
```

> Then you can install the package using:
Expand Down
215 changes: 18 additions & 197 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@secjs/storage",
"version": "1.0.3",
"version": "1.0.4",
"description": "Handle your application files in Node.js",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand All @@ -9,7 +9,7 @@
"homepage": "https://github.com/secjs/SecJS#readme",
"scripts": {
"build": "tsc",
"test": "NODE_ENV= jest --verbose",
"test": "NODE_ENV= NODE_TS=true jest --verbose",
"test:debug": "DEBUG=* jest --verbose",
"lint:fix": "eslint \"{src,tests}/**/*.ts\" --fix"
},
Expand All @@ -20,11 +20,9 @@
"nodejs"
],
"devDependencies": {
"@secjs/config": "1.0.7",
"@secjs/env": "1.2.5",
"@secjs/env": "1.3.0",
"@secjs/exceptions": "1.0.4",
"@secjs/logger": "1.2.2",
"@secjs/utils": "1.6.9",
"@secjs/utils": "1.7.6",
"@types/jest": "27.0.1",
"@types/mime-types": "2.1.1",
"@types/node": "14.17.0",
Expand Down
9 changes: 4 additions & 5 deletions src/Drivers/GCSDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
* file that was distributed with this source code.
*/

import { Config } from '@secjs/config'
import { File } from '@secjs/utils'
import { join } from 'path'
import { tmpdir } from 'os'
import { promises } from 'fs'
import { File, Config } from '@secjs/utils'
import { Storage } from '@google-cloud/storage'
import { InternalServerException } from '@secjs/exceptions'
import { DriverContract } from '../Contracts/DriverContract'
import { promises } from 'fs'
import { join } from 'path'
import { tmpdir } from 'os'

export class GCSDriver implements DriverContract {
private gcsClient: Storage
Expand Down
3 changes: 1 addition & 2 deletions src/Drivers/LocalDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*/

import { promises } from 'fs'
import { File } from '@secjs/utils'
import { Config } from '@secjs/config'
import { File, Config } from '@secjs/utils'
import { InternalServerException } from '@secjs/exceptions'
import { DriverContract } from '../Contracts/DriverContract'

Expand Down
3 changes: 1 addition & 2 deletions src/Drivers/S3Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*/

import { S3 } from 'aws-sdk'
import { File } from '@secjs/utils'
import { Config } from '@secjs/config'
import { File, Config } from '@secjs/utils'
import { InternalServerException } from '@secjs/exceptions'
import { DriverContract } from '../Contracts/DriverContract'

Expand Down
5 changes: 3 additions & 2 deletions src/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import {

import { tmpdir } from 'os'
import { promises } from 'fs'
import { File } from '@secjs/utils'
import { Config } from '@secjs/config'
import { isAbsolute, join } from 'path'
import { File, Config, Path } from '@secjs/utils'
import { Drivers } from './Drivers/Drivers'
import { DriverContract } from './Contracts/DriverContract'

Expand Down Expand Up @@ -62,6 +61,8 @@ export class Storage {
}

constructor(runtimeConfig: any = {}) {
new Config().safeLoad(Path.config('filesystem'))

this.runtimeConfig = runtimeConfig
this.driver = this.createDriverInstance()
}
Expand Down
3 changes: 0 additions & 3 deletions tests/build-storage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { existsSync } from 'fs'
import { Config } from '@secjs/config'
import { Storage } from '../src/Storage'
import { Folder, Path } from '@secjs/utils'
import { LocalDriver } from '../src/Drivers/LocalDriver'
Expand All @@ -10,8 +9,6 @@ describe('\n Build Drive Storage Class', () => {
const bigContent = Buffer.alloc(Math.max(0, 1024 * 1024 * 200 - 2), 'l')

beforeEach(async () => {
await new Config().load()

storage = new Storage()
})

Expand Down
Loading

0 comments on commit d065b93

Please sign in to comment.