nest-knexjs 0.0.8 → 0.0.11
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/codeql-analysis.yml +4 -4
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/README.md +3 -4
- package/dist/common/index.js +5 -1
- package/dist/common/knex.utils.d.ts +1 -1
- package/dist/common/knex.utils.js +3 -0
- package/dist/exceptions/index.js +5 -1
- package/dist/index.js +5 -1
- package/dist/interfaces/index.js +5 -1
- package/package.json +30 -37
- package/tests/app-knex/app/app.module.ts +2 -1
- package/tests/app-multi-database/app/app.module.ts +1 -1
- package/tests/app-multi-database/app/users/users.controller.ts +2 -2
- package/tests/jest-e2e.json +1 -2
- package/tsconfig.build.json +1 -2
- package/dist/entities-metadata.storage.d.ts +0 -8
- package/dist/entities-metadata.storage.js +0 -31
|
@@ -15,17 +15,17 @@ jobs:
|
|
|
15
15
|
|
|
16
16
|
steps:
|
|
17
17
|
- name: Checkout repository
|
|
18
|
-
uses: actions/checkout@
|
|
18
|
+
uses: actions/checkout@v3
|
|
19
19
|
with:
|
|
20
20
|
fetch-depth: 0
|
|
21
21
|
|
|
22
22
|
- name: Initialize CodeQL
|
|
23
|
-
uses: github/codeql-action/init@
|
|
23
|
+
uses: github/codeql-action/init@v2
|
|
24
24
|
with:
|
|
25
25
|
languages: javascript
|
|
26
26
|
|
|
27
27
|
- name: Autobuild
|
|
28
|
-
uses: github/codeql-action/autobuild@
|
|
28
|
+
uses: github/codeql-action/autobuild@v2
|
|
29
29
|
|
|
30
30
|
- name: Perform CodeQL Analysis
|
|
31
|
-
uses: github/codeql-action/analyze@
|
|
31
|
+
uses: github/codeql-action/analyze@v2
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/
|
|
2
|
+
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
|
@@ -51,7 +51,7 @@ or
|
|
|
51
51
|
- [Usage](#usage)
|
|
52
52
|
- [KnexModule](#knexmodule)
|
|
53
53
|
- [ExampleOfUse](#example-of-use)
|
|
54
|
-
- [
|
|
54
|
+
- [MultiConnectionsDatabase](#multi-connections-database)
|
|
55
55
|
- [CreateMigrations](#create-migrations)
|
|
56
56
|
- [RunMigrations](#run-migrations)
|
|
57
57
|
- [CreateSeeds](#create-seeds)
|
|
@@ -134,7 +134,7 @@ export class UsersController {
|
|
|
134
134
|
constructor(private readonly usersService: UsersService) {}
|
|
135
135
|
|
|
136
136
|
@Get()
|
|
137
|
-
async
|
|
137
|
+
async getAllUsers() {
|
|
138
138
|
return await this.usersService.findAll();
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -224,7 +224,6 @@ export class PostService {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
async findAll() {
|
|
227
|
-
console.log(this.knexConnection);
|
|
228
227
|
const posts = await this.knexConnection.table('posts');
|
|
229
228
|
return { posts };
|
|
230
229
|
}
|
package/dist/common/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -7,7 +7,7 @@ import { Observable } from 'rxjs';
|
|
|
7
7
|
* @returns {string} The Entity injection token
|
|
8
8
|
*/
|
|
9
9
|
export declare function getModelToken(model: Function, connection?: KnexModuleOptions | string): string;
|
|
10
|
-
export declare function getConnectionToken(connection?: KnexModuleOptions |
|
|
10
|
+
export declare function getConnectionToken(connection?: KnexModuleOptions | string): string | Function;
|
|
11
11
|
/**
|
|
12
12
|
* This function returns a Connection prefix based on the connection name
|
|
13
13
|
* @param {KnexModuleOptions | string} [connection='default'] This optional parameter is either
|
|
@@ -22,6 +22,9 @@ function getModelToken(model, connection = knex_constants_1.DEFAULT_CONNECTION_N
|
|
|
22
22
|
}
|
|
23
23
|
exports.getModelToken = getModelToken;
|
|
24
24
|
function getConnectionToken(connection = knex_constants_1.DEFAULT_CONNECTION_NAME) {
|
|
25
|
+
if (typeof connection === 'string') {
|
|
26
|
+
return connection;
|
|
27
|
+
}
|
|
25
28
|
return `${connection.name || knex_constants_1.DEFAULT_CONNECTION_NAME}`;
|
|
26
29
|
}
|
|
27
30
|
exports.getConnectionToken = getConnectionToken;
|
package/dist/exceptions/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nest-knexjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Knexjs module for Nest framework (node.js) 😻",
|
|
5
5
|
"author": "Tony133",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,55 +15,48 @@
|
|
|
15
15
|
"test:e2e": "jest --config ./tests/jest-e2e.json --runInBand",
|
|
16
16
|
"test:e2e:dev": "jest --config ./tests/jest-e2e.json --runInBand --watch",
|
|
17
17
|
"prerelease": "npm run build",
|
|
18
|
-
"release": "release-it"
|
|
18
|
+
"release": "release-it",
|
|
19
|
+
"prepare": "husky install"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
|
-
"@commitlint/cli": "
|
|
22
|
-
"@commitlint/config-angular": "
|
|
23
|
-
"@nestjs/common": "8.
|
|
24
|
-
"@nestjs/core": "8.
|
|
25
|
-
"@nestjs/platform-express": "8.
|
|
26
|
-
"@nestjs/testing": "8.
|
|
22
|
+
"@commitlint/cli": "17.0.3",
|
|
23
|
+
"@commitlint/config-angular": "17.0.3",
|
|
24
|
+
"@nestjs/common": "8.4.7",
|
|
25
|
+
"@nestjs/core": "8.4.7",
|
|
26
|
+
"@nestjs/platform-express": "8.4.7",
|
|
27
|
+
"@nestjs/testing": "8.4.7",
|
|
27
28
|
"@types/express": "4.17.13",
|
|
28
|
-
"@types/node": "16.11.
|
|
29
|
-
"@types/jest": "
|
|
30
|
-
"@types/supertest": "2.0.
|
|
31
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
32
|
-
"@typescript-eslint/parser": "5.
|
|
33
|
-
"eslint": "8.
|
|
34
|
-
"eslint-config-prettier": "8.
|
|
35
|
-
"eslint-plugin-import": "2.
|
|
36
|
-
"knex": "1.0
|
|
29
|
+
"@types/node": "16.11.43",
|
|
30
|
+
"@types/jest": "28.1.4",
|
|
31
|
+
"@types/supertest": "2.0.12",
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "5.30.5",
|
|
33
|
+
"@typescript-eslint/parser": "5.30.5",
|
|
34
|
+
"eslint": "8.19.0",
|
|
35
|
+
"eslint-config-prettier": "8.5.0",
|
|
36
|
+
"eslint-plugin-import": "2.26.0",
|
|
37
|
+
"knex": "2.1.0",
|
|
37
38
|
"mysql": "2.18.1",
|
|
38
|
-
"husky": "
|
|
39
|
-
"prettier": "2.
|
|
40
|
-
"jest": "
|
|
39
|
+
"husky": "8.0.1",
|
|
40
|
+
"prettier": "2.7.1",
|
|
41
|
+
"jest": "28.1.2",
|
|
41
42
|
"reflect-metadata": "0.1.13",
|
|
42
|
-
"release-it": "
|
|
43
|
-
"supertest": "6.2.
|
|
44
|
-
"ts-node": "10.
|
|
45
|
-
"rxjs": "7.5.
|
|
46
|
-
"ts-jest": "
|
|
47
|
-
"tsconfig-paths": "
|
|
48
|
-
"typescript": "4.
|
|
43
|
+
"release-it": "15.1.1",
|
|
44
|
+
"supertest": "6.2.4",
|
|
45
|
+
"ts-node": "10.8.2",
|
|
46
|
+
"rxjs": "7.5.5",
|
|
47
|
+
"ts-jest": "28.0.5",
|
|
48
|
+
"tsconfig-paths": "4.0.0",
|
|
49
|
+
"typescript": "4.7.4"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"@nestjs/common": "^7.0.0 || ^8.0.0",
|
|
52
53
|
"@nestjs/core": "^7.0.0 || ^8.0.0",
|
|
53
54
|
"reflect-metadata": "^0.1.13",
|
|
54
55
|
"rxjs": "^6.6.3 || ^7.2.0",
|
|
55
|
-
"knex": "^0.21.17 || ^0.95.0 || ^1.0.0"
|
|
56
|
+
"knex": "^0.21.17 || ^0.95.0 || ^1.0.0 || ^2.0.0"
|
|
56
57
|
},
|
|
57
58
|
"lint-staged": {
|
|
58
|
-
"
|
|
59
|
-
"prettier --write"
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
"husky": {
|
|
63
|
-
"hooks": {
|
|
64
|
-
"commit-msg": "commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS",
|
|
65
|
-
"pre-commit": "lint-staged"
|
|
66
|
-
}
|
|
59
|
+
"**/*.{ts,json}": []
|
|
67
60
|
},
|
|
68
61
|
"repository": {
|
|
69
62
|
"type": "git",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Module } from '@nestjs/common';
|
|
2
|
-
import { KnexModule } from '
|
|
2
|
+
import { KnexModule } from '../../../lib';
|
|
3
3
|
import { UsersModule } from './users/users.module';
|
|
4
4
|
|
|
5
5
|
@Module({
|
|
@@ -11,6 +11,7 @@ import { UsersModule } from './users/users.module';
|
|
|
11
11
|
useNullAsDefault: true,
|
|
12
12
|
connection: {
|
|
13
13
|
host: '127.0.0.1',
|
|
14
|
+
port: 3308,
|
|
14
15
|
user: 'root',
|
|
15
16
|
password: 'root',
|
|
16
17
|
database: 'test',
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
Get,
|
|
4
4
|
Post,
|
|
5
5
|
Body,
|
|
6
|
-
Put,
|
|
7
6
|
Param,
|
|
8
7
|
Delete,
|
|
8
|
+
Patch,
|
|
9
9
|
} from '@nestjs/common';
|
|
10
10
|
import { UsersService } from './users.service';
|
|
11
11
|
import { CreateUserDto } from './dto/create-user.dto';
|
|
@@ -30,7 +30,7 @@ export class UsersController {
|
|
|
30
30
|
return this.usersService.findOne(+id);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
@
|
|
33
|
+
@Patch(':id')
|
|
34
34
|
update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) {
|
|
35
35
|
return this.usersService.update(+id, updateUserDto);
|
|
36
36
|
}
|
package/tests/jest-e2e.json
CHANGED
package/tsconfig.build.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { KnexModuleOptions } from './interfaces';
|
|
2
|
-
declare type ConnectionToken = KnexModuleOptions | string;
|
|
3
|
-
export declare class EntitiesMetadataStorage {
|
|
4
|
-
private static readonly storage;
|
|
5
|
-
static addEntitiesByConnection(connection: ConnectionToken, entities: Function[]): void;
|
|
6
|
-
static getEntitiesByConnection(connection: ConnectionToken): Function[];
|
|
7
|
-
}
|
|
8
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntitiesMetadataStorage = void 0;
|
|
4
|
-
class EntitiesMetadataStorage {
|
|
5
|
-
static addEntitiesByConnection(connection, entities) {
|
|
6
|
-
const connectionToken = typeof connection === 'string' ? connection : connection.name;
|
|
7
|
-
if (!connectionToken) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
let collection = this.storage.get(connectionToken);
|
|
11
|
-
if (!collection) {
|
|
12
|
-
collection = [];
|
|
13
|
-
this.storage.set(connectionToken, collection);
|
|
14
|
-
}
|
|
15
|
-
entities.forEach(entity => {
|
|
16
|
-
if (collection.includes(entity)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
collection.push(entity);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
static getEntitiesByConnection(connection) {
|
|
23
|
-
const connectionToken = typeof connection === 'string' ? connection : connection.name;
|
|
24
|
-
if (!connectionToken) {
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
return this.storage.get(connectionToken) || [];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.EntitiesMetadataStorage = EntitiesMetadataStorage;
|
|
31
|
-
EntitiesMetadataStorage.storage = new Map();
|