@mshima/generator-jhipster-nodejs 0.0.0-stage → 0.0.2

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 (216) hide show
  1. package/LICENSE.txt +204 -0
  2. package/README.md +243 -2
  3. package/build-info.json +3 -0
  4. package/cli/cli-customizations.cjs +9 -0
  5. package/cli/cli.cjs +40 -0
  6. package/cli/logo.js +31 -0
  7. package/cli/version.cjs +12 -0
  8. package/generators/ci-cd/USAGE +5 -0
  9. package/generators/ci-cd/command.js +5 -0
  10. package/generators/ci-cd/generator.js +158 -0
  11. package/generators/ci-cd/index.js +2 -0
  12. package/generators/ci-cd/templates/.gitlab-ci.yml.ejs +137 -0
  13. package/generators/ci-cd/templates/azure-pipelines.yml.ejs +68 -0
  14. package/generators/ci-cd/templates/circle.yml.ejs +59 -0
  15. package/generators/ci-cd/templates/docker-registry.yml.ejs +58 -0
  16. package/generators/ci-cd/templates/github-ci.yml.ejs +90 -0
  17. package/generators/ci-cd/templates/jenkins/Jenkinsfile.ejs +104 -0
  18. package/generators/ci-cd/templates/jenkins/idea.gdsl +90 -0
  19. package/generators/ci-cd/templates/jenkins/jenkins.yml.ejs +33 -0
  20. package/generators/ci-cd/templates/travis.yml.ejs +75 -0
  21. package/generators/client/command.js +5 -0
  22. package/generators/client/generator.js +21 -0
  23. package/generators/client/generators/bootstrap/command.js +5 -0
  24. package/generators/client/generators/bootstrap/generator.js +28 -0
  25. package/generators/client/generators/bootstrap/index.js +2 -0
  26. package/generators/client/index.js +2 -0
  27. package/generators/common/generators/bootstrap/command.js +5 -0
  28. package/generators/common/generators/bootstrap/generator.js +37 -0
  29. package/generators/common/generators/bootstrap/index.js +2 -0
  30. package/generators/docker/command.js +5 -0
  31. package/generators/docker/generator.js +16 -0
  32. package/generators/docker/generators/bootstrap/command.js +5 -0
  33. package/generators/docker/generators/bootstrap/generator.js +56 -0
  34. package/generators/docker/generators/bootstrap/index.js +2 -0
  35. package/generators/docker/index.js +2 -0
  36. package/generators/docker/templates/docker/app.yml.ejs +25 -0
  37. package/generators/generator-nodejs-constants.js +32 -0
  38. package/generators/languages/command.js +5 -0
  39. package/generators/languages/generator.js +22 -0
  40. package/generators/languages/index.js +2 -0
  41. package/generators/languages/templates/src/main/webapp/i18n/en/home.json +19 -0
  42. package/generators/languages/templates/src/main/webapp/i18n/es/home.json +19 -0
  43. package/generators/languages/templates/src/main/webapp/i18n/it/home.json +19 -0
  44. package/generators/node-server/command.js +96 -0
  45. package/generators/node-server/entity-files.js +26 -0
  46. package/generators/node-server/files.js +254 -0
  47. package/generators/node-server/generator.js +705 -0
  48. package/generators/node-server/generators/bootstrap/command.js +5 -0
  49. package/generators/node-server/generators/bootstrap/generator.js +84 -0
  50. package/generators/node-server/generators/bootstrap/index.js +2 -0
  51. package/generators/node-server/generators/migrations/command.js +5 -0
  52. package/generators/node-server/generators/migrations/files.js +42 -0
  53. package/generators/node-server/generators/migrations/generator.js +108 -0
  54. package/generators/node-server/generators/migrations/index.js +2 -0
  55. package/generators/node-server/generators/migrations/templates/server/src/migrations/_entityConstraintsMigration_.ts.ejs +40 -0
  56. package/generators/node-server/generators/migrations/templates/server/src/migrations/_entityMigration_.ts.ejs +26 -0
  57. package/generators/node-server/generators/migrations/templates/server/src/migrations/_entityRemovedMigration_.ts.ejs +15 -0
  58. package/generators/node-server/generators/migrations/templates/server/src/migrations/_entityUpdatedConstraintsMigration_.ts.ejs +60 -0
  59. package/generators/node-server/generators/migrations/templates/server/src/migrations/_entityUpdatedMigration_.ts.ejs +28 -0
  60. package/generators/node-server/index.js +2 -0
  61. package/generators/node-server/resources/package.json +76 -0
  62. package/generators/node-server/support/api-fake-data.js +54 -0
  63. package/generators/node-server/support/columns.js +73 -0
  64. package/generators/node-server/support/database.js +24 -0
  65. package/generators/node-server/support/entity-authorities.js +32 -0
  66. package/generators/node-server/support/entity-paths.js +13 -0
  67. package/generators/node-server/support/enums.js +11 -0
  68. package/generators/node-server/support/index.js +9 -0
  69. package/generators/node-server/support/mail-templates.js +82 -0
  70. package/generators/node-server/support/migrations.js +376 -0
  71. package/generators/node-server/support/validators.js +25 -0
  72. package/generators/node-server/templates/.dockerignore.ejs +16 -0
  73. package/generators/node-server/templates/.gitignore.jhi.nodejs.ejs +24 -0
  74. package/generators/node-server/templates/Dockerfile.ejs +54 -0
  75. package/generators/node-server/templates/README.md.jhi.nodejs.ejs +220 -0
  76. package/generators/node-server/templates/package.json.ejs +82 -0
  77. package/generators/node-server/templates/server/README.md.ejs +277 -0
  78. package/generators/node-server/templates/server/e2e/_entityFileName_.database.e2e-spec.ts.ejs +192 -0
  79. package/generators/node-server/templates/server/e2e/_entityFileName_.e2e-spec.ts.ejs +402 -0
  80. package/generators/node-server/templates/server/e2e/account.e2e-spec.ts.ejs +349 -0
  81. package/generators/node-server/templates/server/e2e/app.e2e-spec.ts.ejs +188 -0
  82. package/generators/node-server/templates/server/e2e/authority.e2e-spec.ts.ejs +50 -0
  83. package/generators/node-server/templates/server/e2e/cors.e2e-spec.ts.ejs +110 -0
  84. package/generators/node-server/templates/server/e2e/management.e2e-spec.ts.ejs +180 -0
  85. package/generators/node-server/templates/server/e2e/oauth2-bearer.e2e-spec.ts.ejs +71 -0
  86. package/generators/node-server/templates/server/e2e/session.e2e-spec.ts.ejs +234 -0
  87. package/generators/node-server/templates/server/e2e/setup.test.js.ejs +1 -0
  88. package/generators/node-server/templates/server/e2e/user.e2e-spec.ts.ejs +318 -0
  89. package/generators/node-server/templates/server/env.ejs +1 -0
  90. package/generators/node-server/templates/server/eslint.config.mjs.ejs +48 -0
  91. package/generators/node-server/templates/server/nest-cli.json.ejs +11 -0
  92. package/generators/node-server/templates/server/ormconfig.ts.ejs +35 -0
  93. package/generators/node-server/templates/server/package.json.ejs +143 -0
  94. package/generators/node-server/templates/server/sonar-project.properties.ejs +10 -0
  95. package/generators/node-server/templates/server/src/app.config.spec.ts.ejs +13 -0
  96. package/generators/node-server/templates/server/src/app.config.ts.ejs +179 -0
  97. package/generators/node-server/templates/server/src/app.module.ts.ejs +80 -0
  98. package/generators/node-server/templates/server/src/application-config.ts.ejs +153 -0
  99. package/generators/node-server/templates/server/src/auth/account.controller.ts.ejs +183 -0
  100. package/generators/node-server/templates/server/src/auth/auth.module.ts.ejs +104 -0
  101. package/generators/node-server/templates/server/src/auth/auth.service.ts.ejs +294 -0
  102. package/generators/node-server/templates/server/src/auth/csrf.middleware.spec.ts.ejs +76 -0
  103. package/generators/node-server/templates/server/src/auth/csrf.middleware.ts.ejs +85 -0
  104. package/generators/node-server/templates/server/src/auth/decorators/auth-user.decorator.ts.ejs +8 -0
  105. package/generators/node-server/templates/server/src/auth/decorators/roles.decorator.ts.ejs +4 -0
  106. package/generators/node-server/templates/server/src/auth/dto/key-and-password.dto.ts.ejs +17 -0
  107. package/generators/node-server/templates/server/src/auth/dto/password-change.dto.ts.ejs +17 -0
  108. package/generators/node-server/templates/server/src/auth/dto/user-login.dto.ts.ejs +21 -0
  109. package/generators/node-server/templates/server/src/auth/guards/auth.guard.ts.ejs +50 -0
  110. package/generators/node-server/templates/server/src/auth/guards/oauth2-login.guard.ts.ejs +6 -0
  111. package/generators/node-server/templates/server/src/auth/guards/roles.guard.ts.ejs +25 -0
  112. package/generators/node-server/templates/server/src/auth/index.ts.ejs +8 -0
  113. package/generators/node-server/templates/server/src/auth/jwt.config.spec.ts.ejs +22 -0
  114. package/generators/node-server/templates/server/src/auth/jwt.config.ts.ejs +29 -0
  115. package/generators/node-server/templates/server/src/auth/oauth2.authorities.spec.ts.ejs +24 -0
  116. package/generators/node-server/templates/server/src/auth/oauth2.authorities.ts.ejs +33 -0
  117. package/generators/node-server/templates/server/src/auth/oauth2.config.ts.ejs +51 -0
  118. package/generators/node-server/templates/server/src/auth/passport.jwt.strategy.ts.ejs +45 -0
  119. package/generators/node-server/templates/server/src/auth/passport.oauth2-bearer.strategy.ts.ejs +32 -0
  120. package/generators/node-server/templates/server/src/auth/passport.oauth2.strategy.spec.ts.ejs +27 -0
  121. package/generators/node-server/templates/server/src/auth/passport.oauth2.strategy.ts.ejs +44 -0
  122. package/generators/node-server/templates/server/src/auth/password-util.ts.ejs +10 -0
  123. package/generators/node-server/templates/server/src/auth/password.service.ts.ejs +34 -0
  124. package/generators/node-server/templates/server/src/auth/payload.interface.ts.ejs +14 -0
  125. package/generators/node-server/templates/server/src/auth/role-type.ts.ejs +7 -0
  126. package/generators/node-server/templates/server/src/auth/session-user.middleware.ts.ejs +33 -0
  127. package/generators/node-server/templates/server/src/auth/session.entity.ts.ejs +36 -0
  128. package/generators/node-server/templates/server/src/auth/session.store.spec.ts.ejs +99 -0
  129. package/generators/node-server/templates/server/src/auth/session.store.ts.ejs +116 -0
  130. package/generators/node-server/templates/server/src/auth/user.jwt.controller.ts.ejs +26 -0
  131. package/generators/node-server/templates/server/src/auth/user.oauth2.controller.ts.ejs +78 -0
  132. package/generators/node-server/templates/server/src/auth/user.session.controller.ts.ejs +103 -0
  133. package/generators/node-server/templates/server/src/common/common.module.ts.ejs +19 -0
  134. package/generators/node-server/templates/server/src/common/database/base.entity.ts.ejs +13 -0
  135. package/generators/node-server/templates/server/src/common/database/column-transformers.spec.ts.ejs +46 -0
  136. package/generators/node-server/templates/server/src/common/database/column-transformers.ts.ejs +69 -0
  137. package/generators/node-server/templates/server/src/common/database/column-types.spec.ts.ejs +21 -0
  138. package/generators/node-server/templates/server/src/common/database/column-types.ts.ejs +29 -0
  139. package/generators/node-server/templates/server/src/common/database/pagination.entity.spec.ts.ejs +66 -0
  140. package/generators/node-server/templates/server/src/common/database/pagination.entity.ts.ejs +108 -0
  141. package/generators/node-server/templates/server/src/common/dto/base.dto.ts.ejs +19 -0
  142. package/generators/node-server/templates/server/src/common/errors/error-constants.ts.ejs +10 -0
  143. package/generators/node-server/templates/server/src/common/errors/problem-details.filter.ts.ejs +63 -0
  144. package/generators/node-server/templates/server/src/common/errors/problem.exception.ts.ejs +92 -0
  145. package/generators/node-server/templates/server/src/common/field_validators.ejs +77 -0
  146. package/generators/node-server/templates/server/src/common/header-util.ts.ejs +105 -0
  147. package/generators/node-server/templates/server/src/common/interceptors/logging.interceptor.spec.ts.ejs +93 -0
  148. package/generators/node-server/templates/server/src/common/interceptors/logging.interceptor.ts.ejs +48 -0
  149. package/generators/node-server/templates/server/src/common/logging.spec.ts.ejs +83 -0
  150. package/generators/node-server/templates/server/src/common/logging.ts.ejs +129 -0
  151. package/generators/node-server/templates/server/src/common/metrics.spec.ts.ejs +43 -0
  152. package/generators/node-server/templates/server/src/common/metrics.ts.ejs +198 -0
  153. package/generators/node-server/templates/server/src/common/request.ts.ejs +8 -0
  154. package/generators/node-server/templates/server/src/common/sortable-properties.ts.ejs +43 -0
  155. package/generators/node-server/templates/server/src/common/updatable-properties.ts.ejs +14 -0
  156. package/generators/node-server/templates/server/src/config/application-dev.yml.ejs +118 -0
  157. package/generators/node-server/templates/server/src/config/application-prod.yml.ejs +97 -0
  158. package/generators/node-server/templates/server/src/config/application-secret-samples.yml.ejs +42 -0
  159. package/generators/node-server/templates/server/src/config/application-test.yml.ejs +68 -0
  160. package/generators/node-server/templates/server/src/config/application-tls-samples.yml.ejs +15 -0
  161. package/generators/node-server/templates/server/src/config/application-tls.yml.ejs +15 -0
  162. package/generators/node-server/templates/server/src/config/application.yml.ejs +149 -0
  163. package/generators/node-server/templates/server/src/config.spec.ts.ejs +81 -0
  164. package/generators/node-server/templates/server/src/config.ts.ejs +255 -0
  165. package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.controller.ts.ejs +178 -0
  166. package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.entity.ts.ejs +110 -0
  167. package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.mapper.ts.ejs +37 -0
  168. package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.module.ts.ejs +14 -0
  169. package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.service.ts.ejs +123 -0
  170. package/generators/node-server/templates/server/src/entities/_entityFileName_/dto/_entityFileName_.dto.ts.ejs +99 -0
  171. package/generators/node-server/templates/server/src/mail/mail.module.ts.ejs +49 -0
  172. package/generators/node-server/templates/server/src/mail/mail.service.spec.ts.ejs +105 -0
  173. package/generators/node-server/templates/server/src/mail/mail.service.ts.ejs +120 -0
  174. package/generators/node-server/templates/server/src/main.ts.ejs +114 -0
  175. package/generators/node-server/templates/server/src/management/api-docs.controller.ts.ejs +27 -0
  176. package/generators/node-server/templates/server/src/management/api-docs.service.ts.ejs +8 -0
  177. package/generators/node-server/templates/server/src/management/configuration.controller.ts.ejs +80 -0
  178. package/generators/node-server/templates/server/src/management/health.controller.spec.ts.ejs +79 -0
  179. package/generators/node-server/templates/server/src/management/health.controller.ts.ejs +87 -0
  180. package/generators/node-server/templates/server/src/management/health.module.ts.ejs +9 -0
  181. package/generators/node-server/templates/server/src/management/loggers.controller.ts.ejs +40 -0
  182. package/generators/node-server/templates/server/src/management/management.controller.spec.ts.ejs +26 -0
  183. package/generators/node-server/templates/server/src/management/management.controller.ts.ejs +34 -0
  184. package/generators/node-server/templates/server/src/management/management.module.ts.ejs +21 -0
  185. package/generators/node-server/templates/server/src/management/metrics.controller.ts.ejs +85 -0
  186. package/generators/node-server/templates/server/src/migrations/1570200270081-CreateTables.ts.ejs +64 -0
  187. package/generators/node-server/templates/server/src/migrations/1570200270082-CreateSessions.ts.ejs +26 -0
  188. package/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs +74 -0
  189. package/generators/node-server/templates/server/src/migrations/support/schema.ts.ejs +254 -0
  190. package/generators/node-server/templates/server/src/orm.config.ts.ejs +147 -0
  191. package/generators/node-server/templates/server/src/registry/consul.service.ts.ejs +70 -0
  192. package/generators/node-server/templates/server/src/registry/eureka.service.ts.ejs +129 -0
  193. package/generators/node-server/templates/server/src/swagger.ts.ejs +24 -0
  194. package/generators/node-server/templates/server/src/tls.ts.ejs +27 -0
  195. package/generators/node-server/templates/server/src/users/authority.controller.ts.ejs +85 -0
  196. package/generators/node-server/templates/server/src/users/authority.entity.ts.ejs +22 -0
  197. package/generators/node-server/templates/server/src/users/dto/authority.dto.ts.ejs +10 -0
  198. package/generators/node-server/templates/server/src/users/dto/user.dto.ts.ejs +116 -0
  199. package/generators/node-server/templates/server/src/users/public.user.controller.ts.ejs +51 -0
  200. package/generators/node-server/templates/server/src/users/user.controller.ts.ejs +191 -0
  201. package/generators/node-server/templates/server/src/users/user.entity.ts.ejs +63 -0
  202. package/generators/node-server/templates/server/src/users/user.mapper.ts.ejs +26 -0
  203. package/generators/node-server/templates/server/src/users/user.module.ts.ejs +19 -0
  204. package/generators/node-server/templates/server/src/users/user.service.ts.ejs +156 -0
  205. package/generators/node-server/templates/server/tsconfig.build.json.ejs +9 -0
  206. package/generators/node-server/templates/server/tsconfig.json.ejs +23 -0
  207. package/generators/node-server/templates/server/typeorm-migration.ts.ejs +18 -0
  208. package/generators/node-server/templates/server/vitest.config.e2e.ts.ejs +16 -0
  209. package/generators/node-server/templates/server/vitest.config.ts.ejs +16 -0
  210. package/generators/server/command.js +7 -0
  211. package/generators/server/generator.js +20 -0
  212. package/generators/server/generators/bootstrap/command.js +5 -0
  213. package/generators/server/generators/bootstrap/generator.js +15 -0
  214. package/generators/server/generators/bootstrap/index.js +2 -0
  215. package/generators/server/index.js +2 -0
  216. package/package.json +75 -4
