nestjs-typeorm3-kit 0.1.1 → 0.1.3

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/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # nestjs-typeorm3-kit
2
+
3
+ [![npm](https://img.shields.io/npm/v/nestjs-typeorm3-kit)](https://www.npmjs.com/package/nestjs-typeorm3-kit) ![MIT License](https://img.shields.io/npm/l/nestjs-typeorm3-kit.svg)
4
+
5
+ ## [Node.js] nestjs-typeorm3-kit
6
+
7
+ ### Installation
8
+
9
+ #### NPM
10
+
11
+ ```bash
12
+ npm install nestjs-typeorm3-kit typeorm-transactional
13
+ ```
14
+
15
+ #### Yarn
16
+
17
+ ```bash
18
+ yarn add nestjs-typeorm3-kit typeorm-transactional
19
+ ```
20
+
21
+ #### pnpm
22
+
23
+ ```bash
24
+ pnpm add nestjs-typeorm3-kit typeorm-transactional
25
+ ```
26
+
27
+ #### bun
28
+
29
+ ```bash
30
+ bun add nestjs-typeorm3-kit typeorm-transactional
31
+ ```
32
+
33
+ ### Config after install
34
+
35
+ #### Use @DefEntityRepository
36
+
37
+ For using `@DefEntityRepository` instead of `@EntityRepository` of typeorm 0.2, you need to add the following code in `main.ts` or `app.module.ts`:
38
+
39
+ ```typescript
40
+ import { TypeOrmModule } from "@nestjs/typeorm";
41
+
42
+ TypeOrmModule.forRootAsync({
43
+ useFactory: () => ({
44
+ type: "postgres",
45
+ host: "localhost",
46
+ port: 5432,
47
+ username: "postgres",
48
+ password: "Abc12345",
49
+ database: "primary_db",
50
+ entities: [join(__dirname, "./domains/primary/**/*.entity.{ts,js}")],
51
+ synchronize: true,
52
+ autoLoadEntities: true,
53
+ retryAttempts: 2,
54
+ retryDelay: 1000,
55
+ }),
56
+ dataSourceFactory: async (options: DataSourceOptions) => {
57
+ if (!options) {
58
+ throw new Error("Invalid options passed");
59
+ }
60
+ return addTransactionalDataSource({
61
+ dataSource: new DataSource(options),
62
+ name: PRIMARY_CONNECTION,
63
+ });
64
+ },
65
+ });
66
+ ```
67
+
68
+ #### create Repository module Use @DefRepositoryModule
69
+
70
+ ```typescript
71
+ import { Module } from "@nestjs/common";
72
+ import { join } from "path";
73
+
74
+ import { PRIMARY_CONNECTION } from "~/common/constants";
75
+ import { DefRepositoryModule } from "nestjs-typeorm3-kit";
76
+ @Module({
77
+ imports: [
78
+ DefRepositoryModule.forRootAsync({
79
+ useFactory: () => ({
80
+ globPattern: join(__dirname, "./**/*.repo.{ts,js}"),
81
+ dataSource: PRIMARY_CONNECTION,
82
+ }),
83
+ }),
84
+ ],
85
+ exports: [DefRepositoryModule],
86
+ })
87
+ export class PrimaryRepoModule {}
88
+ ```
89
+
90
+ or
91
+
92
+ ```typescript
93
+ import { Module } from "@nestjs/common";
94
+ import { join } from "path";
95
+
96
+ import { PRIMARY_CONNECTION } from "~/common/constants";
97
+ import { DefRepositoryModule } from "nestjs-typeorm3-kit";
98
+ @Module({
99
+ imports: [
100
+ DefRepositoryModule.forFeature([BookRepo, PhotoRepo], PRIMARY_CONNECTION),
101
+ ],
102
+ exports: [DefRepositoryModule],
103
+ })
104
+ export class PrimaryRepoModule {}
105
+ ```
106
+
107
+ #### Example
108
+
109
+ [Example](./example)
110
+
111
+ ### Full document in wiki github
112
+
113
+ [FULL DOCUMENT](https://x302502.github.io/nestjs-typeorm3-kit/)
@@ -1,2 +1,4 @@
1
+ import { addTransactionalDataSource } from "typeorm-transactional";
1
2
  export declare function setupTransactionContext(): void;
3
+ export { addTransactionalDataSource };
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transaction/setup/index.ts"],"names":[],"mappings":"AACA,wBAAgB,uBAAuB,SAEtC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transaction/setup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,0BAA0B,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,wBAAgB,uBAAuB,SAEtC;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addTransactionalDataSource = void 0;
3
4
  exports.setupTransactionContext = setupTransactionContext;
4
5
  const typeorm_transactional_1 = require("typeorm-transactional");
6
+ Object.defineProperty(exports, "addTransactionalDataSource", { enumerable: true, get: function () { return typeorm_transactional_1.addTransactionalDataSource; } });
5
7
  function setupTransactionContext() {
6
8
  (0, typeorm_transactional_1.initializeTransactionalContext)();
7
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transaction/setup/index.ts"],"names":[],"mappings":";;AACA,0DAEC;AAHD,iEAAuE;AACvE,SAAgB,uBAAuB;IACrC,IAAA,sDAA8B,GAAE,CAAC;AACnC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transaction/setup/index.ts"],"names":[],"mappings":";;;AAIA,0DAEC;AAND,iEAG+B;AAKtB,2GANP,kDAA0B,OAMO;AAJnC,SAAgB,uBAAuB;IACrC,IAAA,sDAA8B,GAAE,CAAC;AACnC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestjs-typeorm3-kit",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "NestJS utilities for TypeORM v0.3+",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,9 @@
10
10
  "scripts": {
11
11
  "build": "rimraf dist && tsc",
12
12
  "test": "jest --config ./tests/jest.config.json --detectOpenHandles",
13
- "prepare": "yarn build"
13
+ "prepare": "yarn build",
14
+ "gen-docs": "typedoc --plugin typedoc-plugin-markdown --out docs src/**/*.ts",
15
+ "gen-docs-github": "npx typedoc --theme github-wiki src/**/*.ts"
14
16
  },
15
17
  "repository": {
16
18
  "type": "git",
@@ -36,12 +38,14 @@
36
38
  "libphonenumber-js": "^1.10.20",
37
39
  "reflect-metadata": ">=0.1.13",
38
40
  "rxjs": ">=7.2.0",
39
- "typeorm": ">=0.3.0"
41
+ "typeorm": ">=0.3.0",
42
+ "typeorm-transactional": ">=0.5.0"
40
43
  },
41
44
  "devDependencies": {
42
45
  "@nestjs/common": "^11.1.3",
43
46
  "@nestjs/core": "^11.1.3",
44
47
  "@nestjs/swagger": "^11.2.0",
48
+ "@nestjs/testing": "^11.1.3",
45
49
  "@nestjs/typeorm": "^11.0.0",
46
50
  "@types/jest": "^30.0.0",
47
51
  "class-transformer": "^0.5.1",
@@ -53,7 +57,11 @@
53
57
  "prettier": "^3.6.2",
54
58
  "reflect-metadata": "^0.2.2",
55
59
  "rimraf": "^6.0.1",
60
+ "rxjs": "^7.8.2",
56
61
  "ts-jest": "^29.4.0",
62
+ "typedoc": "^0.28.6",
63
+ "typedoc-github-wiki-theme": "^2.1.0",
64
+ "typedoc-plugin-markdown": "^4.7.0",
57
65
  "typeorm": "^0.3.25",
58
66
  "typeorm-transactional": "^0.5.0",
59
67
  "typescript": "^5.8.3"