@lenne.tech/nest-server 10.2.6 → 10.2.8

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.
Files changed (327) hide show
  1. package/dist/config.env.js +75 -75
  2. package/dist/config.env.js.map +1 -1
  3. package/dist/core/common/args/filter.args.js +1 -1
  4. package/dist/core/common/args/filter.args.js.map +1 -1
  5. package/dist/core/common/args/pagination.args.js.map +1 -1
  6. package/dist/core/common/decorators/current-user.decorator.js.map +1 -1
  7. package/dist/core/common/decorators/graphql-populate.decorator.js.map +1 -1
  8. package/dist/core/common/decorators/graphql-service-options.decorator.js.map +1 -1
  9. package/dist/core/common/decorators/restricted.decorator.d.ts +4 -4
  10. package/dist/core/common/decorators/restricted.decorator.js +2 -2
  11. package/dist/core/common/decorators/restricted.decorator.js.map +1 -1
  12. package/dist/core/common/enums/comparison-operator.enum.js +1 -1
  13. package/dist/core/common/enums/comparison-operator.enum.js.map +1 -1
  14. package/dist/core/common/enums/logical-operator.enum.js +1 -1
  15. package/dist/core/common/enums/logical-operator.enum.js.map +1 -1
  16. package/dist/core/common/enums/role.enum.d.ts +3 -3
  17. package/dist/core/common/enums/role.enum.js +2 -2
  18. package/dist/core/common/enums/role.enum.js.map +1 -1
  19. package/dist/core/common/enums/sort-order.emum.js +1 -1
  20. package/dist/core/common/enums/sort-order.emum.js.map +1 -1
  21. package/dist/core/common/filters/http-exception-log.filter.js.map +1 -1
  22. package/dist/core/common/helpers/config.helper.js.map +1 -1
  23. package/dist/core/common/helpers/context.helper.js +1 -1
  24. package/dist/core/common/helpers/context.helper.js.map +1 -1
  25. package/dist/core/common/helpers/db.helper.d.ts +28 -4
  26. package/dist/core/common/helpers/db.helper.js +4 -4
  27. package/dist/core/common/helpers/db.helper.js.map +1 -1
  28. package/dist/core/common/helpers/decorator.helper.d.ts +24 -0
  29. package/dist/core/common/helpers/decorator.helper.js.map +1 -1
  30. package/dist/core/common/helpers/file.helper.js +1 -1
  31. package/dist/core/common/helpers/file.helper.js.map +1 -1
  32. package/dist/core/common/helpers/filter.helper.d.ts +26 -2
  33. package/dist/core/common/helpers/filter.helper.js +3 -3
  34. package/dist/core/common/helpers/filter.helper.js.map +1 -1
  35. package/dist/core/common/helpers/graphql.helper.d.ts +2 -2
  36. package/dist/core/common/helpers/graphql.helper.js +1 -1
  37. package/dist/core/common/helpers/graphql.helper.js.map +1 -1
  38. package/dist/core/common/helpers/input.helper.d.ts +3 -3
  39. package/dist/core/common/helpers/input.helper.js +5 -5
  40. package/dist/core/common/helpers/input.helper.js.map +1 -1
  41. package/dist/core/common/helpers/model.helper.d.ts +2 -2
  42. package/dist/core/common/helpers/model.helper.js +3 -3
  43. package/dist/core/common/helpers/model.helper.js.map +1 -1
  44. package/dist/core/common/helpers/service.helper.d.ts +6 -6
  45. package/dist/core/common/helpers/service.helper.js +5 -5
  46. package/dist/core/common/helpers/service.helper.js.map +1 -1
  47. package/dist/core/common/helpers/table.helper.d.ts +9 -0
  48. package/dist/core/common/helpers/table.helper.js +28 -0
  49. package/dist/core/common/helpers/table.helper.js.map +1 -0
  50. package/dist/core/common/inputs/combined-filter.input.js.map +1 -1
  51. package/dist/core/common/inputs/filter.input.js.map +1 -1
  52. package/dist/core/common/inputs/single-filter.input.js.map +1 -1
  53. package/dist/core/common/inputs/sort.input.js.map +1 -1
  54. package/dist/core/common/interceptors/check-response.interceptor.js.map +1 -1
  55. package/dist/core/common/interceptors/check-security.interceptor.js.map +1 -1
  56. package/dist/core/common/interfaces/core-persistence-model.interface.d.ts +3 -3
  57. package/dist/core/common/interfaces/mailjet-options.interface.d.ts +1 -1
  58. package/dist/core/common/interfaces/prepare-input-options.interface.d.ts +1 -1
  59. package/dist/core/common/interfaces/server-options.interface.d.ts +15 -7
  60. package/dist/core/common/interfaces/service-options.interface.d.ts +31 -5
  61. package/dist/core/common/models/core-model.model.js.map +1 -1
  62. package/dist/core/common/models/core-persistence.model.d.ts +24 -0
  63. package/dist/core/common/models/core-persistence.model.js.map +1 -1
  64. package/dist/core/common/pipes/check-input.pipe.js.map +1 -1
  65. package/dist/core/common/pipes/map-and-validate.pipe.js.map +1 -1
  66. package/dist/core/common/plugins/complexity.plugin.js +4 -4
  67. package/dist/core/common/plugins/complexity.plugin.js.map +1 -1
  68. package/dist/core/common/plugins/mongoose-id.plugin.js.map +1 -1
  69. package/dist/core/common/scalars/any.scalar.js.map +1 -1
  70. package/dist/core/common/scalars/date-timestamp.scalar.js.map +1 -1
  71. package/dist/core/common/scalars/date.scalar.js.map +1 -1
  72. package/dist/core/common/scalars/json.scalar.js.map +1 -1
  73. package/dist/core/common/services/brevo.service.d.ts +10 -0
  74. package/dist/core/common/services/brevo.service.js +75 -0
  75. package/dist/core/common/services/brevo.service.js.map +1 -0
  76. package/dist/core/common/services/config.service.js +1 -1
  77. package/dist/core/common/services/config.service.js.map +1 -1
  78. package/dist/core/common/services/core-cron-jobs.service.d.ts +2 -2
  79. package/dist/core/common/services/core-cron-jobs.service.js.map +1 -1
  80. package/dist/core/common/services/crud.service.d.ts +63 -32
  81. package/dist/core/common/services/crud.service.js +59 -21
  82. package/dist/core/common/services/crud.service.js.map +1 -1
  83. package/dist/core/common/services/email.service.js +5 -5
  84. package/dist/core/common/services/email.service.js.map +1 -1
  85. package/dist/core/common/services/mailjet.service.d.ts +4 -4
  86. package/dist/core/common/services/mailjet.service.js +8 -8
  87. package/dist/core/common/services/mailjet.service.js.map +1 -1
  88. package/dist/core/common/services/model-doc.service.d.ts +24 -0
  89. package/dist/core/common/services/model-doc.service.js +1 -1
  90. package/dist/core/common/services/model-doc.service.js.map +1 -1
  91. package/dist/core/common/services/module.service.d.ts +28 -4
  92. package/dist/core/common/services/module.service.js +23 -7
  93. package/dist/core/common/services/module.service.js.map +1 -1
  94. package/dist/core/common/services/template.service.js +3 -3
  95. package/dist/core/common/services/template.service.js.map +1 -1
  96. package/dist/core/common/types/core-model-constructor.type.d.ts +1 -1
  97. package/dist/core/common/types/falsy.type.d.ts +1 -1
  98. package/dist/core/common/types/field-selection.type.d.ts +25 -1
  99. package/dist/core/common/types/ids.type.d.ts +31 -7
  100. package/dist/core/common/types/maybe-promise.type.d.ts +1 -1
  101. package/dist/core/common/types/plain-input.type.d.ts +1 -1
  102. package/dist/core/common/types/populate-config.type.d.ts +25 -1
  103. package/dist/core/common/types/string-or-object-id.type.d.ts +25 -1
  104. package/dist/core/modules/auth/core-auth.controller.js +1 -1
  105. package/dist/core/modules/auth/core-auth.controller.js.map +1 -1
  106. package/dist/core/modules/auth/core-auth.model.js.map +1 -1
  107. package/dist/core/modules/auth/core-auth.module.d.ts +5 -5
  108. package/dist/core/modules/auth/core-auth.module.js +5 -5
  109. package/dist/core/modules/auth/core-auth.module.js.map +1 -1
  110. package/dist/core/modules/auth/core-auth.resolver.js +1 -1
  111. package/dist/core/modules/auth/core-auth.resolver.js.map +1 -1
  112. package/dist/core/modules/auth/guards/auth.guard.d.ts +1 -1
  113. package/dist/core/modules/auth/guards/auth.guard.js +1 -1
  114. package/dist/core/modules/auth/guards/auth.guard.js.map +1 -1
  115. package/dist/core/modules/auth/guards/refresh-token.guard.js.map +1 -1
  116. package/dist/core/modules/auth/guards/roles.guard.js.map +1 -1
  117. package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js.map +1 -1
  118. package/dist/core/modules/auth/inputs/core-auth-sign-up.input.js.map +1 -1
  119. package/dist/core/modules/auth/interfaces/core-auth-user.interface.d.ts +1 -1
  120. package/dist/core/modules/auth/interfaces/core-token-data.interface.d.ts +1 -1
  121. package/dist/core/modules/auth/interfaces/jwt-payload.interface.d.ts +1 -1
  122. package/dist/core/modules/auth/services/core-auth.service.d.ts +1 -1
  123. package/dist/core/modules/auth/services/core-auth.service.js +10 -10
  124. package/dist/core/modules/auth/services/core-auth.service.js.map +1 -1
  125. package/dist/core/modules/auth/strategies/jwt-refresh.strategy.js +1 -1
  126. package/dist/core/modules/auth/strategies/jwt-refresh.strategy.js.map +1 -1
  127. package/dist/core/modules/auth/strategies/jwt.strategy.js.map +1 -1
  128. package/dist/core/modules/auth/tokens.decorator.js +1 -1
  129. package/dist/core/modules/auth/tokens.decorator.js.map +1 -1
  130. package/dist/core/modules/file/core-file-info.model.d.ts +24 -0
  131. package/dist/core/modules/file/core-file-info.model.js +5 -5
  132. package/dist/core/modules/file/core-file-info.model.js.map +1 -1
  133. package/dist/core/modules/file/core-file.controller.js.map +1 -1
  134. package/dist/core/modules/file/core-file.resolver.js +1 -1
  135. package/dist/core/modules/file/core-file.resolver.js.map +1 -1
  136. package/dist/core/modules/file/core-file.service.d.ts +30 -6
  137. package/dist/core/modules/file/core-file.service.js +3 -3
  138. package/dist/core/modules/file/core-file.service.js.map +1 -1
  139. package/dist/core/modules/file/interfaces/file-service-options.interface.d.ts +1 -1
  140. package/dist/core/modules/file/interfaces/file-upload.interface.d.ts +2 -2
  141. package/dist/core/modules/health-check/core-health-check-result.model.js.map +1 -1
  142. package/dist/core/modules/health-check/core-health-check.controller.js.map +1 -1
  143. package/dist/core/modules/health-check/core-health-check.module.js +1 -1
  144. package/dist/core/modules/health-check/core-health-check.module.js.map +1 -1
  145. package/dist/core/modules/health-check/core-health-check.resolver.js +2 -2
  146. package/dist/core/modules/health-check/core-health-check.resolver.js.map +1 -1
  147. package/dist/core/modules/health-check/core-health-check.service.js +1 -1
  148. package/dist/core/modules/health-check/core-health-check.service.js.map +1 -1
  149. package/dist/core/modules/user/core-user.model.d.ts +24 -0
  150. package/dist/core/modules/user/core-user.model.js +1 -1
  151. package/dist/core/modules/user/core-user.model.js.map +1 -1
  152. package/dist/core/modules/user/core-user.service.d.ts +25 -1
  153. package/dist/core/modules/user/core-user.service.js +3 -3
  154. package/dist/core/modules/user/core-user.service.js.map +1 -1
  155. package/dist/core/modules/user/inputs/core-user-create.input.js +1 -1
  156. package/dist/core/modules/user/inputs/core-user-create.input.js.map +1 -1
  157. package/dist/core/modules/user/inputs/core-user.input.js +1 -1
  158. package/dist/core/modules/user/inputs/core-user.input.js.map +1 -1
  159. package/dist/core.module.js +20 -20
  160. package/dist/core.module.js.map +1 -1
  161. package/dist/index.d.ts +2 -0
  162. package/dist/index.js +2 -0
  163. package/dist/index.js.map +1 -1
  164. package/dist/main.js +3 -3
  165. package/dist/main.js.map +1 -1
  166. package/dist/server/common/models/persistence.model.d.ts +24 -0
  167. package/dist/server/common/models/persistence.model.js +4 -4
  168. package/dist/server/common/models/persistence.model.js.map +1 -1
  169. package/dist/server/common/services/cron-jobs.service.js.map +1 -1
  170. package/dist/server/modules/auth/auth.controller.js.map +1 -1
  171. package/dist/server/modules/auth/auth.model.js.map +1 -1
  172. package/dist/server/modules/auth/auth.module.js +2 -2
  173. package/dist/server/modules/auth/auth.module.js.map +1 -1
  174. package/dist/server/modules/auth/auth.resolver.js.map +1 -1
  175. package/dist/server/modules/auth/auth.service.js +1 -1
  176. package/dist/server/modules/auth/auth.service.js.map +1 -1
  177. package/dist/server/modules/auth/inputs/auth-sign-in.input.js.map +1 -1
  178. package/dist/server/modules/auth/inputs/auth-sign-up.input.js.map +1 -1
  179. package/dist/server/modules/file/file-info.model.js.map +1 -1
  180. package/dist/server/modules/file/file.controller.js.map +1 -1
  181. package/dist/server/modules/file/file.module.js +2 -2
  182. package/dist/server/modules/file/file.module.js.map +1 -1
  183. package/dist/server/modules/file/file.resolver.js +5 -5
  184. package/dist/server/modules/file/file.resolver.js.map +1 -1
  185. package/dist/server/modules/file/file.service.d.ts +24 -0
  186. package/dist/server/modules/file/file.service.js.map +1 -1
  187. package/dist/server/modules/file/multer-config.service.js +2 -2
  188. package/dist/server/modules/file/multer-config.service.js.map +1 -1
  189. package/dist/server/modules/user/avatar.controller.js.map +1 -1
  190. package/dist/server/modules/user/inputs/user-create.input.js.map +1 -1
  191. package/dist/server/modules/user/inputs/user.input.js.map +1 -1
  192. package/dist/server/modules/user/outputs/find-and-count-users-result.output.js.map +1 -1
  193. package/dist/server/modules/user/user.model.js +2 -2
  194. package/dist/server/modules/user/user.model.js.map +1 -1
  195. package/dist/server/modules/user/user.module.js +2 -2
  196. package/dist/server/modules/user/user.module.js.map +1 -1
  197. package/dist/server/modules/user/user.resolver.d.ts +1 -1
  198. package/dist/server/modules/user/user.resolver.js +1 -1
  199. package/dist/server/modules/user/user.resolver.js.map +1 -1
  200. package/dist/server/modules/user/user.service.d.ts +25 -1
  201. package/dist/server/modules/user/user.service.js +2 -2
  202. package/dist/server/modules/user/user.service.js.map +1 -1
  203. package/dist/server/server.controller.js.map +1 -1
  204. package/dist/server/server.module.js +2 -2
  205. package/dist/server/server.module.js.map +1 -1
  206. package/dist/test/test.helper.d.ts +13 -13
  207. package/dist/test/test.helper.js +15 -15
  208. package/dist/test/test.helper.js.map +1 -1
  209. package/dist/tsconfig.build.tsbuildinfo +1 -1
  210. package/package.json +35 -34
  211. package/src/config.env.ts +79 -78
  212. package/src/core/common/args/filter.args.ts +2 -1
  213. package/src/core/common/args/pagination.args.ts +1 -0
  214. package/src/core/common/decorators/current-user.decorator.ts +1 -0
  215. package/src/core/common/decorators/graphql-populate.decorator.ts +1 -0
  216. package/src/core/common/decorators/graphql-service-options.decorator.ts +1 -0
  217. package/src/core/common/decorators/restricted.decorator.ts +7 -5
  218. package/src/core/common/enums/comparison-operator.enum.ts +1 -1
  219. package/src/core/common/enums/logical-operator.enum.ts +1 -1
  220. package/src/core/common/enums/role.enum.ts +6 -6
  221. package/src/core/common/enums/sort-order.emum.ts +1 -1
  222. package/src/core/common/helpers/context.helper.ts +1 -1
  223. package/src/core/common/helpers/db.helper.ts +14 -12
  224. package/src/core/common/helpers/decorator.helper.ts +1 -0
  225. package/src/core/common/helpers/file.helper.ts +1 -1
  226. package/src/core/common/helpers/filter.helper.ts +6 -5
  227. package/src/core/common/helpers/graphql.helper.ts +7 -6
  228. package/src/core/common/helpers/input.helper.ts +10 -8
  229. package/src/core/common/helpers/model.helper.ts +6 -5
  230. package/src/core/common/helpers/service.helper.ts +13 -11
  231. package/src/core/common/helpers/table.helper.ts +37 -0
  232. package/src/core/common/inputs/combined-filter.input.ts +1 -0
  233. package/src/core/common/inputs/filter.input.ts +1 -0
  234. package/src/core/common/inputs/single-filter.input.ts +1 -0
  235. package/src/core/common/inputs/sort.input.ts +1 -0
  236. package/src/core/common/interceptors/check-response.interceptor.ts +1 -0
  237. package/src/core/common/interceptors/check-security.interceptor.ts +1 -0
  238. package/src/core/common/interfaces/core-persistence-model.interface.ts +3 -3
  239. package/src/core/common/interfaces/cron-job-config-with-time-zone.interface.ts +1 -0
  240. package/src/core/common/interfaces/cron-job-config-with-utc-offset.interface.ts +1 -0
  241. package/src/core/common/interfaces/mailjet-options.interface.ts +1 -1
  242. package/src/core/common/interfaces/prepare-input-options.interface.ts +1 -1
  243. package/src/core/common/interfaces/server-options.interface.ts +49 -23
  244. package/src/core/common/interfaces/service-options.interface.ts +31 -16
  245. package/src/core/common/models/core-persistence.model.ts +1 -0
  246. package/src/core/common/pipes/check-input.pipe.ts +1 -0
  247. package/src/core/common/pipes/map-and-validate.pipe.ts +1 -0
  248. package/src/core/common/plugins/complexity.plugin.ts +5 -4
  249. package/src/core/common/scalars/date-timestamp.scalar.ts +1 -0
  250. package/src/core/common/scalars/date.scalar.ts +1 -0
  251. package/src/core/common/services/brevo.service.ts +93 -0
  252. package/src/core/common/services/config.service.ts +3 -1
  253. package/src/core/common/services/core-cron-jobs.service.ts +3 -2
  254. package/src/core/common/services/crud.service.ts +113 -41
  255. package/src/core/common/services/email.service.ts +7 -5
  256. package/src/core/common/services/mailjet.service.ts +14 -13
  257. package/src/core/common/services/model-doc.service.ts +2 -1
  258. package/src/core/common/services/module.service.ts +33 -13
  259. package/src/core/common/services/template.service.ts +5 -3
  260. package/src/core/common/types/core-model-constructor.type.ts +1 -1
  261. package/src/core/common/types/falsy.type.ts +1 -1
  262. package/src/core/common/types/field-selection.type.ts +4 -3
  263. package/src/core/common/types/ids.type.ts +3 -3
  264. package/src/core/common/types/maybe-promise.type.ts +1 -1
  265. package/src/core/common/types/plain-input.type.ts +1 -1
  266. package/src/core/common/types/populate-config.type.ts +1 -1
  267. package/src/core/common/types/string-or-object-id.type.ts +1 -1
  268. package/src/core/modules/auth/core-auth.controller.ts +2 -1
  269. package/src/core/modules/auth/core-auth.model.ts +1 -0
  270. package/src/core/modules/auth/core-auth.module.ts +8 -7
  271. package/src/core/modules/auth/core-auth.resolver.ts +2 -1
  272. package/src/core/modules/auth/guards/auth.guard.ts +4 -2
  273. package/src/core/modules/auth/guards/refresh-token.guard.ts +1 -0
  274. package/src/core/modules/auth/guards/roles.guard.ts +1 -0
  275. package/src/core/modules/auth/inputs/core-auth-sign-in.input.ts +1 -0
  276. package/src/core/modules/auth/inputs/core-auth-sign-up.input.ts +1 -0
  277. package/src/core/modules/auth/interfaces/core-auth-user.interface.ts +4 -4
  278. package/src/core/modules/auth/interfaces/core-token-data.interface.ts +4 -4
  279. package/src/core/modules/auth/interfaces/jwt-payload.interface.ts +1 -1
  280. package/src/core/modules/auth/services/core-auth.service.ts +13 -11
  281. package/src/core/modules/auth/strategies/jwt-refresh.strategy.ts +3 -2
  282. package/src/core/modules/auth/strategies/jwt.strategy.ts +3 -2
  283. package/src/core/modules/auth/tokens.decorator.ts +4 -3
  284. package/src/core/modules/file/core-file-info.model.ts +6 -5
  285. package/src/core/modules/file/core-file.controller.ts +1 -0
  286. package/src/core/modules/file/core-file.resolver.ts +2 -1
  287. package/src/core/modules/file/core-file.service.ts +9 -8
  288. package/src/core/modules/file/interfaces/file-service-options.interface.ts +1 -1
  289. package/src/core/modules/file/interfaces/file-upload.interface.ts +2 -2
  290. package/src/core/modules/health-check/core-health-check-result.model.ts +1 -0
  291. package/src/core/modules/health-check/core-health-check.controller.ts +1 -0
  292. package/src/core/modules/health-check/core-health-check.module.ts +2 -1
  293. package/src/core/modules/health-check/core-health-check.resolver.ts +3 -2
  294. package/src/core/modules/health-check/core-health-check.service.ts +2 -1
  295. package/src/core/modules/user/core-user.model.ts +2 -1
  296. package/src/core/modules/user/core-user.service.ts +6 -4
  297. package/src/core/modules/user/inputs/core-user-create.input.ts +2 -1
  298. package/src/core/modules/user/inputs/core-user.input.ts +2 -1
  299. package/src/core.module.ts +24 -22
  300. package/src/index.ts +2 -0
  301. package/src/main.ts +5 -3
  302. package/src/server/common/models/persistence.model.ts +7 -5
  303. package/src/server/common/services/cron-jobs.service.ts +1 -0
  304. package/src/server/modules/auth/auth.controller.ts +1 -0
  305. package/src/server/modules/auth/auth.model.ts +1 -0
  306. package/src/server/modules/auth/auth.module.ts +3 -2
  307. package/src/server/modules/auth/auth.resolver.ts +1 -0
  308. package/src/server/modules/auth/auth.service.ts +2 -1
  309. package/src/server/modules/auth/inputs/auth-sign-in.input.ts +1 -0
  310. package/src/server/modules/auth/inputs/auth-sign-up.input.ts +1 -0
  311. package/src/server/modules/file/file-info.model.ts +1 -0
  312. package/src/server/modules/file/file.controller.ts +1 -0
  313. package/src/server/modules/file/file.module.ts +3 -2
  314. package/src/server/modules/file/file.resolver.ts +7 -5
  315. package/src/server/modules/file/file.service.ts +1 -0
  316. package/src/server/modules/file/multer-config.service.ts +3 -2
  317. package/src/server/modules/user/avatar.controller.ts +1 -0
  318. package/src/server/modules/user/inputs/user-create.input.ts +1 -0
  319. package/src/server/modules/user/inputs/user.input.ts +1 -0
  320. package/src/server/modules/user/outputs/find-and-count-users-result.output.ts +1 -0
  321. package/src/server/modules/user/user.model.ts +3 -2
  322. package/src/server/modules/user/user.module.ts +3 -2
  323. package/src/server/modules/user/user.resolver.ts +2 -1
  324. package/src/server/modules/user/user.service.ts +5 -3
  325. package/src/server/server.controller.ts +1 -0
  326. package/src/server/server.module.ts +7 -6
  327. package/src/test/test.helper.ts +28 -26