@@ -0,0 +1,54 @@
1
+ <%_
2
+ const serverDir = nodeServerRootDir.replace(/\/$/, '');
3
+ const clientDir = clientRootDir.replace(/\/$/, '');
4
+ _%>
5
+ # Build stage: installs every dependency and builds the application.
6
+ FROM node:<%- nodeVersion %>-alpine AS build
7
+
8
+ WORKDIR /usr/src/app
9
+
10
+ # The package-lock.json of the application, missing in a workspace of applications (its lock is the one of the workspace).
11
+ COPY package*.json ./
12
+ COPY <%- nodeServerRootDir %>package.json <%- nodeServerRootDir %>
13
+ <%_ if (clientFrameworkAny) { _%>
14
+ COPY <%- clientRootDir %>package.json <%- clientRootDir %>
15
+ <%_ } _%>
16
+ # The install scripts (native bindings of the development database, husky, Cypress) are not needed to build. npm install
17
+ # installs the versions of the package-lock.json, or resolves them and writes one, the runtime stage installs from it.
18
+ RUN npm install --ignore-scripts
19
+
20
+ COPY . .
21
+ RUN npm run build --workspace <%- serverDir %>
22
+ <%_ if (clientFrameworkAny) { _%>
23
+ # The client is built into <%- nodeServerRootDir %>dist/static, served by the server.
24
+ RUN npm run build --workspace <%- clientDir %>
25
+ <%_ } _%>
26
+
27
+ # Runtime stage: the production dependencies of the server and its build only.
28
+ FROM node:<%- nodeVersion %>-alpine
29
+
30
+ WORKDIR /usr/src/app
31
+
32
+ ENV NODE_ENV=production
33
+ ENV BACKEND_ENV=prod
34
+ ENV NODE_SERVER_PORT=<%- serverPort %>
35
+
36
+ COPY package.json ./
37
+ COPY --from=build /usr/src/app/package-lock.json ./
38
+ COPY <%- nodeServerRootDir %>package.json <%- nodeServerRootDir %>
39
+ <%_ if (clientFrameworkAny) { _%>
40
+ COPY <%- clientRootDir %>package.json <%- clientRootDir %>
41
+ <%_ } _%>
42
+ RUN npm ci --omit=dev --ignore-scripts --workspace <%- serverDir %> && npm cache clean --force
43
+
44
+ COPY --from=build /usr/src/app/<%- nodeServerRootDir %>dist <%- nodeServerRootDir %>dist
45
+
46
+ USER node
47
+ WORKDIR /usr/src/app/<%- serverDir %>
48
+
49
+ EXPOSE <%- serverPort %>
50
+
51
+ HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=5 \
52
+ CMD ["node", "-e", "fetch(`http://localhost:${process.env.NODE_SERVER_PORT}/management/health`).then(r => process.exit(r.ok ? 0 : 1), () => process.exit(1))"]
53
+
54
+ CMD ["node", "dist/main.js"]
@@ -0,0 +1,220 @@
1
+ <%#
2
+ Copyright 2019-2023 the original author or authors from the JHipster project
3
+
4
+ This file is part of the JHipster project, see https://www.jhipster.tech/
5
+ for more information.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ https://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ -%>
19
+ <%#
20
+ This is a fragment file, it will be merged into to root template if available.
21
+ EJS fragments will process % delimiter tags in template and & delimiter tags in the merge process.
22
+ -%>
23
+ <&_ if (fragment.introSection) { -&>
24
+ This application was generated using the [NodeJS blueprint](https://github.com/jhipster/generator-jhipster-nodejs) of JHipster <%= jhipsterVersion %>, you can find documentation and help at [<%= documentationArchiveUrl %>](<%= documentationArchiveUrl %>). For any questions you can refer to the stream lead: [Angelo Manganiello](https://github.com/amanganiello90).
25
+ <%_ if (applicationTypeGateway || applicationTypeMicroservice) { _%>
26
+
27
+ This is a "<%= applicationType %>" application intended to be part of a microservice architecture, please refer to the [Doing microservices with JHipster][] page of the documentation for more information.
28
+ <%_ if (serviceDiscoveryEureka) { _%>
29
+ This application is configured for Service Discovery and Configuration with the JHipster-Registry, enabled with `EUREKA_CLIENT_ENABLED=true` (at `eureka.client.service-url.defaultZone`, [http://localhost:8761](http://localhost:8761) by default). Enabled, it refuses to start if it is not able to load its configuration from the JHipster-Registry, then registers once it listens and deregisters when it stops. For more information, read our documentation on [Service Discovery and Configuration with the JHipster-Registry][].
30
+ <%_ } _%>
31
+ <%_ if (serviceDiscoveryConsul) { _%>
32
+ This application is configured for Service Discovery with Consul, enabled with `CLOUD_CONSUL_ENABLED=true` (at `CLOUD_CONSUL_HOST` and `CLOUD_CONSUL_PORT`, [http://localhost:8500](http://localhost:8500) by default). Enabled, it registers once it listens, with the health check of `/management/health`, and deregisters when it stops; a failed registration is logged. For more information, read our documentation on [Service Discovery and Configuration with Consul][].
33
+ <%_ } _%>
34
+ <%_ } _%>
35
+
36
+ <&_ } -&>
37
+
38
+ <&_ if (fragment.structureSection) { -&>
39
+ Node is required for generation and recommended for development. `package.json` is always generated for a better development experience with prettier, commit hooks, scripts and so on.
40
+
41
+ In the project root, JHipster generates configuration files for tools like git, prettier, husky, and others that are well known and you can find references in the web.
42
+
43
+ - `.yo-rc.json` - Yeoman configuration file
44
+ JHipster configuration is stored in this file at `generator-jhipster` key. You may find `generator-jhipster-*` for specific blueprints configuration.
45
+ - `.yo-resolve` (optional) - Yeoman conflict resolver
46
+ Allows to use a specific action when conflicts are found skipping prompts for files that matches a pattern. Each line should match `[pattern] [action]` with pattern been a [Minimatch](https://github.com/isaacs/minimatch#minimatch) pattern and action been one of skip (default if ommited) or force. Lines starting with `#` are considered comments and are ignored.
47
+ - `.jhipster/*.json` - JHipster entity configuration files
48
+ - `/<%- dockerServicesDir %>` - Docker configurations for the application and services that the application depends on
49
+ - `/<%- clientRootDir %>` - Web application.
50
+ - `/server/` - NodeJS server application.
51
+
52
+ <&_ } -&>
53
+
54
+ <&_ if (fragment.developmentSection) { -&>
55
+
56
+ <%_ if (authenticationTypeOauth2) { _%>
57
+ ### OAuth 2.0 / OpenID Connect
58
+
59
+ Congratulations! You've selected an excellent way to secure your NHipster application. If you're not sure what OAuth and OpenID Connect (OIDC) are, please see [What the Heck is OAuth?](https://developer.okta.com/blog/2017/06/21/what-the-heck-is-oauth)
60
+
61
+ To log in to your app, you'll need to have [Keycloak](https://keycloak.org) up and running. The JHipster Team has created a Docker container for you that has the default users and roles. Start Keycloak using the following command.
62
+
63
+ ```
64
+ docker compose -f <%- dockerServicesDir %>keycloak.yml up
65
+ ```
66
+
67
+ ### Okta
68
+
69
+ If you'd like to use Okta instead of Keycloak, it's pretty quick using the [Okta CLI](https://cli.okta.com/). After you've installed it, run:
70
+
71
+ ```shell
72
+ okta register
73
+ ```
74
+
75
+ Then, in your JHipster app's directory, run `okta apps create` and select **JHipster**. This will set up an Okta app for you, create `ROLE_ADMIN` and `ROLE_USER` groups, create a `.okta.env` file with your Okta settings, and configure a `groups` claim in your ID token.
76
+
77
+ Run `source .okta.env` and start your app with `npm start`. You should be able to sign in with the credentials you registered with.
78
+
79
+ If you're on Windows, you should install [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10) so the `source` command will work.
80
+
81
+ If you'd like to configure things manually through the Okta developer console, see the instructions below.
82
+
83
+ First, you'll need to create a free developer account at <https://developer.okta.com/signup/>. After doing so, you'll get your own Okta domain, that has a name like `https://dev-123456.okta.com`.
84
+
85
+ Modify `<%= nodeServerRootDir %>src/config/application.yml` to use your Okta settings.
86
+
87
+ ```yaml
88
+ ...
89
+ security:
90
+ oauth2:
91
+ client:
92
+ provider:
93
+ oidc:
94
+ issuer-uri: https://{yourOktaDomain}/oauth2/default
95
+ registration:
96
+ oidc:
97
+ client-id: {clientId}
98
+ client-secret: {clientSecret}
99
+ ```
100
+
101
+ Create an OIDC App in Okta to get a `{clientId}` and `{clientSecret}`. To do this, log in to your Okta Developer account and navigate to **Applications** > **Add Application**. Click **Web** and click the **Next** button. Give the app a name you’ll remember, specify `http://localhost:<%- serverPort %>` as a Base URI, and `http://localhost:<%- serverPort %>/login/oauth2/code/oidc` as a Login Redirect URI. Click **Done**, then Edit and add `http://localhost:<%- serverPort %>` as a Logout redirect URI. Copy and paste the client ID and secret into your `application.yml` file.
102
+
103
+ Create a `ROLE_ADMIN` and `ROLE_USER` group and add users into them. Modify e2e tests to use this account when running integration tests. You'll need to change credentials in `<%= clientTestDir %>e2e/account/account.spec.ts` and `<%= clientTestDir %>e2e/admin/administration.spec.ts`.
104
+
105
+ Navigate to **API** > **Authorization Servers**, click the **Authorization Servers** tab and edit the default one. Click the **Claims** tab and **Add Claim**. Name it "groups", and include it in the ID Token. Set the value type to "Groups" and set the filter to be a Regex of `.*`.
106
+
107
+ After making these changes, you should be good to go! If you have any issues, please post them to [Stack Overflow](https://stackoverflow.com/questions/tagged/jhipster). Make sure to tag your question with "jhipster" and "okta".
108
+
109
+ <%_ } else if (authenticationTypeJwt) { _%>
110
+
111
+ ### JWT authentication and authorization
112
+
113
+ Congratulations! You've selected an excellent way to secure your NHipster application. If you're not sure what JSON Web Token (JWT) is, please see [What the Heck is JWT?](https://jwt.io/introduction/)
114
+
115
+ Your app uses, to get and use the token, the `<%= nodeServerRootDir %>src/config/application.yml` settings:
116
+
117
+ ```yaml
118
+ ...
119
+ security:
120
+ authentication:
121
+ jwt:
122
+ # This token must be encoded using Base64 and be at least 512 bits long, like the HS512 key of JHipster Spring Boot (you can type `openssl rand -base64 64` on your command line to generate one)
123
+ base64-secret: {yourSecret}
124
+ # Token is valid 24 hours
125
+ token-validity-in-seconds: 86400
126
+ token-validity-in-seconds-for-remember-me: 2592000
127
+ ```
128
+
129
+ You can use the default secret created from the app, or change it.
130
+ <%_ if (generateBuiltInUserEntity) { _%>
131
+ So to get a token, you have to pass a POST request on the _api/authenticate_ url with **UserLoginDTO** as body.
132
+ For this you can use the client login page (if you have generated it), or a client like curl.
133
+ <%_ } else { _%>
134
+ This application has no users of its own: it validates the tokens issued by the application sharing this secret (like the gateway), and the user of a request is the one of its token.
135
+ <%_ } _%>
136
+ <%_ } else if (authenticationTypeSession) { _%>
137
+
138
+ ### Session authentication
139
+
140
+ Like JHipster Spring Boot with HTTP sessions, the client logs in by posting the `username`, `password` and `remember-me`
141
+ form to `api/authentication`, and logs out by posting to `api/logout`. The sessions are kept in the database of the
142
+ application (the `<%- jhiTablePrefix %>_session` table or collection): they outlive a restart and are shared by the instances of a
143
+ cluster. A session ends after 30 minutes without requests, 31 days with remember-me, and the account page lists the
144
+ sessions of the user, any of which it can end. Its unsafe requests, the login included, send the token of the
145
+ `XSRF-TOKEN` cookie as the `X-XSRF-TOKEN` header, as the JHipster clients do. The secret of the sessions is
146
+ `jhipster.security.session.secret`, set it in production with the `JHIPSTER_SECURITY_SESSION_SECRET` environment variable.
147
+ <%_ } _%>
148
+ <%_ if (generateUserManagement) { _%>
149
+
150
+ ### Account mails
151
+
152
+ Like JHipster Spring Boot, the server sends the account mails with [@nestjs-modules/mailer][] (Nodemailer): the activation mail of a registered user (who signs in once activated, with the link of the mail), the creation mail of a user created by an administrator and the password reset mail. Their HTML is the [Handlebars][] templates of `<%= nodeServerRootDir %>src/templates/mail/` (like the Thymeleaf templates of `templates/mail`; they interpolate values, escaped, and call the `message` helper of the server, they run no code), their texts the messages of `<%= nodeServerRootDir %>src/i18n/messages*.properties` in the language of the user, and their links open the client at `jhipster.mail.base-url`.
153
+
154
+ The SMTP server is set by the `mail` settings of `<%= nodeServerRootDir %>src/config/application-dev.yml` and `application-prod.yml` (`localhost:25` by default), or by environment variables like `MAIL_HOST`, `MAIL_PORT`, `MAIL_USERNAME` and `MAIL_PASSWORD`. A mail that cannot be sent is logged as a warning, without failing the request.
155
+ <%_ } _%>
156
+
157
+ ### Using NestJS CLI
158
+
159
+ You can also use [NestJS CLI][] to generate some custom server code.
160
+
161
+ For example, the following command:
162
+
163
+ nest generate module my-module
164
+
165
+ will generate the file:
166
+
167
+ create <%= nodeServerRootDir %>src/my-component/my-component.module.ts
168
+
169
+
170
+ ### Building and running
171
+
172
+ #### Running
173
+
174
+ ```bash
175
+ <%= nodePackageManager %> run app:start
176
+ ```
177
+
178
+ #### Building
179
+
180
+ ```bash
181
+ <%= nodePackageManager %> run build:app
182
+ ```
183
+
184
+ The build folder with all compiled sources will be **<%= nodeServerRootDir %>dist**.
185
+
186
+ > For more explanation about full stack server/client build refer to [<%= nodeServerRootDir %>README.md](<%= nodeServerRootDir %>README.md)
187
+
188
+ <&_ } -&>
189
+
190
+ <&_ if (fragment.othersSection) { -&>
191
+
192
+ ### Code quality using Sonar
193
+
194
+ Sonar is used to analyse code quality. You can start a local Sonar server (accessible on http://localhost:9001) with:
195
+
196
+ ```
197
+ docker compose -f <%- dockerServicesDir %>sonar.yml up -d
198
+ ```
199
+
200
+ Note: we have turned off forced authentication redirect for UI in [<%- dockerServicesDir %>sonar.yml](<%- dockerServicesDir %>sonar.yml) for out of the box experience while trying out SonarQube, for real use cases turn it back on.
201
+
202
+ You can run a Sonar analysis with using the [sonar-scanner](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner).
203
+ Then, run a Sonar analysis in the <%= nodeServerRootDir %> folder:
204
+
205
+ ```sh
206
+ npm run sonar:scanner
207
+ ```
208
+
209
+ For more information, refer to the [Code quality page][].
210
+
211
+ <&_ } -&>
212
+
213
+ <&_ if (fragment.referenceSection) { -&>
214
+ [Node.js]: https://nodejs.org/
215
+ [Vitest]: https://vitest.dev/
216
+ [NestJS]: https://nestjs.com/
217
+ [NestJS CLI]: https://docs.nestjs.com/cli/usages
218
+ [@nestjs-modules/mailer]: https://nest-modules.github.io/mailer/
219
+ [Handlebars]: https://handlebarsjs.com/
220
+ <&_ } -&>
@@ -0,0 +1,82 @@
1
+ <%#
2
+ Copyright 2019-2023 the original author or authors from the JHipster project.
3
+
4
+ This file is part of the JHipster project, see https://www.jhipster.tech/
5
+ for more information.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ https://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ -%>
19
+ {
20
+ "name": "<%= dasherizedBaseName %>",
21
+ "version": "0.0.0",
22
+ "description": "Description for <%= baseName %>",
23
+ "private": true,
24
+ "license": "UNLICENSED",
25
+ "cacheDirectories": [
26
+ "node_modules"
27
+ ],
28
+ "devDependencies": {
29
+ "@eslint/js": "<%- nodeServerDependencies['@eslint/js'] %>",
30
+ "concurrently": "<%= nodeDependencies['concurrently'] %>",
31
+ "eslint": "<%- nodeServerDependencies['eslint'] %>",
32
+ "eslint-config-prettier": "<%- nodeServerDependencies['eslint-config-prettier'] %>",
33
+ "globals": "<%- nodeServerDependencies['globals'] %>",
34
+ "prettier": "<%= nodeDependencies['prettier'] %>",
35
+ "prettier-plugin-packagejson": "<%= nodeDependencies['prettier-plugin-packagejson'] %>",
36
+ "typescript-eslint": "<%- nodeServerDependencies['typescript-eslint'] %>"<% if (clientFrameworkAny) { %>,
37
+ "wait-on": "<%= nodeDependencies['wait-on'] %>"<% } %>
38
+ },
39
+ "engines": {
40
+ "node": ">=<%= nodeVersion %>"
41
+ },
42
+ <%_ if (clientFrameworkAny) { _%>
43
+ "config": {
44
+ "backend_port": <%= serverPort %>
45
+ },
46
+ <%_ } _%>
47
+ "workspaces": [
48
+ "server"
49
+ ],
50
+ "scripts": {
51
+ "backend:start": "<%= clientPackageManager %> run start:server",
52
+ <%_ if (clientFrameworkAny) { _%>
53
+ "app:start": "<%= clientPackageManager %> run build && BACKEND_ENV=dev <%= clientPackageManager %> run start:prod -w server",
54
+ "ci:e2e:package": "<%= clientPackageManager %> run build",
55
+ <%_ if ((testFrameworks ?? []).some(testFramework => ['cypress', 'playwright'].includes(testFramework))) { _%>
56
+ "e2e": "<%= clientPackageManager %> run e2e -w client",
57
+ <%_ } _%>
58
+ "ci:e2e:server:start": "BACKEND_ENV=test <%= clientPackageManager %> run start:prod -w server",
59
+ "build": "<%= clientPackageManager %> run build -w server && <%= clientPackageManager %> run build -w client",
60
+ <%_ } else { _%>
61
+ "build": "<%= clientPackageManager %> run build -w server",
62
+ <%_ } _%>
63
+ "build:app": "<%= clientPackageManager %> run build -w server",
64
+ "ci:docker:build": "<%= clientPackageManager %> run docker:build",
65
+ "docker:build": "docker build -t <%= baseName.toLowerCase() %> .",
66
+ "lint": "<%= clientPackageManager %> run lint --workspaces",
67
+ "lint:fix": "<%= clientPackageManager %> run lint:fix --workspaces",
68
+ <%_ if (clientFrameworkAny) { _%>
69
+ "start": "concurrently -k -s first -n application,client -c red,green npm:start:server npm:start:client",
70
+ <%_ } else { _%>
71
+ "start": "<%= clientPackageManager %> run start:server",
72
+ <%_ } _%>
73
+ "start:server": "<%= clientPackageManager %> run start -w server",
74
+ <%_ if (clientFrameworkAny) { _%>
75
+ "start:client": "<%= clientPackageManager %> run start -w client",
76
+ "test:client": "<%= clientPackageManager %> test -w client",
77
+ <%_ } _%>
78
+ "test:server": "<%= clientPackageManager %> test -w server",
79
+ "test:server:e2e": "<%= clientPackageManager %> run test:e2e -w server",
80
+ "test": "<%= clientPackageManager %> test --workspaces"
81
+ }
82
+ }
@@ -0,0 +1,277 @@
1
+ <p align="center">
2
+ <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
3
+ </p>
4
+
5
+ [travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
6
+ [travis-url]: https://travis-ci.org/nestjs/nest
7
+ [linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
8
+ [linux-url]: https://travis-ci.org/nestjs/nest
9
+
10
+ <p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
13
+ <a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
14
+ <a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
15
+ <a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
16
+ <a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
17
+ <a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
18
+ <a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
19
+ <a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
20
+ <a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
21
+ <a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
22
+ <a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
23
+ </p>
24
+ <!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
25
+ [![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
26
+
27
+ ## Description
28
+
29
+ [NestJS Framework](https://github.com/nestjs/nest) server project generated from official [JHipster NodeJS blueprint](https://github.com/jhipster/generator-jhipster-nodejs).
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ $ npm install
35
+ ```
36
+
37
+ ## Project structure
38
+
39
+ The server is organized by feature, like the modules NestJS generates (`nest g resource`): each feature folder of `src`
40
+ has its module, its controllers, its services, its entities and its DTOs, the unit tests (`*.spec.ts`) next to the code
41
+ they test, the end-to-end tests in `e2e`.
42
+
43
+ - `src/entities/<entity>/`: an entity of the JDL, its TypeORM entity, its DTO (`dto/`), its mapper, its service, its
44
+ REST controller and its module; `src/entities/enumeration/` the enumerations of the entities.
45
+ <%_ if (generateBuiltInUserEntity) { _%>
46
+ - `src/users/`: the users and their authorities, their administration API.
47
+ <%_ } _%>
48
+ - `src/auth/`: the authentication, its guards, its decorators, its strategies and the account API.
49
+ <%_ if (generateUserManagement) { _%>
50
+ - `src/mail/`: the emails of the user management.
51
+ <%_ } _%>
52
+ - `src/management/`: the management endpoints (health, metrics, loggers, configuration, API documentation).
53
+ <%_ if (serviceDiscoveryAny) { _%>
54
+ - `src/registry/`: the registration of the service in its registry.
55
+ <%_ } _%>
56
+ - `src/common/`: the helpers of every feature: the errors, the HTTP helpers, the base entity and the column types
57
+ (`database/`), the base DTO.
58
+ - `src/config/`: the configuration of each profile; `src/migrations/`: the migrations of the database schema.
59
+
60
+ ## TypeORM configuration
61
+
62
+ ### The database of each profile
63
+
64
+ The database of each profile is the `database` section of its configuration file, read by
65
+ [src/orm.config.ts](src/orm.config.ts) (the TypeORM options):
66
+
67
+ - [src/config/application-dev.yml](src/config/application-dev.yml): the database of development, the one of the
68
+ `docker` folder<% if (databaseTypeSql) { %> (or a SQLite file)<% } %>;
69
+ - [src/config/application-test.yml](src/config/application-test.yml): <%= databaseTypeSql ? 'an in-memory SQLite database' : 'an in-memory MongoDB server' %> for the tests;
70
+ - [src/config/application-prod.yml](src/config/application-prod.yml): the production database, the service of the
71
+ docker compose files by default.
72
+
73
+ ```yaml
74
+ database:
75
+ type: <%= nodeProdDatabaseType %>
76
+ host: localhost
77
+ port: 5432
78
+ username: YOUR_USER
79
+ password: 'YOUR_PASSWORD'
80
+ name: YOUR_DATABASE_NAME
81
+ logging: false
82
+ ```
83
+
84
+ Like every property, an environment variable overrides them: `DATABASE_HOST`, `DATABASE_PORT`, `DATABASE_USERNAME`,
85
+ `DATABASE_PASSWORD`, `DATABASE_NAME`. Keep the production password out of the file this way.
86
+
87
+ ### Configuration from environment variables
88
+
89
+ Like in a Spring Boot application, an environment variable overrides a property of the `src/config/application*.yml`
90
+ files: its name is the property in upper case, with the dots as underscores and the dashes removed (or as
91
+ underscores). For example, `JHIPSTER_MAIL_BASEURL` sets `jhipster.mail.base-url`. Secrets, like the JWT secret, can
92
+ be kept out of the configuration files this way in production.
93
+
94
+ ### Migration data and schema
95
+
96
+ According [typeORM migration guide](https://github.com/typeorm/typeorm/blob/master/docs/migrations.md),
97
+ there are under [src/migrations/](src/migrations/) the scripts to create the database schema and after to insert data seed.
98
+ The application runs the ones not run yet at startup, in the order of the timestamp of their name.
99
+ <%_ if (databaseTypeSql) { _%>
100
+
101
+ Like the Liquibase changelogs of JHipster Spring Boot, JHipster generates the migrations of the schema: `CreateTables`
102
+ creates the tables of the users and of the authorities, then each entity has the migration adding its table
103
+ (`<timestamp>-AddedEntity<Entity>.ts`, the timestamp of its `changelogDate`) and, when it has relationships, the one adding
104
+ its foreign keys and its join tables (`<timestamp>-AddedEntityConstraints<Entity>.ts`, its timestamp plus 3000000000000),
105
+ run after the tables of every entity, like the constraints changelogs of Liquibase. A database the application ran them
106
+ on already is not changed by a regeneration of a migration.
107
+
108
+ Like the incremental changelogs of Liquibase, a regeneration keeps the migrations of an entity and generates the ones of
109
+ its changes since, run after the others (their timestamp plus <%= nodejsMigrationTimestampOffset %>):
110
+ `<timestamp>-UpdatedEntity<Entity>.ts` adds the columns of the added fields and drops the ones of the removed fields,
111
+ then `<timestamp>-UpdatedEntityConstraints<Entity>.ts` adds and drops the join columns, their foreign keys and the join
112
+ tables of the relationships, and `<timestamp>-RemovedEntity<Entity>.ts` drops the join tables and the table of a removed
113
+ entity, after the updates of the entities whose relationships referenced it. The changes are the changelogs JHipster
114
+ records in the `objects` of `.yo-rc.json`, one for each change of the database schema of an entity: keep them with the
115
+ migrations, the migrations of the application are the ones of its changelogs. A field changed (its type, its
116
+ validations) and a table renamed are not migrated, a dropped column or table keeps none of its values, and a required
117
+ field added to a table having rows needs a migration of your own giving them a value
118
+ (`npm run typeorm:migration:generate`).
119
+
120
+ The application runs the migrations [src/orm.config.ts](src/orm.config.ts) lists: import the class of a migration of
121
+ your own and add it to `migrations`, so the application runs it at startup, like the ones JHipster adds. The
122
+ `typeorm:migration:run` script runs every migration of the `src/migrations` folder (built in `dist/migrations`).
123
+
124
+ TypeORM runs the migrations in the order of the timestamp ending their class name. The `typeorm:migration:create` and
125
+ `typeorm:migration:generate` scripts give a migration of your own its time plus <%= nodejsMigrationTimestampOffset %>
126
+ (see [typeorm-migration.ts](typeorm-migration.ts)), so it runs after the migrations JHipster generates for the entities,
127
+ on an empty database too, like the changelogs added at the end of the `master.xml` of Liquibase.
128
+ <%_ } _%>
129
+
130
+ The `typeorm` npm scripts build the server and run the typeorm CLI on the database `BACKEND_ENV` selects (see
131
+ [ormconfig.ts](ormconfig.ts)):
132
+
133
+ ```bash
134
+ <%_ if (databaseTypeSql) { _%>
135
+ # generate a migration from the changes of the entities
136
+ $ npm run typeorm:migration:generate
137
+ <%_ } _%>
138
+ # create an empty migration
139
+ $ npm run typeorm:migration:create
140
+ # run, revert or list the migrations
141
+ $ npm run typeorm:migration:run
142
+ $ npm run typeorm:migration:revert
143
+ $ npm run typeorm:migration:show
144
+ <%_ if (databaseTypeSql) { _%>
145
+ # show the SQL that would synchronize the schema with the entities
146
+ $ npm run typeorm:schema:log
147
+ <%_ } _%>
148
+ ```
149
+ <%_ if (databaseTypeMongodb) { _%>
150
+
151
+ With MongoDB, they run on the MongoDB of the dev profile (`npm run docker:db:up`), the test profile using an in-memory server. MongoDB has no
152
+ schema to compare, so migrations are written by hand with the MongoDB API (`queryRunner.query()` does not support
153
+ MongoDB): use `queryRunner.dataSource.mongoManager`.
154
+ <%_ } _%>
155
+
156
+ ## Running the app
157
+
158
+ ```bash
159
+ # development
160
+ $ npm run start
161
+
162
+ # watch mode
163
+ $ npm run start:dev
164
+
165
+ # build transpiling files in javascript
166
+ $ npm run build
167
+
168
+ # run javascript build from the source project
169
+ $ npm run start:prod
170
+
171
+ # run javascript build with node
172
+ $ node dist/main.js
173
+ ```
174
+
175
+ ### Development profile and .env file
176
+
177
+ The development scripts (`npm start`, `npm run start:dev`, `npm run start:debug`) run with the **BACKEND_ENV** of the
178
+ [.env.dev](.env.dev) file, **dev**: the dev database and settings, the sample secrets and the API documentation. The
179
+ built application (`npm run start:prod`, `node dist/main.js`, the Docker image) does not read it, like a Spring Boot jar
180
+ built with the prod profile: set **BACKEND_ENV** where it runs, like `prod`.
181
+
182
+ An optional `.env` file, ignored by git, holds local settings, like secrets: the application loads it with
183
+ [dotenv](https://www.npmjs.com/package/dotenv) when it exists. A variable set in the environment wins over both files.
184
+
185
+ ### Profiles
186
+
187
+ Like `spring.profiles.active` in a Spring Boot application, **BACKEND_ENV** is a comma separated list of profiles, for
188
+ example `prod,api-docs`. Each profile loads its `application-{profile}.yml` file of the [config folder](src/config), when
189
+ there is one, in the order of the list (the last one wins), and the profiles of its group (`profiles.group` of
190
+ [application.yml](src/config/application.yml)): `dev` activates `secret-samples` and `api-docs`, `test` activates
191
+ `secret-samples`. The standard profiles are:
192
+
193
+ - `dev`, `prod` and `test`: the database and the settings of each environment;
194
+ - `api-docs`: the OpenAPI document of the API at `/v3/api-docs`, for the administrators like JHipster Spring Boot<%= skipClient ? '' : ', read by the API page of the client' %>;
195
+ - `secret-samples`: samples of the secrets (<%= authenticationType === 'oauth2' ? 'the session secret and the OAuth2 client' : authenticationType === 'session' ? 'the session secret' : 'the JWT secret' %><%= databaseTypeSql ? ', the username and the password of the database' : '' %>) for development and CI, in
196
+ [application-secret-samples.yml](src/config/application-secret-samples.yml). In production, set them with environment
197
+ variables instead, like `<%= authenticationType === 'oauth2' ? 'JHIPSTER_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENTSECRET' : authenticationType === 'session' ? 'JHIPSTER_SECURITY_SESSION_SECRET' : 'JHIPSTER_SECURITY_AUTHENTICATION_JWT_BASE64SECRET' %>`;
198
+ - `tls`: HTTPS, with your PKCS#12 keystore (`SERVER_SSL_KEY_STORE` and `SERVER_SSL_KEY_STORE_PASSWORD`);
199
+ - `tls-samples`: with `tls`, the self-signed sample keystore of [src/config/tls](src/config/tls), for development only.
200
+
201
+ > You can define your custom profiles, with an application-{profile}.yml file in your [config folder](src/config); an
202
+ > environment of its own needs the `database` section of that environment.
203
+
204
+ The `/management/info` endpoint gives the active profiles to the client, which shows its ribbon on the
205
+ `info.display-ribbon-on-profiles` ones.
206
+
207
+ **BACKEND_ENV** can also be set in the environment of the process.
208
+ For example:
209
+
210
+ ```bash
211
+
212
+ # development in prod environment, with the API documentation and the sample secrets
213
+ # in linux
214
+ $ BACKEND_ENV=prod,api-docs,secret-samples npm run start
215
+ # in windows
216
+ $ set BACKEND_ENV=prod,api-docs,secret-samples&& npm run start
217
+
218
+ # run javascript build with node in prod environment
219
+ # in linux
220
+ $ BACKEND_ENV=prod node dist/main.js
221
+ # in windows
222
+ $ set BACKEND_ENV=prod&& node dist/main.js
223
+ ```
224
+
225
+ ## Lint
226
+
227
+ ```bash
228
+ # run lint
229
+ $ npm run lint
230
+
231
+ # fix lint issues
232
+ $ npm run lint:fix
233
+
234
+ ```
235
+
236
+ ## Debug
237
+
238
+ ```bash
239
+ # run this and after you can execute debug task in VSCode
240
+ $ npm run start:debug
241
+
242
+ ```
243
+
244
+ ## Test
245
+
246
+ ```bash
247
+ # unit tests
248
+ $ npm run test
249
+
250
+ # lint
251
+ $ npm run lint
252
+
253
+ # fix lint issues
254
+ $ npm run lint:fix
255
+
256
+ # test coverage of unit tests
257
+ $ npm run test:cov
258
+
259
+ # e2e tests with full app coverage report
260
+ $ npm run test:e2e
261
+
262
+ ```
263
+
264
+ ## Support
265
+
266
+ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
267
+
268
+ ## Stay in touch
269
+
270
+ - Community - [jhipster homepage](https://www.jhipster.tech)
271
+ - Stream Lead - [Angelo Manganiello](https://github.com/amanganiello90)
272
+ - Website And Guide - [https://nestjs.com](https://nestjs.com/)
273
+ - Twitter - [@nestframework](https://twitter.com/nestframework)
274
+
275
+ ## License
276
+
277
+ Nest is [MIT licensed](LICENSE).