Skip to content

Commit c1d99d8

Browse files
Merge pull request #158 from codemask-labs/feat/update
feat: update dependency
2 parents c89caee + 9ae42cb commit c1d99d8

6 files changed

Lines changed: 2460 additions & 2042 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@ jobs:
2727

2828
- name: Type check files
2929
run: yarn tsc
30+
31+
- name: Run Trivy vulnerability scanner in fs mode
32+
uses: aquasecurity/trivy-action@0.33.1
33+
with:
34+
scan-type: 'fs'
35+
scan-ref: '.'
36+
ignore-unfixed: true
37+
vuln-type: 'os,library'
38+
severity: 'CRITICAL,HIGH'
39+

lib/exceptions/validation.exception.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export class ValidationException extends Error {
66
const failedConstraints = validationErrors
77
.map(error => {
88
const [constraint] = Object.values(error.constraints ?? {})
9-
const message = constraint || `${error.property} failed for unknown reason or constraint`
9+
const message = constraint !== '' ? constraint : `${error.property} failed for unknown reason or constraint`
1010

11-
return gray(`- ${message} ${blue(`(was: ${error.value || 'undefined'})`)}`)
11+
return gray(`- ${message} ${blue(`(was: ${error.value ?? 'undefined'})`)}`)
1212
})
1313
.join('\r\n')
1414

lib/getters/get-config-value.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Class, getConfigInstance } from 'lib/module'
44
export const getConfigValue = <T extends Class<any>, U>(constructor: T, getter: (config: InstanceType<T>) => U) => {
55
const instance = getConfigInstance(constructor)
66

7-
if (!instance) {
7+
if (instance === null || instance === undefined) {
88
throw new Error('Failed to find instance')
99
}
1010

lib/module/utils.ts

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import { registry } from './constants'
99

1010
export const registerConfigDefaults = (base: Class) => {
1111
if (!registry.has(base)) {
12-
const dependencies: Array<Class> = Reflect.getMetadata('design:paramtypes', base) || []
12+
const dependencies: Array<Class> = Reflect.getMetadata('design:paramtypes', base) ?? []
1313

14+
// eslint-disable-next-line functional/immutable-data
1415
registry.set(base, {
1516
base,
1617
dependencies,
@@ -28,6 +29,7 @@ export const registerConfigTransformOptions = (base: Class, transformOptions?: C
2829
throw new Error(`Failed to find registered config. Make sure to decorate a class with @Config()!`)
2930
}
3031

32+
// eslint-disable-next-line functional/immutable-data
3133
registry.set(base, {
3234
...current,
3335
transformOptions
@@ -41,10 +43,11 @@ export const registerConfigTransformTranslations = (base: Class, propertyName: s
4143
throw new Error(`Failed to find registered config. Make sure to decorate a class with @Config()!`)
4244
}
4345

46+
// eslint-disable-next-line functional/immutable-data
4447
registry.set(base, {
4548
...current,
4649
propertyNameTranslations: {
47-
...current?.propertyNameTranslations,
50+
...current.propertyNameTranslations,
4851
[propertyName]: environmentPropertyName
4952
}
5053
})
@@ -57,7 +60,7 @@ export const getConfigInstance = <T extends Class>(base: T, transformOptions?: T
5760
throw new Error(`Failed to find registered config. Make sure to decorate a class with @Config()!`)
5861
}
5962

60-
if (registeredDependency.instance) {
63+
if (isNotNil(registeredDependency.instance)) {
6164
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
6265
return registeredDependency.instance
6366
}
@@ -80,27 +83,26 @@ export const getConfigInstance = <T extends Class>(base: T, transformOptions?: T
8083

8184
const storage = getMetadataStorage()
8285
const metadatas = storage.getTargetValidationMetadatas(base, base.name, false, false)
83-
const transformedProperties = metadatas.reduce(
84-
(acc, { propertyName, target }) => {
85-
if (acc[propertyName]) {
86-
return acc
87-
}
88-
89-
const prototype: object = typeof target === 'function' ? target.prototype : {}
90-
const environmentPropertyName = registeredDependency.propertyNameTranslations[propertyName]
91-
92-
const key = environmentPropertyName || propertyName
93-
const value = environmentVariables[key] || process.env[key]
94-
const type = Reflect.getMetadata('design:type', prototype, propertyName)
95-
96-
return {
97-
...acc,
98-
[propertyName]: isNotNil(value) ? toValueByType(type, value) : value
99-
}
100-
},
101-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
102-
{} as Record<string, any>
103-
)
86+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
87+
const transformedProperties = metadatas.reduce<Record<string, any>>((acc, { propertyName, target }) => {
88+
if (isNotNil(acc[propertyName])) {
89+
return acc
90+
}
91+
92+
const prototype: object = typeof target === 'function' ? target.prototype : {}
93+
const environmentPropertyName = registeredDependency.propertyNameTranslations[propertyName]
94+
95+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
96+
const key = environmentPropertyName || propertyName
97+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
98+
const value = environmentVariables[key] || process.env[key]
99+
const type = Reflect.getMetadata('design:type', prototype, propertyName)
100+
101+
return {
102+
...acc,
103+
[propertyName]: isNotNil(value) ? toValueByType(type, value) : value
104+
}
105+
}, {})
104106

105107
/**
106108
* Make the instance methods, auto-bindable to "this" reference so we can destruct the
@@ -114,18 +116,15 @@ export const getConfigInstance = <T extends Class>(base: T, transformOptions?: T
114116

115117
const descriptors = Object.getOwnPropertyDescriptors(base.prototype)
116118
const descriptorNames = Object.keys(descriptors).filter(name => name !== 'constructor')
117-
const unreferencedMethods = descriptorNames.reduce(
118-
(result, name) => {
119-
const descriptor = descriptors[name]
120-
121-
return {
122-
...result,
123-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, functional/functional-parameters
124-
[name]: (...args: Array<any>) => descriptor.value.apply(instance, args)
125-
}
126-
},
127-
{} as Record<string, () => void>
128-
)
119+
const unreferencedMethods = descriptorNames.reduce<Record<string, () => void>>((result, name) => {
120+
const descriptor = descriptors[name]
121+
122+
return {
123+
...result,
124+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, functional/functional-parameters
125+
[name]: (...args: Array<any>) => descriptor.value.apply(instance, args)
126+
}
127+
}, {})
129128

130129
/**
131130
* Due to missing option for passing constructor arguments, we are creating
@@ -137,7 +136,7 @@ export const getConfigInstance = <T extends Class>(base: T, transformOptions?: T
137136
static readonly name = base.name
138137

139138
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, functional/functional-parameters
140-
constructor(...unusedArgs: Array<any>) {
139+
constructor(...args: Array<any>) {
141140
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
142141
super(...resolvedDependencies)
143142
}
@@ -161,7 +160,7 @@ export const getConfigInstance = <T extends Class>(base: T, transformOptions?: T
161160
}
162161
})
163162

164-
if (validationErrors.length) {
163+
if (validationErrors.length > 0) {
165164
throw new ValidationException(base.name, validationErrors)
166165
}
167166

@@ -171,6 +170,7 @@ export const getConfigInstance = <T extends Class>(base: T, transformOptions?: T
171170
instance
172171
}
173172

173+
// eslint-disable-next-line functional/immutable-data
174174
registry.set(base, config)
175175

176176
// eslint-disable-next-line @typescript-eslint/no-unsafe-return

package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,33 @@
6464
},
6565
"dependencies": {
6666
"chalk": "4.1.2",
67-
"dotenv": "16.4.7",
68-
"ramda": "0.30.1"
67+
"dotenv": "17.2.3",
68+
"ramda": "0.32.0"
6969
},
7070
"devDependencies": {
71-
"@commitlint/config-conventional": "19.6.0",
72-
"@nestjs/cli": "11.0.2",
73-
"@nestjs/common": "11.0.5",
74-
"@nestjs/core": "11.0.7",
75-
"@nestjs/platform-express": "11.0.7",
71+
"@commitlint/config-conventional": "20.0.0",
72+
"@nestjs/cli": "11.0.10",
73+
"@nestjs/common": "11.1.9",
74+
"@nestjs/core": "11.1.9",
75+
"@nestjs/platform-express": "11.1.9",
7676
"@nestjs/typeorm": "11.0.0",
77-
"@types/jest": "29.5.14",
78-
"@types/node": "22.10.10",
79-
"@types/pg": "8.11.10",
80-
"@types/ramda": "0.30.2",
77+
"@types/jest": "30.0.0",
78+
"@types/node": "24.10.1",
79+
"@types/pg": "8.15.6",
80+
"@types/ramda": "0.31.1",
8181
"class-transformer": "0.5.1",
82-
"class-validator": "0.14.1",
83-
"eslint": "9.19.0",
84-
"eslint-config-codemask": "2.0.0-beta.15",
85-
"jest": "29.7.0",
86-
"pg": "8.13.1",
87-
"prettier": "3.4.2",
82+
"class-validator": "0.14.2",
83+
"eslint": "9.39.1",
84+
"eslint-config-codemask": "2.2.1",
85+
"jest": "30.2.0",
86+
"pg": "8.16.3",
87+
"prettier": "3.6.2",
8888
"reflect-metadata": "0.2.2",
89-
"rimraf": "6.0.1",
90-
"ts-jest": "29.2.5",
89+
"rimraf": "6.1.0",
90+
"ts-jest": "29.4.5",
9191
"tscpaths": "0.0.9",
92-
"typeorm": "0.3.20",
93-
"typescript": "5.7.3"
92+
"typeorm": "0.3.27",
93+
"typescript": "5.9.3"
9494
},
9595
"files": [
9696
"dist",

0 commit comments

Comments
 (0)