@@ -1,7 +1,7 @@
1
1
  import { Types } from 'mongoose';
2
2
 
3
3
  export type IdsType =
4
- | string
4
+ | ({ _id?: Types.ObjectId | string; id?: Types.ObjectId | string } | Types.ObjectId | string)[]
5
+ | { _id?: Types.ObjectId | string; id?: Types.ObjectId | string }
5
6
  | Types.ObjectId
6
- | { id?: string | Types.ObjectId; _id?: string | Types.ObjectId }
7
- | (string | Types.ObjectId | { id?: string | Types.ObjectId; _id?: string | Types.ObjectId })[];
7
+ | string;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Promise or direct value
3
3
  */
4
- export type MaybePromise<T = any> = T | Promise<T>;
4
+ export type MaybePromise<T = any> = Promise<T> | T;
@@ -2,5 +2,5 @@
2
2
  * Type for plain inputs with only optional properties
3
3
  */
4
4
  export type PlainInput<T> = {
5
- [P in keyof T]?: Partial<T[P]> | Partial<PlainInput<T[P]>>;
5
+ [P in keyof T]?: Partial<PlainInput<T[P]>> | Partial<T[P]>;
6
6
  };
@@ -3,4 +3,4 @@ import { PopulateOptions } from 'mongoose';
3
3
  /**
4
4
  * Configuration (path or options) for Mongoose populate methode
5
5
  */
