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.
@@ -15,17 +15,17 @@ jobs:
15
15
 
16
16
  steps:
17
17
  - name: Checkout repository
18
- uses: actions/checkout@v2
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@v1
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@v1
28
+ uses: github/codeql-action/autobuild@v2
29
29
 
30
30
  - name: Perform CodeQL Analysis
31
- uses: github/codeql-action/analyze@v1
31
+ uses: github/codeql-action/analyze@v2
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx --no-install commitlint --edit $1
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx lint-staged
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/logo_text.svg" width="320" alt="Nest Logo" /></a>
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
- - [MultiConnectionsDatabae](#multi-connections-database)
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 getHello() {
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
  }
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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 | any): string | Function;
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;
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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.8",
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": "16.1.0",
22
- "@commitlint/config-angular": "16.0.0",
23
- "@nestjs/common": "8.2.6",
24
- "@nestjs/core": "8.2.6",
25
- "@nestjs/platform-express": "8.2.6",
26
- "@nestjs/testing": "8.2.6",
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.21",
29
- "@types/jest": "27.4.0",
30
- "@types/supertest": "2.0.11",
31
- "@typescript-eslint/eslint-plugin": "5.10.1",
32
- "@typescript-eslint/parser": "5.10.1",
33
- "eslint": "8.8.0",
34
- "eslint-config-prettier": "8.3.0",
35
- "eslint-plugin-import": "2.25.4",
36
- "knex": "1.0.1",
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": "7.0.4",
39
- "prettier": "2.5.1",
40
- "jest": "27.4.7",
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": "14.12.4",
43
- "supertest": "6.2.2",
44
- "ts-node": "10.4.0",
45
- "rxjs": "7.5.2",
46
- "ts-jest": "27.1.3",
47
- "tsconfig-paths": "3.12.0",
48
- "typescript": "4.5.5"
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
- "*.ts": [
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 '../../lib';
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',
@@ -1,5 +1,5 @@
1
1
  import { Module } from '@nestjs/common';
2
- import { KnexModule } from '../../lib';
2
+ import { KnexModule } from '../../../lib';
3
3
  import { PostModule } from './post/post.module';
4
4
  import { UsersModule } from './users/users.module';
5
5
 
@@ -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
- @Put(':id')
33
+ @Patch(':id')
34
34
  update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) {
35
35
  return this.usersService.update(+id, updateUserDto);
36
36
  }
@@ -1,4 +1,3 @@
1
-
2
1
  {
3
2
  "moduleFileExtensions": ["js", "json", "ts"],
4
3
  "rootDir": "..",
@@ -7,4 +6,4 @@
7
6
  "transform": {
8
7
  "^.+\\.(t|j)s$": "ts-jest"
9
8
  }
10
- }
9
+ }
@@ -1,5 +1,4 @@
1
1
  {
2
2
  "extends": "./tsconfig.json",
3
3
  "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4
- }
5
-
4
+ }
@@ -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();