Skip to content

Commit 930bf4b

Browse files
committed
chore: update deps
- move mongodb to peerDependencies - eslint bump - bump version - bump yarn to berry version
1 parent eb71658 commit 930bf4b

File tree

22 files changed

+7734
-4720
lines changed

22 files changed

+7734
-4720
lines changed

.eslintrc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@
55
"parserOptions": {
66
"project": "./tsconfig.json"
77
},
8-
"ignorePatterns": ["typedoc.js", "docs/*"],
9-
"extends": ["standard-with-typescript", "prettier"],
8+
"ignorePatterns": [
9+
"typedoc.js",
10+
"docs/*"
11+
],
12+
"extends": [
13+
"eslint:recommended",
14+
"plugin:@typescript-eslint/eslint-recommended",
15+
"plugin:@typescript-eslint/recommended",
16+
"prettier"
17+
],
1018
"root": true,
1119
"rules": {
1220
"@typescript-eslint/explicit-function-return-type": "off",
1321
"@typescript-eslint/no-explicit-any": "off",
1422
"@typescript-eslint/no-empty-interface": "off"
1523
}
16-
}
24+
}

.github/workflows/test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [12.x, 14.x, 15.x]
19+
node-version: [14.x, 16.x, 18.x]
2020
mongodb-version: [4.2, 4.2, 4.4, 5.0]
2121

2222
steps:
@@ -37,8 +37,7 @@ jobs:
3737
yarn run build
3838
yarn run test:cov
3939
- name: Codecov
40-
uses: codecov/codecov-action@v1.0.5
40+
uses: codecov/codecov-action@v2
4141
with:
42-
token: ${{ secrets.CODECOV_TOKEN }}
4342
file: ./coverage/coverage-final.json
4443
fail_ci_if_error: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ coverage/
33
dist/
44
*.tgz
55
.DS_Store
6+
.yarn/install-state.gz
7+
.yarn/cache

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ renovate.json
1919
.github/
2020
dist/test/
2121
coverage/
22+
.yarn*
23+
CHANGELOG.md

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"typescript.tsdk": "./node_modules/typescript/lib",
44
"editor.formatOnSave": true,
55
"editor.codeActionsOnSave": {
6-
"source.fixAll.eslint": true
6+
"source.fixAll.eslint": true,
7+
"source.organizeImports": true
78
},
89
"[javascript]": {
910
"editor.defaultFormatter": "esbenp.prettier-vscode"

.yarn/releases/yarn-3.2.0.cjs

Lines changed: 785 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarnPath: .yarn/releases/yarn-3.2.0.cjs

package.json

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nestjs-mongo",
3-
"version": "0.13.2",
3+
"version": "0.14.0",
44
"description": "A NestJS module that provide a simple mongodb orm like",
55
"keywords": [
66
"nestjs",
@@ -17,51 +17,47 @@
1717
"peerDependencies": {
1818
"@nestjs/common": "^8",
1919
"@nestjs/core": "^8",
20-
"reflect-metadata": "^0.1.13",
21-
"class-validator": "^0.13.1"
20+
"class-validator": "^0.13.1",
21+
"mongodb": "^4.5.0",
22+
"reflect-metadata": "^0.1.13"
2223
},
2324
"dependencies": {
2425
"class-transformer": "0.5.1",
2526
"cls-hooked": "4.2.2",
26-
"debug": "4.3.3",
27+
"debug": "4.3.4",
2728
"global": "4.4.0",
2829
"lodash": "4.17.21",
29-
"mongodb": "4.3.1",
3030
"slugify": "1.6.5",
3131
"uuid": "8.3.2"
3232
},
3333
"devDependencies": {
34-
"@nestjs/common": "8.2.6",
35-
"@nestjs/core": "8.2.6",
36-
"@nestjs/testing": "8.2.6",
37-
"@nestjs/platform-express": "8.2.6",
38-
"@types/cls-hooked": "4.3.3",
39-
"@types/debug": "4.1.7",
40-
"@types/jest": "27.4.0",
41-
"@types/lodash": "4.14.178",
42-
"@types/supertest": "2.0.11",
43-
"@typescript-eslint/eslint-plugin": "5.10.2",
44-
"@typescript-eslint/parser": "^4.0.1",
45-
"@types/node": "17.0.14",
46-
"class-validator": "0.13.2",
47-
"eslint": "^7.12.1",
48-
"eslint-config-prettier": "8.3.0",
49-
"eslint-plugin-import": "2.25.4",
50-
"eslint-plugin-node": "^11.1.0",
51-
"eslint-plugin-prefer-arrow": "1.2.3",
52-
"eslint-plugin-promise": "^5.0.0",
53-
"eslint-plugin-standard": "5.0.0",
54-
"eslint-config-standard-with-typescript": "^21.0.1",
55-
"jest": "27.4.7",
56-
"prettier": "2.5.1",
57-
"reflect-metadata": "0.1.13",
58-
"rxjs": "7.5.2",
59-
"supertest": "6.2.2",
60-
"ts-jest": "27.1.3",
61-
"ts-node": "10.4.0",
62-
"tsconfig-paths": "3.12.0",
63-
"typedoc": "0.22.11",
64-
"typescript": "4.5.5"
34+
"@nestjs/common": "^8.4.4",
35+
"@nestjs/core": "^8.4.4",
36+
"@nestjs/platform-express": "^8.4.4",
37+
"@nestjs/testing": "^8.4.4",
38+
"@types/cls-hooked": "^4.3.3",
39+
"@types/debug": "^4.1.7",
40+
"@types/jest": "^27.4.1",
41+
"@types/lodash": "^4.14.182",
42+
"@types/node": "^17.0.27",
43+
"@types/supertest": "^2.0.12",
44+
"@typescript-eslint/eslint-plugin": "^5.21.0",
45+
"@typescript-eslint/parser": "^5.21.0",
46+
"class-validator": "^0.13.2",
47+
"eslint": "^8.14.0",
48+
"eslint-config-prettier": "^8.5.0",
49+
"eslint-plugin-import": "^2.26.0",
50+
"jest": "^27.5.1",
51+
"mongodb": "^4.5.0",
52+
"prettier": "^2.6.2",
53+
"reflect-metadata": "^0.1.13",
54+
"rxjs": "^7.5.5",
55+
"supertest": "^6.2.3",
56+
"ts-jest": "^27.1.4",
57+
"ts-node": "^10.7.0",
58+
"tsconfig-paths": "^3.14.1",
59+
"typedoc": "^0.22.15",
60+
"typescript": "^4.6.3"
6561
},
6662
"scripts": {
6763
"build": "rm -Rf dist && tsc -b tsconfig.build.json",
@@ -93,6 +89,7 @@
9389
"coverageDirectory": "../coverage"
9490
},
9591
"engines": {
96-
"node": ">=0.12"
97-
}
92+
"node": ">=0.14"
93+
},
94+
"packageManager": "yarn@3.2.0"
9895
}

