nest-knexjs 0.0.23 → 0.0.25
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.
- package/.github/workflows/nodejs-environment.yml +5 -1
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/dist/common/knex.utils.js +6 -6
- package/package.json +17 -17
- package/tests/e2e/knex-app-user.spec.ts +10 -3
- package/tests/e2e/knex-async-class.spec.ts +11 -4
- package/tests/e2e/knex-async-existing.spec.ts +11 -4
- package/tests/e2e/knex-async.spec.ts +11 -4
- package/tests/e2e/knex.spec.ts +10 -4
|
@@ -39,6 +39,10 @@ jobs:
|
|
|
39
39
|
uses: actions/setup-node@v4
|
|
40
40
|
with:
|
|
41
41
|
node-version: ${{ matrix.node-version }}
|
|
42
|
+
- name: Install Docker Compose
|
|
43
|
+
run: |
|
|
44
|
+
sudo apt-get update
|
|
45
|
+
sudo apt-get install -y docker-compose
|
|
42
46
|
- name: Start Docker-Compose
|
|
43
47
|
run: cd tests && docker-compose up -d
|
|
44
48
|
- name: Install npm
|
|
@@ -51,4 +55,4 @@ jobs:
|
|
|
51
55
|
- name: Run tests e2e
|
|
52
56
|
run: npm run test:e2e
|
|
53
57
|
- name: Stop Docker-Compose
|
|
54
|
-
run: cd tests && docker-compose down
|
|
58
|
+
run: cd tests && docker-compose down
|
package/.husky/commit-msg
CHANGED
package/.husky/pre-commit
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateString =
|
|
3
|
+
exports.generateString = void 0;
|
|
4
|
+
exports.getModelToken = getModelToken;
|
|
5
|
+
exports.getConnectionToken = getConnectionToken;
|
|
6
|
+
exports.getConnectionPrefix = getConnectionPrefix;
|
|
7
|
+
exports.handleRetry = handleRetry;
|
|
8
|
+
exports.getConnectionName = getConnectionName;
|
|
4
9
|
const knex_constants_1 = require("../knex.constants");
|
|
5
10
|
const operators_1 = require("rxjs/operators");
|
|
6
11
|
const node_crypto_1 = require("node:crypto");
|
|
@@ -20,14 +25,12 @@ function getModelToken(model, connection = knex_constants_1.DEFAULT_CONNECTION_N
|
|
|
20
25
|
const connectionPrefix = getConnectionPrefix(connection);
|
|
21
26
|
return `${connectionPrefix}${model.name}`;
|
|
22
27
|
}
|
|
23
|
-
exports.getModelToken = getModelToken;
|
|
24
28
|
function getConnectionToken(connection = knex_constants_1.DEFAULT_CONNECTION_NAME) {
|
|
25
29
|
if (typeof connection === 'string') {
|
|
26
30
|
return connection;
|
|
27
31
|
}
|
|
28
32
|
return `${connection.name || knex_constants_1.DEFAULT_CONNECTION_NAME}`;
|
|
29
33
|
}
|
|
30
|
-
exports.getConnectionToken = getConnectionToken;
|
|
31
34
|
/**
|
|
32
35
|
* This function returns a Connection prefix based on the connection name
|
|
33
36
|
* @param {KnexModuleOptions | string} [connection='default'] This optional parameter is either
|
|
@@ -46,7 +49,6 @@ function getConnectionPrefix(connection = knex_constants_1.DEFAULT_CONNECTION_NA
|
|
|
46
49
|
}
|
|
47
50
|
return connection.name + '_';
|
|
48
51
|
}
|
|
49
|
-
exports.getConnectionPrefix = getConnectionPrefix;
|
|
50
52
|
function handleRetry(retryAttempts = 9, retryDelay = 3000) {
|
|
51
53
|
return (source) => source.pipe((0, operators_1.retryWhen)((e) => e.pipe((0, operators_1.scan)((errorCount, error) => {
|
|
52
54
|
logger.error(`Unable to connect to the database. Retrying (${errorCount + 1})...`, error.stack);
|
|
@@ -56,10 +58,8 @@ function handleRetry(retryAttempts = 9, retryDelay = 3000) {
|
|
|
56
58
|
return errorCount + 1;
|
|
57
59
|
}, 0), (0, operators_1.delay)(retryDelay))));
|
|
58
60
|
}
|
|
59
|
-
exports.handleRetry = handleRetry;
|
|
60
61
|
function getConnectionName(options) {
|
|
61
62
|
return options && options.name ? options.name : knex_constants_1.DEFAULT_CONNECTION_NAME;
|
|
62
63
|
}
|
|
63
|
-
exports.getConnectionName = getConnectionName;
|
|
64
64
|
const generateString = () => (0, node_crypto_1.randomUUID)();
|
|
65
65
|
exports.generateString = generateString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nest-knexjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "Knexjs module for Nest framework (node.js) 😻",
|
|
5
5
|
"author": "Tony133",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,33 +19,33 @@
|
|
|
19
19
|
"prepare": "husky"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@commitlint/cli": "19.
|
|
23
|
-
"@commitlint/config-angular": "19.
|
|
24
|
-
"@nestjs/common": "10.
|
|
25
|
-
"@nestjs/core": "10.
|
|
26
|
-
"@nestjs/platform-fastify": "
|
|
27
|
-
"@nestjs/testing": "10.
|
|
28
|
-
"@types/jest": "29.5.
|
|
29
|
-
"@types/node": "
|
|
22
|
+
"@commitlint/cli": "19.6.0",
|
|
23
|
+
"@commitlint/config-angular": "19.6.0",
|
|
24
|
+
"@nestjs/common": "10.4.12",
|
|
25
|
+
"@nestjs/core": "10.4.12",
|
|
26
|
+
"@nestjs/platform-fastify": "10.4.12",
|
|
27
|
+
"@nestjs/testing": "10.4.12",
|
|
28
|
+
"@types/jest": "29.5.14",
|
|
29
|
+
"@types/node": "22.10.1",
|
|
30
30
|
"@types/supertest": "6.0.2",
|
|
31
|
-
"@typescript-eslint/eslint-plugin": "
|
|
32
|
-
"@typescript-eslint/parser": "
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "8.16.0",
|
|
32
|
+
"@typescript-eslint/parser": "8.16.0",
|
|
33
33
|
"eslint": "8.57.0",
|
|
34
34
|
"eslint-config-prettier": "9.1.0",
|
|
35
|
-
"eslint-plugin-import": "2.
|
|
36
|
-
"husky": "9.
|
|
35
|
+
"eslint-plugin-import": "2.31.0",
|
|
36
|
+
"husky": "9.1.7",
|
|
37
37
|
"jest": "29.7.0",
|
|
38
38
|
"knex": "3.1.0",
|
|
39
39
|
"mysql": "2.18.1",
|
|
40
|
-
"prettier": "3.
|
|
40
|
+
"prettier": "3.4.1",
|
|
41
41
|
"reflect-metadata": "0.2.2",
|
|
42
|
-
"release-it": "17.
|
|
42
|
+
"release-it": "17.10.0",
|
|
43
43
|
"rxjs": "7.8.1",
|
|
44
44
|
"supertest": "7.0.0",
|
|
45
|
-
"ts-jest": "29.
|
|
45
|
+
"ts-jest": "29.2.5",
|
|
46
46
|
"ts-node": "10.9.2",
|
|
47
47
|
"tsconfig-paths": "4.2.0",
|
|
48
|
-
"typescript": "5.
|
|
48
|
+
"typescript": "5.7.2"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpStatus } from '@nestjs/common';
|
|
2
2
|
import { TestingModule, Test } from '@nestjs/testing';
|
|
3
3
|
import { UsersModule } from '../src/apps/app-knex/app/users/users.module';
|
|
4
4
|
import { KnexModule } from '../../lib';
|
|
5
5
|
import * as request from 'supertest';
|
|
6
|
+
import {
|
|
7
|
+
FastifyAdapter,
|
|
8
|
+
NestFastifyApplication,
|
|
9
|
+
} from '@nestjs/platform-fastify';
|
|
6
10
|
|
|
7
11
|
describe('[Feature] Users - /users', () => {
|
|
8
|
-
let app:
|
|
12
|
+
let app: NestFastifyApplication;
|
|
9
13
|
|
|
10
14
|
beforeAll(async () => {
|
|
11
15
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
@@ -28,8 +32,11 @@ describe('[Feature] Users - /users', () => {
|
|
|
28
32
|
],
|
|
29
33
|
}).compile();
|
|
30
34
|
|
|
31
|
-
app = moduleFixture.createNestApplication(
|
|
35
|
+
app = moduleFixture.createNestApplication<NestFastifyApplication>(
|
|
36
|
+
new FastifyAdapter(),
|
|
37
|
+
);
|
|
32
38
|
await app.init();
|
|
39
|
+
await app.getHttpAdapter().getInstance().ready();
|
|
33
40
|
});
|
|
34
41
|
|
|
35
42
|
it('should create a new user [POST /users]', () => {
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import { HttpStatus
|
|
1
|
+
import { HttpStatus } from '@nestjs/common';
|
|
2
2
|
import { Test } from '@nestjs/testing';
|
|
3
3
|
import { AsyncOptionsClassModule } from '../src/async-class-options.module';
|
|
4
4
|
import * as request from 'supertest';
|
|
5
|
+
import {
|
|
6
|
+
FastifyAdapter,
|
|
7
|
+
NestFastifyApplication,
|
|
8
|
+
} from '@nestjs/platform-fastify';
|
|
5
9
|
|
|
6
10
|
describe('Knex (async configuration)', () => {
|
|
7
|
-
let app:
|
|
11
|
+
let app: NestFastifyApplication;
|
|
8
12
|
|
|
9
13
|
beforeAll(async () => {
|
|
10
|
-
const
|
|
14
|
+
const moduleFixture = await Test.createTestingModule({
|
|
11
15
|
imports: [AsyncOptionsClassModule],
|
|
12
16
|
}).compile();
|
|
13
17
|
|
|
14
|
-
app =
|
|
18
|
+
app = moduleFixture.createNestApplication<NestFastifyApplication>(
|
|
19
|
+
new FastifyAdapter(),
|
|
20
|
+
);
|
|
15
21
|
await app.init();
|
|
22
|
+
await app.getHttpAdapter().getInstance().ready();
|
|
16
23
|
});
|
|
17
24
|
|
|
18
25
|
it(`should return created entity`, () => {
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import { HttpStatus
|
|
1
|
+
import { HttpStatus } from '@nestjs/common';
|
|
2
2
|
import { Test } from '@nestjs/testing';
|
|
3
3
|
import { AsyncOptionsExistingModule } from '../src/async-existing-options.module';
|
|
4
4
|
import * as request from 'supertest';
|
|
5
|
+
import {
|
|
6
|
+
FastifyAdapter,
|
|
7
|
+
NestFastifyApplication,
|
|
8
|
+
} from '@nestjs/platform-fastify';
|
|
5
9
|
|
|
6
10
|
describe('Knex (async configuration)', () => {
|
|
7
|
-
let app:
|
|
11
|
+
let app: NestFastifyApplication;
|
|
8
12
|
|
|
9
13
|
beforeAll(async () => {
|
|
10
|
-
const
|
|
14
|
+
const moduleFixture = await Test.createTestingModule({
|
|
11
15
|
imports: [AsyncOptionsExistingModule],
|
|
12
16
|
}).compile();
|
|
13
17
|
|
|
14
|
-
app =
|
|
18
|
+
app = moduleFixture.createNestApplication<NestFastifyApplication>(
|
|
19
|
+
new FastifyAdapter(),
|
|
20
|
+
);
|
|
15
21
|
await app.init();
|
|
22
|
+
await app.getHttpAdapter().getInstance().ready();
|
|
16
23
|
});
|
|
17
24
|
|
|
18
25
|
it(`should return created entity`, () => {
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import { HttpStatus
|
|
1
|
+
import { HttpStatus } from '@nestjs/common';
|
|
2
2
|
import { Test } from '@nestjs/testing';
|
|
3
3
|
import { AsyncApplicationModule } from '../src/app-async.module';
|
|
4
4
|
import * as request from 'supertest';
|
|
5
|
+
import {
|
|
6
|
+
FastifyAdapter,
|
|
7
|
+
NestFastifyApplication,
|
|
8
|
+
} from '@nestjs/platform-fastify';
|
|
5
9
|
|
|
6
10
|
describe('Knex (async configuration)', () => {
|
|
7
|
-
let app:
|
|
11
|
+
let app: NestFastifyApplication;
|
|
8
12
|
|
|
9
13
|
beforeAll(async () => {
|
|
10
|
-
const
|
|
14
|
+
const moduleFixture = await Test.createTestingModule({
|
|
11
15
|
imports: [AsyncApplicationModule],
|
|
12
16
|
}).compile();
|
|
13
17
|
|
|
14
|
-
app =
|
|
18
|
+
app = moduleFixture.createNestApplication<NestFastifyApplication>(
|
|
19
|
+
new FastifyAdapter(),
|
|
20
|
+
);
|
|
15
21
|
await app.init();
|
|
22
|
+
await app.getHttpAdapter().getInstance().ready();
|
|
16
23
|
});
|
|
17
24
|
|
|
18
25
|
it(`should return created entity`, () => {
|
package/tests/e2e/knex.spec.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { INestApplication } from '@nestjs/common';
|
|
2
1
|
import { Test } from '@nestjs/testing';
|
|
3
2
|
import { ApplicationModule } from '../src/app.module';
|
|
4
3
|
import * as request from 'supertest';
|
|
4
|
+
import {
|
|
5
|
+
FastifyAdapter,
|
|
6
|
+
NestFastifyApplication,
|
|
7
|
+
} from '@nestjs/platform-fastify';
|
|
5
8
|
|
|
6
9
|
describe('Knex', () => {
|
|
7
|
-
let app:
|
|
10
|
+
let app: NestFastifyApplication;
|
|
8
11
|
|
|
9
12
|
beforeAll(async () => {
|
|
10
|
-
const
|
|
13
|
+
const moduleFixture = await Test.createTestingModule({
|
|
11
14
|
imports: [ApplicationModule],
|
|
12
15
|
}).compile();
|
|
13
16
|
|
|
14
|
-
app =
|
|
17
|
+
app = moduleFixture.createNestApplication<NestFastifyApplication>(
|
|
18
|
+
new FastifyAdapter(),
|
|
19
|
+
);
|
|
15
20
|
await app.init();
|
|
21
|
+
await app.getHttpAdapter().getInstance().ready();
|
|
16
22
|
});
|
|
17
23
|
|
|
18
24
|
it(`should return created entity`, () => {
|