@lenne.tech/nest-server 10.3.1 → 10.3.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/dist/config.env.js +3 -3
- package/dist/config.env.js.map +1 -1
- package/dist/core/common/inputs/combined-filter.input.js +5 -0
- package/dist/core/common/inputs/combined-filter.input.js.map +1 -1
- package/dist/core/common/inputs/filter.input.js +5 -0
- package/dist/core/common/inputs/filter.input.js.map +1 -1
- package/dist/core/common/inputs/single-filter.input.js +10 -0
- package/dist/core/common/inputs/single-filter.input.js.map +1 -1
- package/dist/core/common/inputs/sort.input.js +5 -0
- package/dist/core/common/inputs/sort.input.js.map +1 -1
- package/dist/core/common/models/core-persistence.model.d.ts +1 -0
- package/dist/core/common/models/core-persistence.model.js +9 -0
- package/dist/core/common/models/core-persistence.model.js.map +1 -1
- package/dist/core/modules/auth/core-auth.controller.js +7 -0
- package/dist/core/modules/auth/core-auth.controller.js.map +1 -1
- package/dist/core/modules/auth/core-auth.model.js +6 -0
- package/dist/core/modules/auth/core-auth.model.js.map +1 -1
- package/dist/core/modules/auth/core-auth.resolver.js +7 -0
- package/dist/core/modules/auth/core-auth.resolver.js.map +1 -1
- package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js +7 -0
- package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js.map +1 -1
- package/dist/core/modules/auth/inputs/core-auth-sign-up.input.js +3 -0
- package/dist/core/modules/auth/inputs/core-auth-sign-up.input.js.map +1 -1
- package/dist/core/modules/file/core-file-info.model.js +14 -0
- package/dist/core/modules/file/core-file-info.model.js.map +1 -1
- package/dist/core/modules/file/core-file.controller.js +4 -0
- package/dist/core/modules/file/core-file.controller.js.map +1 -1
- package/dist/core/modules/file/core-file.resolver.js +7 -0
- package/dist/core/modules/file/core-file.resolver.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check-result.model.js +7 -0
- package/dist/core/modules/health-check/core-health-check-result.model.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check.controller.js +4 -0
- package/dist/core/modules/health-check/core-health-check.controller.js.map +1 -1
- package/dist/core/modules/user/core-user.model.js +15 -0
- package/dist/core/modules/user/core-user.model.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user-create.input.js +4 -0
- package/dist/core/modules/user/inputs/core-user-create.input.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js +6 -0
- package/dist/core/modules/user/inputs/core-user.input.js.map +1 -1
- package/dist/server/common/models/persistence.model.js +5 -0
- package/dist/server/common/models/persistence.model.js.map +1 -1
- package/dist/server/modules/auth/auth.controller.js +3 -0
- package/dist/server/modules/auth/auth.controller.js.map +1 -1
- package/dist/server/modules/auth/auth.model.js +4 -0
- package/dist/server/modules/auth/auth.model.js.map +1 -1
- package/dist/server/modules/auth/auth.resolver.js +5 -0
- package/dist/server/modules/auth/auth.resolver.js.map +1 -1
- package/dist/server/modules/auth/inputs/auth-sign-in.input.js +3 -0
- package/dist/server/modules/auth/inputs/auth-sign-in.input.js.map +1 -1
- package/dist/server/modules/auth/inputs/auth-sign-up.input.js +5 -0
- package/dist/server/modules/auth/inputs/auth-sign-up.input.js.map +1 -1
- package/dist/server/modules/file/file-info.model.js +3 -0
- package/dist/server/modules/file/file-info.model.js.map +1 -1
- package/dist/server/modules/file/file.controller.js +4 -0
- package/dist/server/modules/file/file.controller.js.map +1 -1
- package/dist/server/modules/user/avatar.controller.js +1 -0
- package/dist/server/modules/user/avatar.controller.js.map +1 -1
- package/dist/server/modules/user/inputs/user-create.input.js +3 -0
- package/dist/server/modules/user/inputs/user-create.input.js.map +1 -1
- package/dist/server/modules/user/inputs/user.input.js +3 -0
- package/dist/server/modules/user/inputs/user.input.js.map +1 -1
- package/dist/server/modules/user/outputs/find-and-count-users-result.output.js +5 -0
- package/dist/server/modules/user/outputs/find-and-count-users-result.output.js.map +1 -1
- package/dist/server/modules/user/user.model.d.ts +1 -0
- package/dist/server/modules/user/user.model.js +14 -0
- package/dist/server/modules/user/user.model.js.map +1 -1
- package/dist/server/server.controller.js +2 -0
- package/dist/server/server.controller.js.map +1 -1
- package/dist/test/test.helper.d.ts +1 -0
- package/dist/test/test.helper.js +7 -1
- package/dist/test/test.helper.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/config.env.ts +3 -3
- package/src/core/common/inputs/combined-filter.input.ts +5 -0
- package/src/core/common/inputs/filter.input.ts +5 -0
- package/src/core/common/inputs/single-filter.input.ts +10 -0
- package/src/core/common/inputs/sort.input.ts +5 -0
- package/src/core/common/models/core-persistence.model.ts +13 -0
- package/src/core/modules/auth/core-auth.controller.ts +7 -0
- package/src/core/modules/auth/core-auth.model.ts +6 -0
- package/src/core/modules/auth/core-auth.resolver.ts +7 -0
- package/src/core/modules/auth/inputs/core-auth-sign-in.input.ts +7 -0
- package/src/core/modules/auth/inputs/core-auth-sign-up.input.ts +3 -0
- package/src/core/modules/file/core-file-info.model.ts +10 -0
- package/src/core/modules/file/core-file.controller.ts +4 -0
- package/src/core/modules/file/core-file.resolver.ts +7 -0
- package/src/core/modules/health-check/core-health-check-result.model.ts +7 -0
- package/src/core/modules/health-check/core-health-check.controller.ts +4 -0
- package/src/core/modules/user/core-user.model.ts +15 -0
- package/src/core/modules/user/inputs/core-user-create.input.ts +4 -0
- package/src/core/modules/user/inputs/core-user.input.ts +6 -0
- package/src/server/common/models/persistence.model.ts +5 -0
- package/src/server/modules/auth/auth.controller.ts +3 -0
- package/src/server/modules/auth/auth.model.ts +4 -0
- package/src/server/modules/auth/auth.resolver.ts +5 -0
- package/src/server/modules/auth/inputs/auth-sign-in.input.ts +3 -0
- package/src/server/modules/auth/inputs/auth-sign-up.input.ts +5 -0
- package/src/server/modules/file/file-info.model.ts +3 -0
- package/src/server/modules/file/file.controller.ts +4 -0
- package/src/server/modules/user/avatar.controller.ts +1 -0
- package/src/server/modules/user/inputs/user-create.input.ts +3 -0
- package/src/server/modules/user/inputs/user.input.ts +3 -0
- package/src/server/modules/user/outputs/find-and-count-users-result.output.ts +5 -0
- package/src/server/modules/user/user.model.ts +15 -0
- package/src/server/server.controller.ts +2 -0
- package/src/test/test.helper.ts +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "10.3.
|
|
3
|
+
"version": "10.3.3",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
"@lenne.tech/mongoose-gridfs": "1.4.2",
|
|
69
69
|
"@lenne.tech/multer-gridfs-storage": "5.0.6",
|
|
70
70
|
"@nestjs/apollo": "12.2.0",
|
|
71
|
-
"@nestjs/common": "10.4.
|
|
72
|
-
"@nestjs/core": "10.4.
|
|
71
|
+
"@nestjs/common": "10.4.1",
|
|
72
|
+
"@nestjs/core": "10.4.1",
|
|
73
73
|
"@nestjs/graphql": "12.2.0",
|
|
74
74
|
"@nestjs/jwt": "10.2.0",
|
|
75
75
|
"@nestjs/mongoose": "10.0.10",
|
|
76
76
|
"@nestjs/passport": "10.0.3",
|
|
77
|
-
"@nestjs/platform-express": "10.4.
|
|
77
|
+
"@nestjs/platform-express": "10.4.1",
|
|
78
78
|
"@nestjs/schedule": "4.1.0",
|
|
79
79
|
"@nestjs/terminus": "10.2.3",
|
|
80
80
|
"apollo-server-core": "3.13.0",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"light-my-request": "5.13.0",
|
|
95
95
|
"lodash": "4.17.21",
|
|
96
96
|
"mongodb": "6.8.0",
|
|
97
|
-
"mongoose": "7.8.
|
|
97
|
+
"mongoose": "7.8.1",
|
|
98
98
|
"multer": "1.4.5-lts.1",
|
|
99
99
|
"node-mailjet": "6.0.5",
|
|
100
100
|
"nodemailer": "6.9.14",
|
|
@@ -112,10 +112,10 @@
|
|
|
112
112
|
"@compodoc/compodoc": "1.1.25",
|
|
113
113
|
"@lenne.tech/eslint-config-ts": "0.0.16",
|
|
114
114
|
"@nestjs/cli": "10.4.4",
|
|
115
|
-
"@nestjs/schematics": "10.1.
|
|
116
|
-
"@nestjs/testing": "10.4.
|
|
115
|
+
"@nestjs/schematics": "10.1.4",
|
|
116
|
+
"@nestjs/testing": "10.4.1",
|
|
117
117
|
"@swc/cli": "0.4.0",
|
|
118
|
-
"@swc/core": "1.7.
|
|
118
|
+
"@swc/core": "1.7.14",
|
|
119
119
|
"@swc/jest": "0.2.36",
|
|
120
120
|
"@types/compression": "1.7.5",
|
|
121
121
|
"@types/cookie-parser": "1.4.7",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"@types/jest": "29.5.12",
|
|
125
125
|
"@types/lodash": "4.17.7",
|
|
126
126
|
"@types/multer": "1.4.11",
|
|
127
|
-
"@types/node": "
|
|
127
|
+
"@types/node": "20.16.1",
|
|
128
128
|
"@types/nodemailer": "6.4.15",
|
|
129
129
|
"@types/passport": "1.0.16",
|
|
130
130
|
"@types/supertest": "6.0.2",
|
|
@@ -133,14 +133,14 @@
|
|
|
133
133
|
"coffeescript": "2.7.0",
|
|
134
134
|
"eslint": "8.57.0",
|
|
135
135
|
"eslint-config-prettier": "9.1.0",
|
|
136
|
-
"eslint-plugin-unused-imports": "
|
|
136
|
+
"eslint-plugin-unused-imports": "4.1.3",
|
|
137
137
|
"find-file-up": "2.0.1",
|
|
138
138
|
"grunt": "1.6.1",
|
|
139
139
|
"grunt-bg-shell": "2.3.3",
|
|
140
140
|
"grunt-contrib-clean": "2.0.1",
|
|
141
141
|
"grunt-contrib-watch": "1.1.0",
|
|
142
142
|
"grunt-sync": "0.8.2",
|
|
143
|
-
"husky": "9.1.
|
|
143
|
+
"husky": "9.1.5",
|
|
144
144
|
"jest": "29.7.0",
|
|
145
145
|
"npm-watch": "0.13.0",
|
|
146
146
|
"pm2": "5.4.2",
|
package/src/config.env.ts
CHANGED
|
@@ -45,7 +45,7 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
45
45
|
driver: {
|
|
46
46
|
introspection: true,
|
|
47
47
|
},
|
|
48
|
-
maxComplexity:
|
|
48
|
+
maxComplexity: 1000,
|
|
49
49
|
},
|
|
50
50
|
healthCheck: {
|
|
51
51
|
configs: {
|
|
@@ -158,7 +158,7 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
158
158
|
driver: {
|
|
159
159
|
introspection: true,
|
|
160
160
|
},
|
|
161
|
-
maxComplexity:
|
|
161
|
+
maxComplexity: 1000,
|
|
162
162
|
},
|
|
163
163
|
healthCheck: {
|
|
164
164
|
configs: {
|
|
@@ -262,7 +262,7 @@ const config: { [env: string]: IServerOptions } = {
|
|
|
262
262
|
driver: {
|
|
263
263
|
introspection: true,
|
|
264
264
|
},
|
|
265
|
-
maxComplexity:
|
|
265
|
+
maxComplexity: 1000,
|
|
266
266
|
},
|
|
267
267
|
healthCheck: {
|
|
268
268
|
configs: {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Field, InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../decorators/restricted.decorator';
|
|
3
4
|
import { LogicalOperatorEnum } from '../enums/logical-operator.enum';
|
|
5
|
+
import { RoleEnum } from '../enums/role.enum';
|
|
4
6
|
import { maps } from '../helpers/model.helper';
|
|
5
7
|
import { CoreInput } from './core-input.input';
|
|
6
8
|
import { FilterInput } from './filter.input';
|
|
7
9
|
|
|
10
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
8
11
|
@InputType({
|
|
9
12
|
description: 'Combination of multiple filters via logical operator',
|
|
10
13
|
})
|
|
@@ -12,6 +15,7 @@ export class CombinedFilterInput extends CoreInput {
|
|
|
12
15
|
/**
|
|
13
16
|
* Logical Operator to combine filters
|
|
14
17
|
*/
|
|
18
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
15
19
|
@Field(type => LogicalOperatorEnum, {
|
|
16
20
|
description: 'Logical Operator to combine filters',
|
|
17
21
|
})
|
|
@@ -20,6 +24,7 @@ export class CombinedFilterInput extends CoreInput {
|
|
|
20
24
|
/**
|
|
21
25
|
* Filters to combine via logical operator
|
|
22
26
|
*/
|
|
27
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
23
28
|
@Field(type => [FilterInput], {
|
|
24
29
|
description: 'Filters to combine via logical operator',
|
|
25
30
|
})
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Field, InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../enums/role.enum';
|
|
3
5
|
import { CombinedFilterInput } from './combined-filter.input';
|
|
4
6
|
import { CoreInput } from './core-input.input';
|
|
5
7
|
import { SingleFilterInput } from './single-filter.input';
|
|
@@ -7,6 +9,7 @@ import { SingleFilterInput } from './single-filter.input';
|
|
|
7
9
|
/**
|
|
8
10
|
* Input for filtering. The `singleFilter` will be ignored if the `combinedFilter` is set.
|
|
9
11
|
*/
|
|
12
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
10
13
|
@InputType({
|
|
11
14
|
description: 'Input for filtering. The `singleFilter` will be ignored if the `combinedFilter` is set.',
|
|
12
15
|
})
|
|
@@ -14,6 +17,7 @@ export class FilterInput extends CoreInput {
|
|
|
14
17
|
/**
|
|
15
18
|
* Combination of multiple filters via logical operator
|
|
16
19
|
*/
|
|
20
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
17
21
|
@Field(type => CombinedFilterInput, {
|
|
18
22
|
description: 'Combination of multiple filters via logical operator',
|
|
19
23
|
nullable: true,
|
|
@@ -23,6 +27,7 @@ export class FilterInput extends CoreInput {
|
|
|
23
27
|
/**
|
|
24
28
|
* Filter for a single property
|
|
25
29
|
*/
|
|
30
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
26
31
|
@Field(type => SingleFilterInput, {
|
|
27
32
|
description: 'Filter for a single property',
|
|
28
33
|
nullable: true,
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { Field, InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../decorators/restricted.decorator';
|
|
3
4
|
import { ComparisonOperatorEnum } from '../enums/comparison-operator.enum';
|
|
5
|
+
import { RoleEnum } from '../enums/role.enum';
|
|
4
6
|
import { JSON } from '../scalars/json.scalar';
|
|
5
7
|
import { CoreInput } from './core-input.input';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Input for a configuration of a filter
|
|
9
11
|
*/
|
|
12
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
10
13
|
@InputType({ description: 'Input for a configuration of a filter' })
|
|
11
14
|
export class SingleFilterInput extends CoreInput {
|
|
12
15
|
/**
|
|
13
16
|
* Convert value to ObjectId
|
|
14
17
|
*/
|
|
18
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
15
19
|
@Field({
|
|
16
20
|
description: 'Convert value to ObjectId',
|
|
17
21
|
nullable: true,
|
|
@@ -21,12 +25,14 @@ export class SingleFilterInput extends CoreInput {
|
|
|
21
25
|
/**
|
|
22
26
|
* Name of the property to be used for the filter
|
|
23
27
|
*/
|
|
28
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
24
29
|
@Field({ description: 'Name of the property to be used for the filter' })
|
|
25
30
|
field: string = undefined;
|
|
26
31
|
|
|
27
32
|
/**
|
|
28
33
|
* Process value as reference
|
|
29
34
|
*/
|
|
35
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
30
36
|
@Field({
|
|
31
37
|
description: 'Process value as reference',
|
|
32
38
|
nullable: true,
|
|
@@ -36,6 +42,7 @@ export class SingleFilterInput extends CoreInput {
|
|
|
36
42
|
/**
|
|
37
43
|
* [Negate operator](https://docs.mongodb.com/manual/reference/operator/query/not/)
|
|
38
44
|
*/
|
|
45
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
39
46
|
@Field({
|
|
40
47
|
description: '[Negate operator](https://docs.mongodb.com/manual/reference/operator/query/not/)',
|
|
41
48
|
nullable: true,
|
|
@@ -45,6 +52,7 @@ export class SingleFilterInput extends CoreInput {
|
|
|
45
52
|
/**
|
|
46
53
|
* [Comparison operator](https://docs.mongodb.com/manual/reference/operator/query-comparison/)
|
|
47
54
|
*/
|
|
55
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
48
56
|
@Field(type => ComparisonOperatorEnum, {
|
|
49
57
|
description: '[Comparison operator](https://docs.mongodb.com/manual/reference/operator/query-comparison/)',
|
|
50
58
|
})
|
|
@@ -54,6 +62,7 @@ export class SingleFilterInput extends CoreInput {
|
|
|
54
62
|
* [Options](https://docs.mongodb.com/manual/reference/operator/query/regex/#op._S_options) for
|
|
55
63
|
* [REGEX](https://docs.mongodb.com/manual/reference/operator/query/regex/) operator
|
|
56
64
|
*/
|
|
65
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
57
66
|
@Field({
|
|
58
67
|
description:
|
|
59
68
|
'[Options](https://docs.mongodb.com/manual/reference/operator/query/regex/#op._S_options) for '
|
|
@@ -62,6 +71,7 @@ export class SingleFilterInput extends CoreInput {
|
|
|
62
71
|
})
|
|
63
72
|
options?: string = undefined;
|
|
64
73
|
|
|
74
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
65
75
|
@Field(type => JSON, { description: 'Value of the property' })
|
|
66
76
|
value: any = undefined;
|
|
67
77
|
}
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import { Field, InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../enums/role.enum';
|
|
3
5
|
import { SortOrderEnum } from '../enums/sort-order.emum';
|
|
4
6
|
import { CoreInput } from './core-input.input';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Sorting the returned elements
|
|
8
10
|
*/
|
|
11
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
9
12
|
@InputType({ description: 'Sorting the returned elements' })
|
|
10
13
|
export class SortInput extends CoreInput {
|
|
11
14
|
/**
|
|
12
15
|
* Field that is to be used for sorting
|
|
13
16
|
*/
|
|
17
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
14
18
|
@Field({ description: 'Field that is to be used for sorting' })
|
|
15
19
|
field: string = undefined;
|
|
16
20
|
|
|
17
21
|
/**
|
|
18
22
|
* SortInput order of the field
|
|
19
23
|
*/
|
|
24
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
20
25
|
@Field(type => SortOrderEnum, { description: 'SortInput order of the field' })
|
|
21
26
|
order: SortOrderEnum = undefined;
|
|
22
27
|
}
|
|
@@ -4,6 +4,7 @@ import { Types } from 'mongoose';
|
|
|
4
4
|
|
|
5
5
|
import { Restricted } from '../decorators/restricted.decorator';
|
|
6
6
|
import { RoleEnum } from '../enums/role.enum';
|
|
7
|
+
import { getStringIds } from '../helpers/db.helper';
|
|
7
8
|
import { CoreModel } from './core-model.model';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -18,6 +19,7 @@ import { CoreModel } from './core-model.model';
|
|
|
18
19
|
* with undefined if possible. If necessary and useful, the init method can then be used deliberately:
|
|
19
20
|
* const corePersistenceModel = item ? CorePersistenceModel.map(item).init() : CorePersistenceModel.init();
|
|
20
21
|
*/
|
|
22
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
21
23
|
@ObjectType({
|
|
22
24
|
description: 'Persistence model which will be saved in DB',
|
|
23
25
|
isAbstract: true,
|
|
@@ -100,4 +102,15 @@ export abstract class CorePersistenceModel extends CoreModel {
|
|
|
100
102
|
this.updatedAt = this.tags === undefined ? this.createdAt : this.updatedAt;
|
|
101
103
|
return this;
|
|
102
104
|
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Map input
|
|
108
|
+
*/
|
|
109
|
+
override map(input) {
|
|
110
|
+
super.map(input);
|
|
111
|
+
if (input._id) {
|
|
112
|
+
this.id = getStringIds(input);
|
|
113
|
+
}
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
103
116
|
}
|
|
@@ -3,6 +3,8 @@ import { Args } from '@nestjs/graphql';
|
|
|
3
3
|
import { Response as ResponseType } from 'express';
|
|
4
4
|
|
|
5
5
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
6
|
+
import { Roles } from '../../common/decorators/roles.decorator';
|
|
7
|
+
import { RoleEnum } from '../../common/enums/role.enum';
|
|
6
8
|
import { ConfigService } from '../../common/services/config.service';
|
|
7
9
|
import { AuthGuardStrategy } from './auth-guard-strategy.enum';
|
|
8
10
|
import { CoreAuthModel } from './core-auth.model';
|
|
@@ -13,6 +15,7 @@ import { ICoreAuthUser } from './interfaces/core-auth-user.interface';
|
|
|
13
15
|
import { CoreAuthService } from './services/core-auth.service';
|
|
14
16
|
import { Tokens } from './tokens.decorator';
|
|
15
17
|
|
|
18
|
+
@Roles(RoleEnum.ADMIN)
|
|
16
19
|
@Controller('auth')
|
|
17
20
|
export class CoreAuthController {
|
|
18
21
|
/**
|
|
@@ -26,6 +29,7 @@ export class CoreAuthController {
|
|
|
26
29
|
/**
|
|
27
30
|
* Logout user (from specific device)
|
|
28
31
|
*/
|
|
32
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
29
33
|
@UseGuards(AuthGuard(AuthGuardStrategy.JWT))
|
|
30
34
|
@Get()
|
|
31
35
|
async logout(
|
|
@@ -41,6 +45,7 @@ export class CoreAuthController {
|
|
|
41
45
|
/**
|
|
42
46
|
* Refresh token (for specific device)
|
|
43
47
|
*/
|
|
48
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
44
49
|
@UseGuards(AuthGuard(AuthGuardStrategy.JWT_REFRESH))
|
|
45
50
|
@Get()
|
|
46
51
|
async refreshToken(
|
|
@@ -55,6 +60,7 @@ export class CoreAuthController {
|
|
|
55
60
|
/**
|
|
56
61
|
* Sign in user via email and password (on specific device)
|
|
57
62
|
*/
|
|
63
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
58
64
|
@Post()
|
|
59
65
|
async signIn(@Res() res: ResponseType, @Body('input') input: CoreAuthSignInInput): Promise<CoreAuthModel> {
|
|
60
66
|
const result = await this.authService.signIn(input);
|
|
@@ -64,6 +70,7 @@ export class CoreAuthController {
|
|
|
64
70
|
/**
|
|
65
71
|
* Register a new user account (on specific device)
|
|
66
72
|
*/
|
|
73
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
67
74
|
@Post()
|
|
68
75
|
async signUp(@Res() res: ResponseType, @Args('input') input: CoreAuthSignUpInput): Promise<CoreAuthModel> {
|
|
69
76
|
const result = await this.authService.signUp(input);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Field, ObjectType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../../common/decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../../common/enums/role.enum';
|
|
3
5
|
import { CoreModel } from '../../common/models/core-model.model';
|
|
4
6
|
import { CoreUserModel } from '../user/core-user.model';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* CoreAuth model for the response after the sign in
|
|
8
10
|
*/
|
|
11
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
9
12
|
@ObjectType({ description: 'CoreAuth', isAbstract: true })
|
|
10
13
|
export class CoreAuthModel extends CoreModel {
|
|
11
14
|
// ===================================================================================================================
|
|
@@ -15,18 +18,21 @@ export class CoreAuthModel extends CoreModel {
|
|
|
15
18
|
/**
|
|
16
19
|
* JavaScript Web Token (JWT)
|
|
17
20
|
*/
|
|
21
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
18
22
|
@Field({ description: 'JavaScript Web Token (JWT)', nullable: true })
|
|
19
23
|
token?: string = undefined;
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* Refresh token
|
|
23
27
|
*/
|
|
28
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
24
29
|
@Field({ description: 'Refresh token', nullable: true })
|
|
25
30
|
refreshToken?: string = undefined;
|
|
26
31
|
|
|
27
32
|
/**
|
|
28
33
|
* Current user
|
|
29
34
|
*/
|
|
35
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
30
36
|
@Field({ description: 'Current user' })
|
|
31
37
|
user: CoreUserModel = undefined;
|
|
32
38
|
|
|
@@ -4,6 +4,8 @@ import { Response as ResponseType } from 'express';
|
|
|
4
4
|
|
|
5
5
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
6
6
|
import { GraphQLServiceOptions } from '../../common/decorators/graphql-service-options.decorator';
|
|
7
|
+
import { Roles } from '../../common/decorators/roles.decorator';
|
|
8
|
+
import { RoleEnum } from '../../common/enums/role.enum';
|
|
7
9
|
import { ServiceOptions } from '../../common/interfaces/service-options.interface';
|
|
8
10
|
import { ConfigService } from '../../common/services/config.service';
|
|
9
11
|
import { AuthGuardStrategy } from './auth-guard-strategy.enum';
|
|
@@ -18,6 +20,7 @@ import { Tokens } from './tokens.decorator';
|
|
|
18
20
|
/**
|
|
19
21
|
* Authentication resolver for the sign in
|
|
20
22
|
*/
|
|
23
|
+
@Roles(RoleEnum.ADMIN)
|
|
21
24
|
@Resolver(of => CoreAuthModel, { isAbstract: true })
|
|
22
25
|
export class CoreAuthResolver {
|
|
23
26
|
/**
|
|
@@ -35,6 +38,7 @@ export class CoreAuthResolver {
|
|
|
35
38
|
/**
|
|
36
39
|
* Logout user (from specific device)
|
|
37
40
|
*/
|
|
41
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
38
42
|
@UseGuards(AuthGuard(AuthGuardStrategy.JWT))
|
|
39
43
|
@Mutation(returns => Boolean, { description: 'Logout user (from specific device)' })
|
|
40
44
|
async logout(
|
|
@@ -50,6 +54,7 @@ export class CoreAuthResolver {
|
|
|
50
54
|
/**
|
|
51
55
|
* Refresh token (for specific device)
|
|
52
56
|
*/
|
|
57
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
53
58
|
@UseGuards(AuthGuard(AuthGuardStrategy.JWT_REFRESH))
|
|
54
59
|
@Mutation(returns => CoreAuthModel, { description: 'Refresh tokens (for specific device)' })
|
|
55
60
|
async refreshToken(
|
|
@@ -64,6 +69,7 @@ export class CoreAuthResolver {
|
|
|
64
69
|
/**
|
|
65
70
|
* Sign in user via email and password (on specific device)
|
|
66
71
|
*/
|
|
72
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
67
73
|
@Mutation(returns => CoreAuthModel, {
|
|
68
74
|
description: 'Sign in user via email and password and get JWT tokens (for specific device)',
|
|
69
75
|
})
|
|
@@ -79,6 +85,7 @@ export class CoreAuthResolver {
|
|
|
79
85
|
/**
|
|
80
86
|
* Register a new user account (on specific device)
|
|
81
87
|
*/
|
|
88
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
82
89
|
@Mutation(returns => CoreAuthModel, { description: 'Register a new user account (on specific device)' })
|
|
83
90
|
async signUp(
|
|
84
91
|
@GraphQLServiceOptions({ gqlPath: 'signUp.user' }) serviceOptions: ServiceOptions,
|
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
import { Field, InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../../../common/decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../../../common/enums/role.enum';
|
|
3
5
|
import { CoreInput } from '../../../common/inputs/core-input.input';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* SignIn input
|
|
7
9
|
*/
|
|
10
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
8
11
|
@InputType({ description: 'Sign-in input' })
|
|
9
12
|
export class CoreAuthSignInInput extends CoreInput {
|
|
10
13
|
// ===================================================================================================================
|
|
11
14
|
// Properties
|
|
12
15
|
// ===================================================================================================================
|
|
13
16
|
|
|
17
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
14
18
|
@Field({ description: 'Device ID (is created automatically if it is not set)', nullable: true })
|
|
15
19
|
deviceId?: string = undefined;
|
|
16
20
|
|
|
21
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
17
22
|
@Field({ description: 'Device description', nullable: true })
|
|
18
23
|
deviceDescription?: string = undefined;
|
|
19
24
|
|
|
25
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
20
26
|
@Field({ description: 'Email', nullable: false })
|
|
21
27
|
email: string = undefined;
|
|
22
28
|
|
|
29
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
23
30
|
@Field({ description: 'Password', nullable: false })
|
|
24
31
|
password: string = undefined;
|
|
25
32
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../../../common/decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../../../common/enums/role.enum';
|
|
3
5
|
import { CoreAuthSignInInput } from './core-auth-sign-in.input';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* SignUp input
|
|
7
9
|
*/
|
|
10
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
8
11
|
@InputType({ description: 'Sign-up input' })
|
|
9
12
|
export class CoreAuthSignUpInput extends CoreAuthSignInInput {}
|
|
@@ -2,17 +2,21 @@ import { Field, ObjectType } from '@nestjs/graphql';
|
|
|
2
2
|
import { Prop } from '@nestjs/mongoose';
|
|
3
3
|
import { Types } from 'mongoose';
|
|
4
4
|
|
|
5
|
+
import { Restricted } from '../../common/decorators/restricted.decorator';
|
|
6
|
+
import { RoleEnum } from '../../common/enums/role.enum';
|
|
5
7
|
import { CoreModel } from '../../common/models/core-model.model';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* File info
|
|
9
11
|
*/
|
|
12
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
10
13
|
@ObjectType({ description: 'Information about file' })
|
|
11
14
|
export class CoreFileInfo extends CoreModel {
|
|
12
15
|
// ===========================================================================
|
|
13
16
|
// Getter
|
|
14
17
|
// ===========================================================================
|
|
15
18
|
|
|
19
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
16
20
|
get _id() {
|
|
17
21
|
return new Types.ObjectId(this.id);
|
|
18
22
|
}
|
|
@@ -21,9 +25,11 @@ export class CoreFileInfo extends CoreModel {
|
|
|
21
25
|
// Properties
|
|
22
26
|
// ===========================================================================
|
|
23
27
|
|
|
28
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
24
29
|
@Field(() => String, { description: 'ID of the file' })
|
|
25
30
|
id: string = undefined;
|
|
26
31
|
|
|
32
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
27
33
|
@Field(() => Number, {
|
|
28
34
|
description:
|
|
29
35
|
'The size of each chunk in bytes. GridFS divides the document into chunks of size chunkSize, '
|
|
@@ -33,18 +39,22 @@ export class CoreFileInfo extends CoreModel {
|
|
|
33
39
|
@Prop({ required: false, type: Number })
|
|
34
40
|
chunkSize: number = undefined;
|
|
35
41
|
|
|
42
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
36
43
|
@Field(() => String, { description: 'Content type', nullable: true })
|
|
37
44
|
@Prop({ required: false, type: String })
|
|
38
45
|
contentType?: string = undefined;
|
|
39
46
|
|
|
47
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
40
48
|
@Field(() => String, { description: 'Name of the file', nullable: true })
|
|
41
49
|
@Prop({ required: false, type: String })
|
|
42
50
|
filename?: string = undefined;
|
|
43
51
|
|
|
52
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
44
53
|
@Field(() => Number, { description: 'The size of the document in bytes', nullable: true })
|
|
45
54
|
@Prop({ required: false, type: Number })
|
|
46
55
|
length: number = undefined;
|
|
47
56
|
|
|
57
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
48
58
|
@Field(() => Date, { description: 'The date the file was first stored', nullable: true })
|
|
49
59
|
@Prop({ required: false, type: Date })
|
|
50
60
|
uploadDate: Date = undefined;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { BadRequestException, Controller, Get, NotFoundException, Param, Res } from '@nestjs/common';
|
|
2
2
|
|
|
3
|
+
import { Roles } from '../../common/decorators/roles.decorator';
|
|
4
|
+
import { RoleEnum } from '../../common/enums/role.enum';
|
|
3
5
|
import { CoreFileService } from './core-file.service';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* File controller
|
|
7
9
|
*/
|
|
10
|
+
@Roles(RoleEnum.ADMIN)
|
|
8
11
|
@Controller('files')
|
|
9
12
|
export abstract class CoreFileController {
|
|
10
13
|
/**
|
|
@@ -15,6 +18,7 @@ export abstract class CoreFileController {
|
|
|
15
18
|
/**
|
|
16
19
|
* Download file
|
|
17
20
|
*/
|
|
21
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
18
22
|
@Get(':filename')
|
|
19
23
|
async getFile(@Param('filename') filename: string, @Res() res) {
|
|
20
24
|
if (!filename) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
|
2
2
|
import * as GraphQLUpload from 'graphql-upload/GraphQLUpload.js';
|
|
3
3
|
|
|
4
|
+
import { Roles } from '../../common/decorators/roles.decorator';
|
|
5
|
+
import { RoleEnum } from '../../common/enums/role.enum';
|
|
4
6
|
import { CoreFileService } from './core-file.service';
|
|
5
7
|
import { CoreFileInfo } from './core-file-info.model';
|
|
6
8
|
import { FileUpload } from './interfaces/file-upload.interface';
|
|
@@ -8,6 +10,7 @@ import { FileUpload } from './interfaces/file-upload.interface';
|
|
|
8
10
|
/**
|
|
9
11
|
* File resolver
|
|
10
12
|
*/
|
|
13
|
+
@Roles(RoleEnum.ADMIN)
|
|
11
14
|
@Resolver()
|
|
12
15
|
export class CoreFileResolver {
|
|
13
16
|
/**
|
|
@@ -22,6 +25,7 @@ export class CoreFileResolver {
|
|
|
22
25
|
/**
|
|
23
26
|
* Get file info
|
|
24
27
|
*/
|
|
28
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
25
29
|
@Query(() => CoreFileInfo, { nullable: true })
|
|
26
30
|
async getFileInfo(@Args({ name: 'filename', type: () => String }) filename: string): Promise<any> {
|
|
27
31
|
return await this.fileService.getFileInfoByName(filename);
|
|
@@ -34,6 +38,7 @@ export class CoreFileResolver {
|
|
|
34
38
|
/**
|
|
35
39
|
* Delete file
|
|
36
40
|
*/
|
|
41
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
37
42
|
@Mutation(() => CoreFileInfo)
|
|
38
43
|
async deleteFile(@Args({ name: 'filename', type: () => String }) filename: string): Promise<any> {
|
|
39
44
|
return await this.fileService.deleteFileByName(filename);
|
|
@@ -42,6 +47,7 @@ export class CoreFileResolver {
|
|
|
42
47
|
/**
|
|
43
48
|
* Upload file
|
|
44
49
|
*/
|
|
50
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
45
51
|
@Mutation(() => CoreFileInfo)
|
|
46
52
|
async uploadFile(@Args({ name: 'file', type: () => GraphQLUpload }) file: FileUpload): Promise<any> {
|
|
47
53
|
return await this.fileService.createFile(file);
|
|
@@ -50,6 +56,7 @@ export class CoreFileResolver {
|
|
|
50
56
|
/**
|
|
51
57
|
* Upload files
|
|
52
58
|
*/
|
|
59
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
53
60
|
@Mutation(() => [CoreFileInfo])
|
|
54
61
|
async uploadFiles(@Args({ name: 'files', type: () => [GraphQLUpload] }) files: FileUpload[]): Promise<any> {
|
|
55
62
|
return await this.fileService.createFiles(files);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Field, ObjectType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
|
+
import { Restricted } from '../../common/decorators/restricted.decorator';
|
|
4
|
+
import { RoleEnum } from '../../common/enums/role.enum';
|
|
3
5
|
import { CoreModel } from '../../common/models/core-model.model';
|
|
4
6
|
import { JSON } from '../../common/scalars/json.scalar';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* User model
|
|
8
10
|
*/
|
|
11
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
9
12
|
@ObjectType({ description: 'Health check result' })
|
|
10
13
|
export abstract class CoreHealthCheckResult extends CoreModel {
|
|
11
14
|
// ===================================================================================================================
|
|
@@ -15,12 +18,14 @@ export abstract class CoreHealthCheckResult extends CoreModel {
|
|
|
15
18
|
/**
|
|
16
19
|
* The overall status of the Health Check
|
|
17
20
|
*/
|
|
21
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
18
22
|
@Field({ description: 'The overall status of the Health Check', nullable: false })
|
|
19
23
|
status: 'error' | 'ok' | 'shutting_down' = undefined;
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* The info object contains information of each health indicator which is of status “up”
|
|
23
27
|
*/
|
|
28
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
24
29
|
@Field(type => JSON, {
|
|
25
30
|
description: 'The info object contains information of each health indicator which is of status “up”',
|
|
26
31
|
nullable: true,
|
|
@@ -30,6 +35,7 @@ export abstract class CoreHealthCheckResult extends CoreModel {
|
|
|
30
35
|
/**
|
|
31
36
|
* The error object contains information of each health indicator which is of status “down”
|
|
32
37
|
*/
|
|
38
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
33
39
|
@Field(type => JSON, {
|
|
34
40
|
description: 'The error object contains information of each health indicator which is of status “down”',
|
|
35
41
|
nullable: true,
|
|
@@ -39,6 +45,7 @@ export abstract class CoreHealthCheckResult extends CoreModel {
|
|
|
39
45
|
/**
|
|
40
46
|
* The details object contains information of every health indicator
|
|
41
47
|
*/
|
|
48
|
+
@Restricted(RoleEnum.S_EVERYONE)
|
|
42
49
|
@Field(type => JSON, {
|
|
43
50
|
description: 'The details object contains information of every health indicator',
|
|
44
51
|
nullable: false,
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Controller, Get } from '@nestjs/common';
|
|
2
2
|
|
|
3
|
+
import { Roles } from '../../common/decorators/roles.decorator';
|
|
4
|
+
import { RoleEnum } from '../../common/enums/role.enum';
|
|
3
5
|
import { CoreHealthCheckService } from './core-health-check.service';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* The HealthController class checks the health of various components including the database, memory, and disk.
|
|
7
9
|
* Inspired by https://mobileappcircular.com/marketplace-backend-creating-a-health-check-endpoint-in-nestjs-app-using-terminus-25727e96c7d2
|
|
8
10
|
*/
|
|
11
|
+
@Roles(RoleEnum.ADMIN)
|
|
9
12
|
@Controller()
|
|
10
13
|
export class CoreHealthCheckController {
|
|
11
14
|
constructor(protected readonly healthCheckService: CoreHealthCheckService) {}
|
|
@@ -18,6 +21,7 @@ export class CoreHealthCheckController {
|
|
|
18
21
|
* storage. The `healthCheck()` method will return a Promise that resolves with an array of objects
|
|
19
22
|
* representing the results of each check
|
|
20
23
|
*/
|
|
24
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
21
25
|
@Get('health-check')
|
|
22
26
|
async healthCheck() {
|
|
23
27
|
return this.healthCheckService.healthCheck();
|