6
- export type PopulateConfig = string | string[] | PopulateOptions | (PopulateOptions | string)[];
6
+ export type PopulateConfig = (PopulateOptions | string)[] | PopulateOptions | string | string[];
@@ -3,4 +3,4 @@ import { Types } from 'mongoose';
3
3
  /**
4
4
  * Everything which will be used by getStringIds or getObjectIds (see helpers/db.helper.ts)
5
5
  */
6
- export type StringOrObjectId<T = any> = string | Types.ObjectId | T;
6
+ export type StringOrObjectId<T = any> = T | Types.ObjectId | string;
@@ -1,6 +1,7 @@
1
1
  import { Body, Controller, Get, Param, ParseBoolPipe, Post, Res, UseGuards } from '@nestjs/common';
2
2
  import { Args } from '@nestjs/graphql';
3
3
  import { Response as ResponseType } from 'express';
4
+
4
5
  import { CurrentUser } from '../../common/decorators/current-user.decorator';
5
6
  import { ConfigService } from '../../common/services/config.service';
6
7
  import { AuthGuardStrategy } from './auth-guard-strategy.enum';
@@ -30,7 +31,7 @@ export class CoreAuthController {
30
31
  @Res() res: ResponseType,
31
32
  @Param('allDevices', ParseBoolPipe) allDevices?: boolean,
32
33
  ): Promise<boolean> {
33
- const result = await this.authService.logout(token, { currentUser, allDevices });
34
+ const result = await this.authService.logout(token, { allDevices, currentUser });
34
35
  return this.processCookies(res, result);
35
36
  }
