nest-knexjs 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- node-version: [20.x, 22.x]
16
+ node-version: [20.x, 22.x, 24.x]
17
17
 
18
18
  steps:
19
19
  - uses: actions/checkout@v4
@@ -30,7 +30,7 @@ jobs:
30
30
 
31
31
  strategy:
32
32
  matrix:
33
- node-version: [20.x, 22.x]
33
+ node-version: [20.x, 22.x, 24.x]
34
34
  needs: [build]
35
35
 
36
36
  steps:
@@ -55,4 +55,4 @@ jobs:
55
55
  - name: Run tests e2e
56
56
  run: npm run test:e2e
57
57
  - name: Stop Docker-Compose
58
- run: cd tests && docker-compose down
58
+ run: cd tests && docker-compose down
@@ -26,12 +26,15 @@ let KnexCoreModule = KnexCoreModule_1 = class KnexCoreModule {
26
26
  this.moduleRef = moduleRef;
27
27
  }
28
28
  static forRoot(options, connection) {
29
+ if (connection) {
30
+ options.name = connection;
31
+ }
29
32
  const knexModuleOptions = {
30
33
  provide: knex_constants_1.KNEX_MODULE_OPTIONS,
31
34
  useValue: options,
32
35
  };
33
36
  const connectionProvider = {
34
- provide: (0, knex_utils_1.getConnectionToken)(connection),
37
+ provide: (0, knex_utils_1.getConnectionToken)(options.name),
35
38
  useFactory: async () => await this.createConnectionFactory(options),
36
39
  };
37
40
  return {
@@ -41,8 +44,11 @@ let KnexCoreModule = KnexCoreModule_1 = class KnexCoreModule {
41
44
  };
42
45
  }
43
46
  static forRootAsync(options, connection) {
47
+ if (connection) {
48
+ options.name = connection;
49
+ }
44
50
  const connectionProvider = {
45
- provide: (0, knex_utils_1.getConnectionToken)(connection),
51
+ provide: (0, knex_utils_1.getConnectionToken)(options.name),
46
52
  useFactory: async (options) => {
47
53
  return await this.createConnectionFactory(options);
48
54
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nest-knexjs",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "Knexjs module for Nest framework (node.js) 😻",
5
5
  "author": "Tony133",
6
6
  "license": "MIT",
@@ -23,12 +23,12 @@
23
23
  "@commitlint/config-angular": "19.8.1",
24
24
  "@eslint/eslintrc": "3.3.1",
25
25
  "@eslint/js": "9.28.0",
26
- "@nestjs/common": "11.1.2",
27
- "@nestjs/core": "11.1.2",
28
- "@nestjs/platform-fastify": "11.1.2",
29
- "@nestjs/testing": "11.1.2",
26
+ "@nestjs/common": "11.1.3",
27
+ "@nestjs/core": "11.1.3",
28
+ "@nestjs/platform-fastify": "11.1.3",
29
+ "@nestjs/testing": "11.1.3",
30
30
  "@types/jest": "29.5.14",
31
- "@types/node": "22.15.29",
31
+ "@types/node": "22.15.31",
32
32
  "@types/supertest": "6.0.3",
33
33
  "eslint": "9.28.0",
34
34
  "eslint-config-prettier": "10.1.5",
@@ -48,7 +48,7 @@
48
48
  "ts-node": "10.9.2",
49
49
  "tsconfig-paths": "4.2.0",
50
50
  "typescript": "5.8.3",
51
- "typescript-eslint": "8.33.0"
51
+ "typescript-eslint": "8.34.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@nestjs/common": "^9.0.0 || ^10.0.0 || ^11.0.0",
@@ -62,6 +62,6 @@
62
62
  },
63
63
  "repository": {
64
64
  "type": "git",
65
- "url": "git+https://github.com/tony133/nestjs-knexjs.git"
65
+ "url": "https://github.com/tony133/nestjs-knexjs"
66
66
  }
67
67
  }
@@ -0,0 +1,28 @@
1
+ import { Test } from '@nestjs/testing';
2
+ import {
3
+ FastifyAdapter,
4
+ NestFastifyApplication,
5
+ } from '@nestjs/platform-fastify';
6
+ import { AppMultiDatabaseModule } from '../src/app-multi-database.module';
7
+
8
+ describe('Knex', () => {
9
+ let app: NestFastifyApplication;
10
+
11
+ beforeAll(async () => {
12
+ const moduleFixture = await Test.createTestingModule({
13
+ imports: [AppMultiDatabaseModule],
14
+ }).compile();
15
+
16
+ app = moduleFixture.createNestApplication<NestFastifyApplication>(
17
+ new FastifyAdapter(),
18
+ );
19
+ });
20
+
21
+ it(`should start`, async () => {
22
+ await expect(app.init()).resolves.not.toThrow();
23
+ });
24
+
25
+ it(`should stop`, async () => {
26
+ await expect(app.close()).resolves.not.toThrow();
27
+ });
28
+ });
@@ -0,0 +1,44 @@
1
+ import { Module } from '@nestjs/common';
2
+ import { KnexModule } from '../../lib';
3
+
4
+ @Module({
5
+ imports: [
6
+ KnexModule.forRoot({
7
+ config: {
8
+ client: 'mysql',
9
+ version: '5.7',
10
+ useNullAsDefault: true,
11
+ connection: {
12
+ host: '127.0.0.1',
13
+ user: 'root',
14
+ port: 3306,
15
+ password: 'root',
16
+ database: 'test',
17
+ },
18
+ pool: {
19
+ min: 2,
20
+ max: 10,
21
+ },
22
+ },
23
+ }, "dbTestConnection1"),
24
+ KnexModule.forRoot({
25
+ config: {
26
+ client: 'mysql',
27
+ version: '5.7',
28
+ useNullAsDefault: true,
29
+ connection: {
30
+ host: '127.0.0.1',
31
+ user: 'root',
32
+ port: 3306,
33
+ password: 'root',
34
+ database: 'test',
35
+ },
36
+ pool: {
37
+ min: 2,
38
+ max: 10,
39
+ },
40
+ },
41
+ }, "dbTestConnection2"),
42
+ ],
43
+ })
44
+ export class AppMultiDatabaseModule {}