Skip to content

Commit bb8a415

Browse files
committed
refactor(json-api-nestjs): change npm package should be in next version
1 parent cbd1e71 commit bb8a415

File tree

3 files changed

+71
-8
lines changed

3 files changed

+71
-8
lines changed

libs/json-api/json-api-nestjs/README.md

+25-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# json-api-nestjs
1010

11-
This plugin works upon TypeOrm library, which is used as the main database abstraction layer tool. The module
11+
This plugin works upon TypeOrm or MicroOrm library, which is used as the main database abstraction layer tool. The module
1212
automatically generates an API according to JSON API specification from the database structure (TypeORM entities). It
1313
supports features such as requests validation based on database fields types, request filtering, endpoints extending,
1414
data relations control and much more. Our module significantly reduces the development time of REST services by removing
@@ -24,15 +24,32 @@ $ npm install json-api-nestjs
2424
## Example
2525

2626
Once the installation process is complete, we can import the **JsonApiModule** into the root **AppModule**.
27+
### TypeOrm
28+
```typescript
29+
import {Module} from '@nestjs/common';
30+
import {JsonApiModule, TypeOrmJsonApiModule} from 'json-api-nestjs';
31+
import {Users} from 'type-orm/database';
2732

33+
@Module({
34+
imports: [
35+
JsonApiModule.forRoot(TypeOrmJsonApiModule, {
36+
entities: [Users]
37+
}),
38+
],
39+
})
40+
export class AppModule {
41+
}
42+
```
43+
44+
### MicroOrm
2845
```typescript
2946
import {Module} from '@nestjs/common';
30-
import {JsonApiModule} from 'json-api-nestjs';
31-
import {Users} from 'database';
47+
import {JsonApiModule, MicroOrmJsonApiModule} from 'json-api-nestjs';
48+
import {Users} from 'micro-orm/database';
3249

3350
@Module({
3451
imports: [
35-
JsonApiModule.forRoot({
52+
JsonApiModule.forRoot(MicroOrmJsonApiModule, {
3653
entities: [Users]
3754
}),
3855
],
@@ -69,11 +86,14 @@ export interface ModuleOptions {
6986
debug?: boolean; // Debug info in result object, like error message
7087
pipeForId?: Type<PipeTransform> // Nestjs pipe for validate id params, by default ParseIntPipe
7188
operationUrl?: string // Url for atomic operation https://jsonapi.org/ext/atomic/
89+
// TypeOrm
7290
useSoftDelete?: boolean // Use soft delete
7391
runInTransaction?: <Func extends (...args: any) => any>(
7492
isolationLevel: IsolationLevel,
7593
fn: Func
7694
) => ReturnType<Func> // You can use cutom function for wrapping transaction in atomic operation, example: runInTransaction from https://github.com/Aliheym/typeorm-transactional
95+
// MicroOrm
96+
arrayType?: string[]; //Custom type for indicate of array
7797
};
7898
}
7999
```
@@ -254,7 +274,7 @@ Available query params:
254274
```typescript
255275
type FilterOperand
256276
{
257-
in:string[] // is equal to the conditional of query "WHERE 'attribute_name' IN ('value1', 'value2')"
277+
in:string[] // is equal to the conditional of query "WHERE 'attribute_name' IN ('value1', 'value2')"
258278
nin: string[] // is equal to the conditional of query "WHERE 'attribute_name' NOT IN ('value1', 'value1')"
259279
eq: string // is equal to the conditional of query "WHERE 'attribute_name' = 'value1'
260280
ne: string // is equal to the conditional of query "WHERE 'attribute_name' <> 'value1'

libs/json-api/json-api-nestjs/package.json

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@klerick/json-api-nestjs",
2+
"name": "json-api-nestjs",
33
"version": "8.0.0",
44
"engines": {
55
"node": ">= 16.0.0"
@@ -27,10 +27,24 @@
2727
"jsonapi",
2828
"json-api",
2929
"typeorm",
30+
"microorm",
3031
"CRUD"
3132
],
3233
"peerDependencies": {
3334
"reflect-metadata": "^0.1.13",
34-
"tslib": "^2.3.0"
35+
"tslib": "^2.3.0",
36+
"@mikro-orm/core": "^6.0.0 || ^6.0.0-dev.0",
37+
"@nestjs/common": "^10.0.0",
38+
"@nestjs/core": "^10.0.0",
39+
"@nestjs/swagger": "^7.3.0",
40+
"@nestjs/typeorm": "^10.0.0",
41+
"@mikro-orm/knex": "^6.0.0",
42+
"typeorm": "^0.3.20"
43+
},
44+
"dependencies": {
45+
"@anatine/zod-openapi": "^2.0.0",
46+
"zod": "^3.24.0",
47+
"zod-validation-error": "^3.4.0",
48+
"uuid": "^10.0.0"
3549
}
3650
}

libs/json-api/json-api-nestjs/project.json

+30-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,42 @@
2121
"tsConfig": "libs/json-api/json-api-nestjs/tsconfig.lib.json",
2222
"packageJson": "libs/json-api/json-api-nestjs/package.json",
2323
"main": "libs/json-api/json-api-nestjs/src/index.ts",
24-
"assets": ["libs/json-api/json-api-nestjs/*.md"]
24+
"assets": ["libs/json-api/json-api-nestjs/*.md"],
25+
"buildableProjectDepsInPackageJsonType": "peerDependencies",
26+
"generateExportsField": true
2527
}
2628
},
2729
"nx-release-publish": {
2830
"options": {
2931
"packageRoot": "dist/{projectRoot}"
3032
}
33+
},
34+
"publish": {
35+
"command": "node tools/scripts/publish.mjs json-api-nestjs {args.ver} {args.tag}",
36+
"dependsOn": ["build"]
37+
},
38+
"test": {
39+
"executor": "@nx/jest:jest",
40+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
41+
"options": {
42+
"jestConfig": "libs/json-api/json-api-nestjs/jest.config.ts",
43+
"codeCoverage": true,
44+
"coverageReporters": ["json-summary"]
45+
}
46+
},
47+
"upload-badge": {
48+
"executor": "nx:run-commands",
49+
"dependsOn": [
50+
{
51+
"target": "test"
52+
}
53+
],
54+
"options": {
55+
"commands": ["node tools/scripts/upload-badge.mjs json-api-nestjs"],
56+
"cwd": "./",
57+
"parallel": false,
58+
"outputPath": "{workspaceRoot}/libs/json-api/json-api-nestjs"
59+
}
3160
}
3261
}
3362
}

0 commit comments

Comments
 (0)