36
37
 
@@ -1,4 +1,5 @@
1
1
  import { Field, ObjectType } from '@nestjs/graphql';
2
+
2
3
  import { CoreModel } from '../../common/models/core-model.model';
3
4
  import { CoreUserModel } from '../user/core-user.model';
4
5
 
@@ -3,12 +3,13 @@ import { APP_GUARD } from '@nestjs/core';
3
3
  import { JwtModule, JwtModuleOptions } from '@nestjs/jwt';
4
4
  import { PassportModule } from '@nestjs/passport';
5
5
  import { PubSub } from 'graphql-subscriptions';
6
+
6
7
  import { AuthGuardStrategy } from './auth-guard-strategy.enum';
7
8
  import { RolesGuard } from './guards/roles.guard';
8
- import { JwtRefreshStrategy } from './strategies/jwt-refresh.strategy';
9
- import { JwtStrategy } from './strategies/jwt.strategy';
10
- import { CoreAuthUserService } from './services/core-auth-user.service';
11
9
  import { CoreAuthService } from './services/core-auth.service';
10
+ import { CoreAuthUserService } from './services/core-auth-user.service';
11
+ import { JwtStrategy } from './strategies/jwt.strategy';
12
+ import { JwtRefreshStrategy } from './strategies/jwt-refresh.strategy';
12
13
 
