nest-knexjs 0.0.26 → 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
|
package/dist/knex-core.module.js
CHANGED
|
@@ -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)(
|
|
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)(
|
|
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.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "Knexjs module for Nest framework (node.js) 😻",
|
|
5
5
|
"author": "Tony133",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,36 +19,36 @@
|
|
|
19
19
|
"prepare": "husky"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@commitlint/cli": "19.
|
|
23
|
-
"@commitlint/config-angular": "19.
|
|
24
|
-
"@eslint/eslintrc": "3.
|
|
25
|
-
"@eslint/js": "9.
|
|
26
|
-
"@nestjs/common": "11.
|
|
27
|
-
"@nestjs/core": "11.
|
|
28
|
-
"@nestjs/platform-fastify": "11.
|
|
29
|
-
"@nestjs/testing": "11.
|
|
22
|
+
"@commitlint/cli": "19.8.1",
|
|
23
|
+
"@commitlint/config-angular": "19.8.1",
|
|
24
|
+
"@eslint/eslintrc": "3.3.1",
|
|
25
|
+
"@eslint/js": "9.28.0",
|
|
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.
|
|
32
|
-
"@types/supertest": "6.0.
|
|
33
|
-
"eslint": "9.
|
|
34
|
-
"eslint-config-prettier": "10.
|
|
31
|
+
"@types/node": "22.15.31",
|
|
32
|
+
"@types/supertest": "6.0.3",
|
|
33
|
+
"eslint": "9.28.0",
|
|
34
|
+
"eslint-config-prettier": "10.1.5",
|
|
35
35
|
"eslint-plugin-import": "2.31.0",
|
|
36
|
-
"eslint-plugin-prettier": "5.
|
|
37
|
-
"globals": "
|
|
36
|
+
"eslint-plugin-prettier": "5.4.1",
|
|
37
|
+
"globals": "16.2.0",
|
|
38
38
|
"husky": "9.1.7",
|
|
39
39
|
"jest": "29.7.0",
|
|
40
40
|
"knex": "3.1.0",
|
|
41
41
|
"mysql": "2.18.1",
|
|
42
|
-
"prettier": "3.
|
|
42
|
+
"prettier": "3.5.3",
|
|
43
43
|
"reflect-metadata": "0.2.2",
|
|
44
|
-
"release-it": "
|
|
45
|
-
"rxjs": "7.8.
|
|
46
|
-
"supertest": "7.
|
|
47
|
-
"ts-jest": "29.
|
|
44
|
+
"release-it": "19.0.3",
|
|
45
|
+
"rxjs": "7.8.2",
|
|
46
|
+
"supertest": "7.1.1",
|
|
47
|
+
"ts-jest": "29.3.4",
|
|
48
48
|
"ts-node": "10.9.2",
|
|
49
49
|
"tsconfig-paths": "4.2.0",
|
|
50
|
-
"typescript": "5.
|
|
51
|
-
"typescript-eslint": "8.
|
|
50
|
+
"typescript": "5.8.3",
|
|
51
|
+
"typescript-eslint": "8.34.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@nestjs/common": "^9.0.0 || ^10.0.0 || ^11.0.0",
|
|
@@ -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 {}
|