src/entity/manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class EntityManager {
144144
async validate<Model extends EntityInterface = any>(
145145
obj: Model,
146146
validatorOptions: ValidatorOptions = {},
147-
throwError: boolean = false
147+
throwError = false
148148
) {
149149
const errors = await validate(obj, {
150150
validationError: { target: true, value: true },

src/entity/repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class EntityRepository<Model extends EntityInterface> {
6868
return this.em.merge(entity, data, excludePrefixes);
6969
}
7070

71-
async validate(entity: Model, validatorOptions: ValidatorOptions = {}, throwError: boolean = false) {
71+
async validate(entity: Model, validatorOptions: ValidatorOptions = {}, throwError = false) {
7272
return await this.em.validate(entity, validatorOptions, throwError);
7373
}
7474
}

src/entity/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export abstract class EntityService<
5555
}
5656

5757
async list(filter: Filter, ResponseType: any, ...rest: any[]): Promise<PaginatedData<Model>> {
58-
const cursor = await this.repository.find(filter.toQuery());
58+
const cursor = await this.repository.find(filter.toQuery(), ...rest);
5959

6060
if (!isEmpty(filter.orderBy)) {
6161
cursor.sort(filter.getSort());

src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const isClass = (fn: any) => /^\s*class/.test(fn.toString());
22

3-
export function getObjectName(o: Object): string {
3+
export function getObjectName(o: any): string {
44
return o.constructor.name;
55
}

src/module/core.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export class MongoModule implements OnModuleDestroy {
4343
const mongoClientProvider = {
4444
provide: mongoConnectionToken,
4545
useFactory: async (config: MongoModuleOptions): Promise<MongoClient> => {
46+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4647
const { uri, exceptionFactory, ...mongoOpts } = config;
4748
const client = new MongoClient(uri, mongoOpts);
4849
return await client.connect();

src/module/interfaces.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ export interface MongoModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'>
2121
inject?: any[];
2222
}
2323

24-
export interface MongoFeatureModelOptions {
25-
model: Type<EntityInterface>;
26-
repository?: Type<EntityRepository<EntityInterface>>;
24+
export interface MongoFeatureModelOptions<Model extends EntityInterface, Repository extends EntityRepository<Model>> {
25+
model: Type<Model>;
26+
repository?: Type<Repository>;
2727
}
2828

2929
export interface MongoFeatureOptions {
3030
connectionName?: string;
31-
models: Array<MongoFeatureModelOptions | Type<EntityInterface>>;
31+
models: Array<MongoFeatureModelOptions<any, any> | Type<EntityInterface>>;
3232
}
3333

3434
export type ExceptionFactory = (errors: ValidationError[]) => any;

src/relationship/constraint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class IsValidRelationshipConstraint implements ValidatorConstraintInterfa
1313
private em: EntityManager;
1414
private message: string;
1515

16-
defaultMessage?(args?: IsValidRelationshipValidationArguments): string {
16+
defaultMessage?(): string {
1717
return this.message;
1818
}
1919

src/relationship/metadata.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
RelationshipCascade,
1212
RelationshipMetadata,
1313
RelationshipMetadataOptions,
14-
RelationshipTypeDescriptor,
14+
RelationshipTypeDescriptor
1515
} from './interfaces';
1616

1717
/**
@@ -49,7 +49,7 @@ export function setRelationshipMetadata<R extends EntityInterface = any>(
4949
* @param obj The instance of the entity (only required if the type of the relationship is dynamic)
5050
*/
5151
export function getRelationshipMetadata<R extends EntityInterface = any>(
52-
target: Function,
52+
target: any,
5353
property: string,
5454
em?: EntityManager,
5555
obj?: any

src/serializer/serializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function toJSON() {
88
const proto = Object.getPrototypeOf(this);
99

1010
const json = Object.entries(Object.getOwnPropertyDescriptors(proto))
11-
.filter(([_, { get }]) => typeof get === 'function')
11+
.filter(([, { get }]) => typeof get === 'function')
1212
.reduce(
1313
(obj, [key]) => ({
1414
...obj,

src/session/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class SessionLoaderMiddleware implements NestMiddleware {
1010
protected log = Debug(`${DEBUG}:SessionLoaderMiddleware`);
1111
protected static readonly ns = createNamespace(SESSION_LOADER_NAMESPACE);
1212

13-
use(_: Request, __: Response, next: Function) {
13+
use(_: Request, __: Response, next: (error?: Error | any) => void) {
1414
SessionLoaderMiddleware.ns.run(() => {
1515
this.log('Running namespace %s', SESSION_LOADER_NAMESPACE);
1616
next();

src/session/orchestrator.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ import { Debugger } from 'debug';
77
*/
88
export class TransactionsOrchestrator {
99
protected readonly jobs: Array<Promise<any>> = [];
10-
protected current: number = 0;
10+
protected current = 0;
1111

1212
constructor(protected readonly log: Debugger) {}
1313

14-
async addJob<F extends () => Promise<any>>(
15-
jobFunc: F
16-
): Promise<ReturnType<F>> {
14+
async addJob<F extends () => Promise<any>>(jobFunc: F): Promise<ReturnType<F>> {
1715
const current = this.current;
1816
this.log('Registering job %s on orchestrator', current);
1917

src/validation/unique/constraint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
ValidationArguments,
44
ValidationOptions,
55
ValidatorConstraint,
6-
ValidatorConstraintInterface,
6+
ValidatorConstraintInterface
77
} from 'class-validator';
88

99
import { Entity } from '../../entity/entity';
@@ -21,7 +21,7 @@ export class IsUniqueConstraint implements ValidatorConstraintInterface {
2121
private em: EntityManager;
2222
private message: string;
2323

24-
defaultMessage?(args?: ValidationArguments): string {
24+
defaultMessage?(): string {
2525
return this.message;
2626
}
2727

test/objectid/objectid.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ObjectId } from 'bson';
21
import { plainToClass } from 'class-transformer';
2+
import { ObjectId } from 'mongodb';
33

44
import { EntityTest } from '../entity/entity';
55
import { EntityRelationship } from '../relationship/entity.relationship';

0 commit comments

Comments
 (0)