13
14
  /**
14
15
  * CoreAuthModule to handle user authentication and enables Roles
@@ -24,9 +25,9 @@ export class CoreAuthModule {
24
25
  UserService: Type<CoreAuthUserService>,
25
26
  options: JwtModuleOptions & {
26
27
  authService?: Type<CoreAuthService>;
27
- jwtStrategy?: Type<JwtStrategy>;
28
+ imports?: Array<DynamicModule | ForwardReference | Promise<DynamicModule> | Type<any>>;
28
29
  jwtRefreshStrategy?: Type<JwtRefreshStrategy>;
29
- imports?: Array<Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
30
+ jwtStrategy?: Type<JwtStrategy>;
30
31
  providers?: Provider[];
31
32
  },
32
33
  ): DynamicModule {
@@ -74,10 +75,10 @@ export class CoreAuthModule {
74
75
 
75
76
  // Return CoreAuthModule
76
77
  return {
77
- module: CoreAuthModule,
78
+ exports: [CoreAuthService, JwtModule, JwtStrategy, JwtRefreshStrategy, PassportModule, UserModule],
78
79
  imports,
80
+ module: CoreAuthModule,
79
81
  providers,
80
- exports: [CoreAuthService, JwtModule, JwtStrategy, JwtRefreshStrategy, PassportModule, UserModule],
81
82
  };
82
83
  }
83
84
  }
@@ -1,6 +1,7 @@
1
1
  import { UseGuards } from '@nestjs/common';
2
2
  import { Args, Context, Mutation, Resolver } from '@nestjs/graphql';
3
3
  import { Response as ResponseType } from 'express';
4
+
4
5
  import { CurrentUser } from '../../common/decorators/current-user.decorator';
5
6
  import { GraphQLServiceOptions } from '../../common/decorators/graphql-service-options.decorator';
6
7
  import { ServiceOptions } from '../../common/interfaces/service-options.interface';
@@ -39,7 +40,7 @@ export class CoreAuthResolver {
39
40
  @Tokens('token') token: string,
40
41
  @Args('allDevices', { nullable: true }) allDevices?: boolean,
41
42
  ): Promise<boolean> {
42
- const result = await this.authService.logout(token, { currentUser, allDevices });
43
+ const result = await this.authService.logout(token, { allDevices, currentUser });
43
44
  return this.processCookies(ctx, result);
44
45
  }
45
46
 
@@ -3,12 +3,14 @@ import { GqlExecutionContext } from '@nestjs/graphql';
3
3
  import { AuthModuleOptions, Type } from '@nestjs/passport';
4
4
  import { defaultOptions } from '@nestjs/passport/dist/options';
5
5
  import { memoize } from '@nestjs/passport/dist/utils/memoize.util';
6
- import passport = require('passport');
6
+
7
7
  import { AuthGuardStrategy } from '../auth-guard-strategy.enum';
8
8
  import { ExpiredRefreshTokenException } from '../exceptions/expired-refresh-token.exception';
9
9
  import { ExpiredTokenException } from '../exceptions/expired-token.exception';
10
10
  import { InvalidTokenException } from '../exceptions/invalid-token.exception';
11
11
 
12
+ import passport = require('passport');
13
+
12
14
  /**
13
15
  * Missing strategy error
14
16
  */
@@ -132,4 +134,4 @@ function createAuthGuard(type?: string): Type<CanActivate> {
132
134
  /**
133
135
  * Export AuthGuard
134
136
  */
135
- export const AuthGuard: (type?: string | string[] | AuthGuardStrategy) => Type<IAuthGuard> = memoize(createAuthGuard);
137
+ export const AuthGuard: (type?: AuthGuardStrategy | string | string[]) => Type<IAuthGuard> = memoize(createAuthGuard);
@@ -1,4 +1,5 @@
1
1
  import { Injectable } from '@nestjs/common';
2
+
2
3
  import { AuthGuard } from './auth.guard';
3
4
 
4
5
  @Injectable()
@@ -1,6 +1,7 @@
1
1
  import { ExecutionContext, Injectable, UnauthorizedException } from '@nestjs/common';
2
2
  import { Reflector } from '@nestjs/core';
3
3
  import { GqlExecutionContext } from '@nestjs/graphql';
4
+
4
5
  import { RoleEnum } from '../../../common/enums/role.enum';
5
6
  import { AuthGuardStrategy } from '../auth-guard-strategy.enum';
6
7
  import { ExpiredTokenException } from '../exceptions/expired-token.exception';
@@ -1,4 +1,5 @@
1
1
  import { Field, InputType } from '@nestjs/graphql';
2
+
2
3
  import { CoreInput } from '../../../common/inputs/core-input.input';
3
4
 
4
5
  /**
@@ -1,4 +1,5 @@
1
1
  import { InputType } from '@nestjs/graphql';
2
+
2
3
  import { CoreAuthSignInInput } from './core-auth-sign-in.input';
3
4
 
4
5
  /**
@@ -5,14 +5,14 @@ import { CoreTokenData } from './core-token-data.interface';
5
5
  */
6
6
  export interface ICoreAuthUser {
7
7
  /**
8
- * ID of the user
8
+ * Email of the user
9
9
  */
10
- id: string;
10
+ email: string;
11
11
 
12
12
  /**
13
- * Email of the user
13
+ * ID of the user
14
14
  */
15
- email: string;
15
+ id: string;
16
16
 
17
17
  /**
18
18
  * Password of the user
@@ -3,14 +3,14 @@
3
3
  */
4
4
  export interface CoreTokenData {
5
5
  /**
6
- * ID of the device from which the token was generated
6
+ * Description of the device from which the token was generated
7
7
  */
8
- deviceId?: string;
8
+ deviceDescription?: string;
9
9
 
10
10
  /**
11
- * Description of the device from which the token was generated
11
+ * ID of the device from which the token was generated
12
12
  */
13
- deviceDescription?: string;
13
+ deviceId?: string;
14
14
 
15
15
  /**
16
16
  * Token ID to make sure that there is only one RefreshToken for each device
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export interface JwtPayload {
5
5
  [key: string]: any;
6
- id: string;
7
6
  deviceId: string;
7
+ id: string;
8
8
  tokenId: string;
9
9
  }
@@ -1,8 +1,8 @@
1
- import { randomUUID } from 'crypto';
2
1
  import { BadRequestException, Injectable, UnauthorizedException } from '@nestjs/common';
3
2
  import { JwtService } from '@nestjs/jwt';
4
- import bcrypt = require('bcrypt');
3
+ import { randomUUID } from 'crypto';
5
4
  import { sha256 } from 'js-sha256';
5
+
6
6
  import { getStringIds } from '../../../common/helpers/db.helper';
7
7
  import { prepareServiceOptions } from '../../../common/helpers/service.helper';
8
8
  import { ServiceOptions } from '../../../common/interfaces/service-options.interface';
@@ -14,6 +14,8 @@ import { ICoreAuthUser } from '../interfaces/core-auth-user.interface';
14
14
  import { JwtPayload } from '../interfaces/jwt-payload.interface';
15
15
  import { CoreAuthUserService } from './core-auth-user.service';
16
16
 
17
+ import bcrypt = require('bcrypt');
18
+
17
19
  /**
18
20
  * CoreAuthService to handle user authentication
19
21
  */
@@ -72,8 +74,8 @@ export class CoreAuthService {
72
74
  */
73
75
  async refreshTokens(user: ICoreAuthUser, currentRefreshToken: string) {
74
76
  // Create new tokens
75
- const { deviceId, deviceDescription } = this.decodeJwt(currentRefreshToken);
76
- const tokens = await this.createTokens(user.id, { deviceId, deviceDescription });
77
+ const { deviceDescription, deviceId } = this.decodeJwt(currentRefreshToken);
78
+ const tokens = await this.createTokens(user.id, { deviceDescription, deviceId });
77
79
  tokens.refreshToken = await this.updateRefreshToken(user, currentRefreshToken, tokens.refreshToken);
78
80
 
79
81
  // Return
@@ -97,7 +99,7 @@ export class CoreAuthService {
97
99
  });
98
100
 
99
101
  // Inputs
100
- const { email, password, deviceId, deviceDescription } = input;
102
+ const { deviceDescription, deviceId, email, password } = input;
101
103
 
102
104
  // Get user
103
105
  const user = await this.userService.getViaEmail(email, serviceOptionsForUserService);
@@ -109,7 +111,7 @@ export class CoreAuthService {
109
111
  }
110
112
 
111
113
  // Return tokens and user
112
- return this.getResult(user, { deviceId, deviceDescription });
114
+ return this.getResult(user, { deviceDescription, deviceId });
113
115
  }
114
116
 
115
117
  /**
@@ -130,10 +132,10 @@ export class CoreAuthService {
130
132
  }
131
133
 
132
134
  // Set device ID
133
- const { deviceId, deviceDescription } = input;
135
+ const { deviceDescription, deviceId } = input;
134
136
 
135
137
  // Return tokens and user
136
- return this.getResult(user, { deviceId, deviceDescription });
138
+ return this.getResult(user, { deviceDescription, deviceId });
137
139
  } catch (err) {
138
140
  if (err?.message === 'Unprocessable Entity') {
139
141
  throw new BadRequestException('Email address already in use');
@@ -219,10 +221,10 @@ export class CoreAuthService {
219
221
  }
220
222
  }
221
223
 
222
- const payload: { [key: string]: any; id: string; deviceId: string; tokenId: string } = {
224
+ const payload: { [key: string]: any; deviceId: string; id: string; tokenId: string } = {
223
225
  ...data,
224
- id: userId,
225
226
  deviceId,
227
+ id: userId,
226
228
  tokenId,
227
229
  };
228
230
  const [token, refreshToken] = await Promise.all([
@@ -236,8 +238,8 @@ export class CoreAuthService {
236
238
  }),
237
239
  ]);
238
240
  return {
239
- token,
240
241
  refreshToken,
242
+ token,
241
243
  };
242
244
  }
243
245
 
@@ -2,6 +2,7 @@ import { Injectable, UnauthorizedException } from '@nestjs/common';
2
2
  import { PassportStrategy } from '@nestjs/passport';
3
3
  import { Request, Request as RequestType } from 'express';
4
4
  import { ExtractJwt, Strategy } from 'passport-jwt';
5
+
5
6
  import { ConfigService } from '../../../common/services/config.service';
6
7
  import { AuthGuardStrategy } from '../auth-guard-strategy.enum';
7
8
  import { CoreAuthService } from '../services/core-auth.service';
@@ -14,19 +15,19 @@ export class JwtRefreshStrategy extends PassportStrategy(Strategy, AuthGuardStra
14
15
  JwtRefreshStrategy.extractJWTFromCookie,
15
16
  ExtractJwt.fromAuthHeaderAsBearerToken(),
16
17
  ]),
18
+ passReqToCallback: true,
17
19
  privateKey: configService.get('jwt.refresh.privateKey'),
18
20
  publicKey: configService.get('jwt.refresh.publicKey'),
19
21
  secret: configService.get('jwt.refresh.secret') || configService.get('jwt.refresh.secretOrPrivateKey'),
20
22
  secretOrKey: configService.get('jwt.refresh.secretOrPrivateKey') || configService.get('jwt.refresh.secret'),
21
23
  secretOrKeyProvider: configService.get('jwt.refresh.secretOrKeyProvider'),
22
- passReqToCallback: true,
23
24
  });
24
25
  }
25
26
 
26
27
  /**
27
28
  * Extract JWT from cookie
28
29
  */
29
- private static extractJWTFromCookie(req: RequestType): string | null {
30
+ private static extractJWTFromCookie(req: RequestType): null | string {
30
31
  return req?.cookies?.refreshToken || null;
31
32
  }
32
33
 
@@ -1,7 +1,8 @@
1
1
  import { Injectable, UnauthorizedException } from '@nestjs/common';
2
2
  import { PassportStrategy } from '@nestjs/passport';
3
- import { ExtractJwt, Strategy } from 'passport-jwt';
4
3
  import { Request as RequestType } from 'express';
4
+ import { ExtractJwt, Strategy } from 'passport-jwt';
5
+
5
6
  import { ConfigService } from '../../../common/services/config.service';
6
7
  import { AuthGuardStrategy } from '../auth-guard-strategy.enum';
7
8
  import { JwtPayload } from '../interfaces/jwt-payload.interface';
@@ -32,7 +33,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, AuthGuardStrategy.JW
32
33
  /**
33
34
  * Extract JWT from cookie
34
35
  */
35
- private static extractJWTFromCookie(req: RequestType): string | null {
36
+ private static extractJWTFromCookie(req: RequestType): null | string {
36
37
  return req?.cookies?.token || null;
37
38
  }
38
39
 
@@ -1,4 +1,5 @@
1
1
  import { ExecutionContext, createParamDecorator } from '@nestjs/common';
2
+
2
3
  import { getContextData } from '../../common/helpers/context.helper';
3
4
 
4
5
  /**
@@ -6,9 +7,9 @@ import { getContextData } from '../../common/helpers/context.helper';
6
7
  */
7
8
  export const Tokens = createParamDecorator(
8
9
  (
9
- tokenId: 'token' | 'refreshToken' | undefined,
10
+ tokenId: 'refreshToken' | 'token' | undefined,
10
11
  ctx: ExecutionContext,
11
- ): string | { token: string; refreshToken: string } => {
12
+ ): { refreshToken: string; token: string } | string => {
12
13
  // Get prepared context (REST or GraphQL)
13
14
  const context = getContextData(ctx);
14
15
 
@@ -24,7 +25,7 @@ export const Tokens = createParamDecorator(
24
25
  const refreshToken = context?.request?.cookies?.['refreshToken'] || token;
25
26
 
26
27
  // Set tokens
27
- const tokens = { token, refreshToken };
28
+ const tokens = { refreshToken, token };
28
29
 
29
30
  // Return tokens
30
31
  if (tokenId?.length) {
@@ -1,6 +1,7 @@
1
1
  import { Field, ObjectType } from '@nestjs/graphql';
2
2
  import { Prop } from '@nestjs/mongoose';
3
3
  import { Types } from 'mongoose';
4
+
4
5
  import { CoreModel } from '../../common/models/core-model.model';
5
6
 
6
7
  /**
@@ -29,22 +30,22 @@ export class CoreFileInfo extends CoreModel {
29
30
  + 'except for the last, which is only as large as needed. The default size is 255 kilobytes (kB)',
30
31
  nullable: true,
31
32
  })
32
- @Prop({ type: Number, required: false })
33
+ @Prop({ required: false, type: Number })
33
34
  chunkSize: number = undefined;
34
35
 
35
36
  @Field(() => String, { description: 'Content type', nullable: true })
36
- @Prop({ type: String, required: false })
37
+ @Prop({ required: false, type: String })
37
38
  contentType?: string = undefined;
38
39
 
39
40
  @Field(() => String, { description: 'Name of the file', nullable: true })
40
- @Prop({ type: String, required: false })
41
+ @Prop({ required: false, type: String })
41
42
  filename?: string = undefined;
42
43
 
43
44
  @Field(() => Number, { description: 'The size of the document in bytes', nullable: true })
44
- @Prop({ type: Number, required: false })
45
+ @Prop({ required: false, type: Number })
45
46
  length: number = undefined;
46
47
 
47
48
  @Field(() => Date, { description: 'The date the file was first stored', nullable: true })
48
- @Prop({ type: Date, required: false })
49
+ @Prop({ required: false, type: Date })
49
50
  uploadDate: Date = undefined;
50
51
  }
@@ -1,4 +1,5 @@
1
1
  import { BadRequestException, Controller, Get, NotFoundException, Param, Res } from '@nestjs/common';
2
+
2
3
  import { CoreFileService } from './core-file.service';
3
4
 
4
5
  /**
@@ -1,7 +1,8 @@
1
1
  import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
2
2
  import * as GraphQLUpload from 'graphql-upload/GraphQLUpload.js';
3
- import { CoreFileInfo } from './core-file-info.model';
3
+
4
4
  import { CoreFileService } from './core-file.service';
5
+ import { CoreFileInfo } from './core-file-info.model';
5
6
  import { FileUpload } from './interfaces/file-upload.interface';
6
7
 
7
8
  /**
@@ -1,7 +1,8 @@
1
+ import { MongoGridFSOptions, MongooseGridFS, createBucket } from '@lenne.tech/mongoose-gridfs';
1
2
  import { NotFoundException } from '@nestjs/common';
2
3
  import { GridFSBucket, GridFSBucketReadStream, GridFSBucketReadStreamOptions } from 'mongodb';
3
4
  import { Connection, Types } from 'mongoose';
4
- import { MongoGridFSOptions, MongooseGridFS, createBucket } from '@lenne.tech/mongoose-gridfs';
5
+
5
6
  import { FilterArgs } from '../../common/args/filter.args';
6
7
  import { getObjectIds, getStringIds } from '../../common/helpers/db.helper';
7
8
  import { convertFilterArgsToQuery } from '../../common/helpers/filter.helper';
@@ -15,7 +16,7 @@ import { FileUpload } from './interfaces/file-upload.interface';
15
16
  /**
16
17
  * Type for checking input
17
18
  */
18
- export type FileInputCheckType = 'file' | 'files' | 'filterArgs' | 'id' | 'filename';
19
+ export type FileInputCheckType = 'file' | 'filename' | 'files' | 'filterArgs' | 'id';
19
20
 
20
21
  /**
21
22
  * Abstract core file service
@@ -39,9 +40,9 @@ export abstract class CoreFileService {
39
40
  }
40
41
  return await new Promise(async (resolve, reject) => {
41
42
  // eslint-disable-next-line unused-imports/no-unused-vars
42
- const { filename, mimetype, encoding, createReadStream } = await file;
43
+ const { createReadStream, encoding, filename, mimetype } = await file;
43
44
  const readStream = createReadStream();
44
- const options: MongoGridFSOptions = { filename, contentType: mimetype };
45
+ const options: MongoGridFSOptions = { contentType: mimetype, filename };
45
46
  this.files.writeFile(options, readStream, (error, fileInfo) => {
46
47
  error ? reject(error) : resolve(this.prepareOutput(fileInfo, serviceOptions));
47
48
  });
@@ -84,7 +85,7 @@ export abstract class CoreFileService {
84
85
  /**
85
86
  * Get info about file via file ID
86
87
  */
87
- async getFileInfo(id: string | Types.ObjectId, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo> {
88
+ async getFileInfo(id: Types.ObjectId | string, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo> {
88
89
  if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
89
90
  return null;
90
91
  }
@@ -112,7 +113,7 @@ export abstract class CoreFileService {
112
113
  /**
113
114
  * Get file stream (for big files) via file ID
114
115
  */
115
- async getFileStream(id: string | Types.ObjectId, serviceOptions?: FileServiceOptions) {
116
+ async getFileStream(id: Types.ObjectId | string, serviceOptions?: FileServiceOptions) {
116
117
  if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
117
118
  return null;
118
119
  }
@@ -135,7 +136,7 @@ export abstract class CoreFileService {
135
136
  /**
136
137
  * Get file buffer (for small files) via file ID
137
138
  */
138
- async getBuffer(id: string | Types.ObjectId, serviceOptions?: FileServiceOptions): Promise<Buffer> {
139
+ async getBuffer(id: Types.ObjectId | string, serviceOptions?: FileServiceOptions): Promise<Buffer> {
139
140
  if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
140
141
  return null;
141
142
  }
@@ -163,7 +164,7 @@ export abstract class CoreFileService {
163
164
  /**
164
165
  * Delete file reference of avatar
165
166
  */
166
- async deleteFile(id: string | Types.ObjectId, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo> {
167
+ async deleteFile(id: Types.ObjectId | string, serviceOptions?: FileServiceOptions): Promise<CoreFileInfo> {
167
168
  if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
168
169
  return null;
169
170
  }
@@ -2,7 +2,7 @@
2
2
  * Interface for service options in file services
3
3
  */
4
4
  export interface FileServiceOptions {
5
- currentUser?: { id: any; hasRole: (roles: string[]) => boolean };
5
+ currentUser?: { hasRole: (roles: string[]) => boolean; id: any };
6
6
  force?: boolean;
7
7
  roles?: string | string[];
8
8
  }
@@ -1,5 +1,5 @@
1
- import { Readable } from 'stream';
2
1
  import { WriteStream } from 'fs-capacitor';
2
+ import { Readable } from 'stream';
3
3
 
4
4
  /**
5
5
  * Interface for file uploads
@@ -15,7 +15,7 @@ export interface FileUpload {
15
15
  */
16
16
  createReadStream: (options?: {
17
17
  /** Specify an encoding for the chunks, default: utf8 */
18
- encoding?: 'utf8' | 'utf8' | 'ucs2' | 'utf16le' | 'latin1' | 'ascii' | 'base64' | 'base64url' | 'hex';
18
+ encoding?: 'ascii' | 'base64' | 'base64url' | 'hex' | 'latin1' | 'ucs2' | 'utf8' | 'utf8' | 'utf16le';
19
19
 
20
20
  /** Maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource, default: 16384 */
21
21
  highWaterMark?: number;
@@ -1,4 +1,5 @@
1
1
  import { Field, ObjectType } from '@nestjs/graphql';
2
+
2
3
  import { CoreModel } from '../../common/models/core-model.model';
3
4
  import { JSON } from '../../common/scalars/json.scalar';
4
5
 
@@ -1,4 +1,5 @@
1
1
  import { Controller, Get } from '@nestjs/common';
2
+
2
3
  import { CoreHealthCheckService } from './core-health-check.service';
3
4
 
4
5
  /**
@@ -1,5 +1,6 @@
1
1
  import { Module } from '@nestjs/common';
2
2
  import { TerminusModule } from '@nestjs/terminus';
3
+
3
4
  import { CoreHealthCheckController } from './core-health-check.controller';
4
5
  import { CoreHealthCheckResolver } from './core-health-check.resolver';
5
6
  import { CoreHealthCheckService } from './core-health-check.service';
@@ -9,8 +10,8 @@ import { CoreHealthCheckService } from './core-health-check.service';
9
10
  * Inspired by https://mobileappcircular.com/marketplace-backend-creating-a-health-check-endpoint-in-nestjs-app-using-terminus-25727e96c7d2
10
11
  */
11
12
  @Module({
12
- imports: [TerminusModule],
13
13
  controllers: [CoreHealthCheckController],
14
+ imports: [TerminusModule],
14
15
  providers: [CoreHealthCheckService, CoreHealthCheckResolver],
15
16
  })
16
17
  export class CoreHealthCheckModule {
@@ -1,8 +1,9 @@
1
1
  import { Query, Resolver } from '@nestjs/graphql';
2
- import { RoleEnum } from '../../common/enums/role.enum';
2
+
3
3
  import { Roles } from '../../common/decorators/roles.decorator';
4
- import { CoreHealthCheckResult } from './core-health-check-result.model';
4
+ import { RoleEnum } from '../../common/enums/role.enum';
5
5
  import { CoreHealthCheckService } from './core-health-check.service';
6
+ import { CoreHealthCheckResult } from './core-health-check-result.model';
6
7
 
7
8
 
8
9
  /**
@@ -7,6 +7,7 @@ import {
7
7
  } from '@nestjs/terminus';
8
8
  import { MongoosePingCheckSettings } from '@nestjs/terminus/dist/health-indicator/database/mongoose.health';
9
9
  import { DiskHealthIndicatorOptions } from '@nestjs/terminus/dist/health-indicator/disk/disk-health-options.type';
10
+
10
11
  import { ConfigService } from '../../common/services/config.service';
11
12
 
12
13
  /**
@@ -52,8 +53,8 @@ export class CoreHealthCheckService {
52
53
  healthIndicatorFunctions.push(() => this.disk.checkStorage(
53
54
  this.config.get<string>('healthCheck.configs.storage.key') ?? 'storage',
54
55
  this.config.get<DiskHealthIndicatorOptions>('healthCheck.configs.storage.options') ?? {
55
- thresholdPercent: 0.8,
56
56
  path: '/',
57
+ thresholdPercent: 0.8,
57
58
  },
58
59
  ));
59
60
  }
@@ -2,6 +2,7 @@ import { Field, ObjectType } from '@nestjs/graphql';
2
2
  import { Schema as MongooseSchema, Prop, raw } from '@nestjs/mongoose';
3
3
  import { IsEmail, IsOptional } from 'class-validator';
4
4
  import { Document } from 'mongoose';
5
+
5
6
  import { CorePersistenceModel } from '../../common/models/core-persistence.model';
6
7
  import { CoreTokenData } from '../auth/interfaces/core-token-data.interface';
7
8
 
@@ -22,7 +23,7 @@ export abstract class CoreUserModel extends CorePersistenceModel {
22
23
  */
23
24
  @Field({ description: 'Email of the user', nullable: true })
24
25
  @IsEmail()
25
- @Prop({ unique: true, lowercase: true, trim: true })
26
+ @Prop({ lowercase: true, trim: true, unique: true })
26
27
  email: string = undefined;
27
28
 
28
29
  /**