@mshima/generator-jhipster-nodejs 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +204 -0
- package/README.md +243 -2
- package/build-info.json +3 -0
- package/cli/cli-customizations.cjs +9 -0
- package/cli/cli.cjs +40 -0
- package/cli/logo.js +31 -0
- package/cli/version.cjs +12 -0
- package/generators/ci-cd/USAGE +5 -0
- package/generators/ci-cd/command.js +5 -0
- package/generators/ci-cd/generator.js +158 -0
- package/generators/ci-cd/index.js +2 -0
- package/generators/ci-cd/templates/.gitlab-ci.yml.ejs +137 -0
- package/generators/ci-cd/templates/azure-pipelines.yml.ejs +68 -0
- package/generators/ci-cd/templates/circle.yml.ejs +59 -0
- package/generators/ci-cd/templates/docker-registry.yml.ejs +58 -0
- package/generators/ci-cd/templates/github-ci.yml.ejs +90 -0
- package/generators/ci-cd/templates/jenkins/Jenkinsfile.ejs +104 -0
- package/generators/ci-cd/templates/jenkins/idea.gdsl +90 -0
- package/generators/ci-cd/templates/jenkins/jenkins.yml.ejs +33 -0
- package/generators/ci-cd/templates/travis.yml.ejs +75 -0
- package/generators/client/command.js +5 -0
- package/generators/client/generator.js +21 -0
- package/generators/client/generators/bootstrap/command.js +5 -0
- package/generators/client/generators/bootstrap/generator.js +28 -0
- package/generators/client/generators/bootstrap/index.js +2 -0
- package/generators/client/index.js +2 -0
- package/generators/common/generators/bootstrap/command.js +5 -0
- package/generators/common/generators/bootstrap/generator.js +37 -0
- package/generators/common/generators/bootstrap/index.js +2 -0
- package/generators/docker/command.js +5 -0
- package/generators/docker/generator.js +16 -0
- package/generators/docker/generators/bootstrap/command.js +5 -0
- package/generators/docker/generators/bootstrap/generator.js +56 -0
- package/generators/docker/generators/bootstrap/index.js +2 -0
- package/generators/docker/index.js +2 -0
- package/generators/docker/templates/docker/app.yml.ejs +25 -0
- package/generators/generator-nodejs-constants.js +32 -0
- package/generators/languages/command.js +5 -0
- package/generators/languages/generator.js +22 -0
- package/generators/languages/index.js +2 -0
- package/generators/languages/templates/src/main/webapp/i18n/en/home.json +19 -0
- package/generators/languages/templates/src/main/webapp/i18n/es/home.json +19 -0
- package/generators/languages/templates/src/main/webapp/i18n/it/home.json +19 -0
- package/generators/node-server/command.js +96 -0
- package/generators/node-server/entity-files.js +41 -0
- package/generators/node-server/files.js +254 -0
- package/generators/node-server/generator.js +702 -0
- package/generators/node-server/generators/bootstrap/command.js +5 -0
- package/generators/node-server/generators/bootstrap/generator.js +83 -0
- package/generators/node-server/generators/bootstrap/index.js +2 -0
- package/generators/node-server/index.js +2 -0
- package/generators/node-server/resources/package.json +76 -0
- package/generators/node-server/support/api-fake-data.js +54 -0
- package/generators/node-server/support/columns.js +73 -0
- package/generators/node-server/support/database.js +24 -0
- package/generators/node-server/support/entity-authorities.js +32 -0
- package/generators/node-server/support/entity-paths.js +13 -0
- package/generators/node-server/support/enums.js +11 -0
- package/generators/node-server/support/index.js +9 -0
- package/generators/node-server/support/mail-templates.js +82 -0
- package/generators/node-server/support/migrations.js +197 -0
- package/generators/node-server/support/validators.js +25 -0
- package/generators/node-server/templates/.dockerignore.ejs +16 -0
- package/generators/node-server/templates/.gitignore.jhi.nodejs.ejs +24 -0
- package/generators/node-server/templates/Dockerfile.ejs +54 -0
- package/generators/node-server/templates/README.md.jhi.nodejs.ejs +220 -0
- package/generators/node-server/templates/package.json.ejs +84 -0
- package/generators/node-server/templates/server/README.md.ejs +269 -0
- package/generators/node-server/templates/server/e2e/_entityFileName_.database.e2e-spec.ts.ejs +192 -0
- package/generators/node-server/templates/server/e2e/_entityFileName_.e2e-spec.ts.ejs +402 -0
- package/generators/node-server/templates/server/e2e/account.e2e-spec.ts.ejs +349 -0
- package/generators/node-server/templates/server/e2e/app.e2e-spec.ts.ejs +188 -0
- package/generators/node-server/templates/server/e2e/authority.e2e-spec.ts.ejs +50 -0
- package/generators/node-server/templates/server/e2e/cors.e2e-spec.ts.ejs +110 -0
- package/generators/node-server/templates/server/e2e/management.e2e-spec.ts.ejs +180 -0
- package/generators/node-server/templates/server/e2e/oauth2-bearer.e2e-spec.ts.ejs +71 -0
- package/generators/node-server/templates/server/e2e/session.e2e-spec.ts.ejs +219 -0
- package/generators/node-server/templates/server/e2e/setup.test.js.ejs +1 -0
- package/generators/node-server/templates/server/e2e/user.e2e-spec.ts.ejs +318 -0
- package/generators/node-server/templates/server/env.ejs +1 -0
- package/generators/node-server/templates/server/eslint.config.mjs.ejs +48 -0
- package/generators/node-server/templates/server/nest-cli.json.ejs +11 -0
- package/generators/node-server/templates/server/ormconfig.ts.ejs +35 -0
- package/generators/node-server/templates/server/package.json.ejs +143 -0
- package/generators/node-server/templates/server/sonar-project.properties.ejs +10 -0
- package/generators/node-server/templates/server/src/app.config.spec.ts.ejs +13 -0
- package/generators/node-server/templates/server/src/app.config.ts.ejs +179 -0
- package/generators/node-server/templates/server/src/app.module.ts.ejs +80 -0
- package/generators/node-server/templates/server/src/application-config.ts.ejs +153 -0
- package/generators/node-server/templates/server/src/auth/account.controller.ts.ejs +183 -0
- package/generators/node-server/templates/server/src/auth/auth.module.ts.ejs +104 -0
- package/generators/node-server/templates/server/src/auth/auth.service.ts.ejs +294 -0
- package/generators/node-server/templates/server/src/auth/csrf.middleware.spec.ts.ejs +65 -0
- package/generators/node-server/templates/server/src/auth/csrf.middleware.ts.ejs +76 -0
- package/generators/node-server/templates/server/src/auth/decorators/auth-user.decorator.ts.ejs +8 -0
- package/generators/node-server/templates/server/src/auth/decorators/roles.decorator.ts.ejs +4 -0
- package/generators/node-server/templates/server/src/auth/dto/key-and-password.dto.ts.ejs +17 -0
- package/generators/node-server/templates/server/src/auth/dto/password-change.dto.ts.ejs +17 -0
- package/generators/node-server/templates/server/src/auth/dto/user-login.dto.ts.ejs +21 -0
- package/generators/node-server/templates/server/src/auth/guards/auth.guard.ts.ejs +50 -0
- package/generators/node-server/templates/server/src/auth/guards/oauth2-login.guard.ts.ejs +6 -0
- package/generators/node-server/templates/server/src/auth/guards/roles.guard.ts.ejs +25 -0
- package/generators/node-server/templates/server/src/auth/index.ts.ejs +8 -0
- package/generators/node-server/templates/server/src/auth/jwt.config.spec.ts.ejs +22 -0
- package/generators/node-server/templates/server/src/auth/jwt.config.ts.ejs +29 -0
- package/generators/node-server/templates/server/src/auth/oauth2.authorities.spec.ts.ejs +24 -0
- package/generators/node-server/templates/server/src/auth/oauth2.authorities.ts.ejs +33 -0
- package/generators/node-server/templates/server/src/auth/oauth2.config.ts.ejs +51 -0
- package/generators/node-server/templates/server/src/auth/passport.jwt.strategy.ts.ejs +45 -0
- package/generators/node-server/templates/server/src/auth/passport.oauth2-bearer.strategy.ts.ejs +32 -0
- package/generators/node-server/templates/server/src/auth/passport.oauth2.strategy.spec.ts.ejs +27 -0
- package/generators/node-server/templates/server/src/auth/passport.oauth2.strategy.ts.ejs +44 -0
- package/generators/node-server/templates/server/src/auth/password-util.ts.ejs +10 -0
- package/generators/node-server/templates/server/src/auth/password.service.ts.ejs +34 -0
- package/generators/node-server/templates/server/src/auth/payload.interface.ts.ejs +14 -0
- package/generators/node-server/templates/server/src/auth/role-type.ts.ejs +7 -0
- package/generators/node-server/templates/server/src/auth/session-user.middleware.ts.ejs +33 -0
- package/generators/node-server/templates/server/src/auth/session.entity.ts.ejs +36 -0
- package/generators/node-server/templates/server/src/auth/session.store.spec.ts.ejs +99 -0
- package/generators/node-server/templates/server/src/auth/session.store.ts.ejs +116 -0
- package/generators/node-server/templates/server/src/auth/user.jwt.controller.ts.ejs +26 -0
- package/generators/node-server/templates/server/src/auth/user.oauth2.controller.ts.ejs +78 -0
- package/generators/node-server/templates/server/src/auth/user.session.controller.ts.ejs +103 -0
- package/generators/node-server/templates/server/src/common/common.module.ts.ejs +19 -0
- package/generators/node-server/templates/server/src/common/database/base.entity.ts.ejs +13 -0
- package/generators/node-server/templates/server/src/common/database/column-transformers.spec.ts.ejs +46 -0
- package/generators/node-server/templates/server/src/common/database/column-transformers.ts.ejs +69 -0
- package/generators/node-server/templates/server/src/common/database/column-types.spec.ts.ejs +21 -0
- package/generators/node-server/templates/server/src/common/database/column-types.ts.ejs +29 -0
- package/generators/node-server/templates/server/src/common/database/pagination.entity.spec.ts.ejs +66 -0
- package/generators/node-server/templates/server/src/common/database/pagination.entity.ts.ejs +108 -0
- package/generators/node-server/templates/server/src/common/dto/base.dto.ts.ejs +19 -0
- package/generators/node-server/templates/server/src/common/errors/error-constants.ts.ejs +10 -0
- package/generators/node-server/templates/server/src/common/errors/problem-details.filter.ts.ejs +63 -0
- package/generators/node-server/templates/server/src/common/errors/problem.exception.ts.ejs +92 -0
- package/generators/node-server/templates/server/src/common/field_validators.ejs +77 -0
- package/generators/node-server/templates/server/src/common/header-util.ts.ejs +105 -0
- package/generators/node-server/templates/server/src/common/interceptors/logging.interceptor.spec.ts.ejs +93 -0
- package/generators/node-server/templates/server/src/common/interceptors/logging.interceptor.ts.ejs +48 -0
- package/generators/node-server/templates/server/src/common/logging.spec.ts.ejs +83 -0
- package/generators/node-server/templates/server/src/common/logging.ts.ejs +129 -0
- package/generators/node-server/templates/server/src/common/metrics.spec.ts.ejs +43 -0
- package/generators/node-server/templates/server/src/common/metrics.ts.ejs +198 -0
- package/generators/node-server/templates/server/src/common/request.ts.ejs +8 -0
- package/generators/node-server/templates/server/src/common/sortable-properties.ts.ejs +43 -0
- package/generators/node-server/templates/server/src/common/updatable-properties.ts.ejs +14 -0
- package/generators/node-server/templates/server/src/config/application-dev.yml.ejs +118 -0
- package/generators/node-server/templates/server/src/config/application-prod.yml.ejs +97 -0
- package/generators/node-server/templates/server/src/config/application-secret-samples.yml.ejs +42 -0
- package/generators/node-server/templates/server/src/config/application-test.yml.ejs +68 -0
- package/generators/node-server/templates/server/src/config/application-tls-samples.yml.ejs +15 -0
- package/generators/node-server/templates/server/src/config/application-tls.yml.ejs +15 -0
- package/generators/node-server/templates/server/src/config/application.yml.ejs +149 -0
- package/generators/node-server/templates/server/src/config.spec.ts.ejs +81 -0
- package/generators/node-server/templates/server/src/config.ts.ejs +255 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.controller.ts.ejs +178 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.entity.ts.ejs +110 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.mapper.ts.ejs +37 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.module.ts.ejs +14 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.service.ts.ejs +123 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/dto/_entityFileName_.dto.ts.ejs +99 -0
- package/generators/node-server/templates/server/src/mail/mail.module.ts.ejs +49 -0
- package/generators/node-server/templates/server/src/mail/mail.service.spec.ts.ejs +105 -0
- package/generators/node-server/templates/server/src/mail/mail.service.ts.ejs +120 -0
- package/generators/node-server/templates/server/src/main.ts.ejs +114 -0
- package/generators/node-server/templates/server/src/management/api-docs.controller.ts.ejs +27 -0
- package/generators/node-server/templates/server/src/management/api-docs.service.ts.ejs +8 -0
- package/generators/node-server/templates/server/src/management/configuration.controller.ts.ejs +80 -0
- package/generators/node-server/templates/server/src/management/health.controller.spec.ts.ejs +79 -0
- package/generators/node-server/templates/server/src/management/health.controller.ts.ejs +87 -0
- package/generators/node-server/templates/server/src/management/health.module.ts.ejs +9 -0
- package/generators/node-server/templates/server/src/management/loggers.controller.ts.ejs +40 -0
- package/generators/node-server/templates/server/src/management/management.controller.spec.ts.ejs +26 -0
- package/generators/node-server/templates/server/src/management/management.controller.ts.ejs +34 -0
- package/generators/node-server/templates/server/src/management/management.module.ts.ejs +21 -0
- package/generators/node-server/templates/server/src/management/metrics.controller.ts.ejs +85 -0
- package/generators/node-server/templates/server/src/migrations/1570200270081-CreateTables.ts.ejs +64 -0
- package/generators/node-server/templates/server/src/migrations/1570200270082-CreateSessions.ts.ejs +26 -0
- package/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs +74 -0
- package/generators/node-server/templates/server/src/migrations/_entityConstraintsMigration_.ts.ejs +40 -0
- package/generators/node-server/templates/server/src/migrations/_entityMigration_.ts.ejs +26 -0
- package/generators/node-server/templates/server/src/migrations/support/schema.ts.ejs +202 -0
- package/generators/node-server/templates/server/src/orm.config.ts.ejs +147 -0
- package/generators/node-server/templates/server/src/registry/consul.service.ts.ejs +70 -0
- package/generators/node-server/templates/server/src/registry/eureka.service.ts.ejs +129 -0
- package/generators/node-server/templates/server/src/swagger.ts.ejs +24 -0
- package/generators/node-server/templates/server/src/tls.ts.ejs +27 -0
- package/generators/node-server/templates/server/src/users/authority.controller.ts.ejs +85 -0
- package/generators/node-server/templates/server/src/users/authority.entity.ts.ejs +22 -0
- package/generators/node-server/templates/server/src/users/dto/authority.dto.ts.ejs +10 -0
- package/generators/node-server/templates/server/src/users/dto/user.dto.ts.ejs +116 -0
- package/generators/node-server/templates/server/src/users/public.user.controller.ts.ejs +51 -0
- package/generators/node-server/templates/server/src/users/user.controller.ts.ejs +191 -0
- package/generators/node-server/templates/server/src/users/user.entity.ts.ejs +63 -0
- package/generators/node-server/templates/server/src/users/user.mapper.ts.ejs +26 -0
- package/generators/node-server/templates/server/src/users/user.module.ts.ejs +19 -0
- package/generators/node-server/templates/server/src/users/user.service.ts.ejs +156 -0
- package/generators/node-server/templates/server/tsconfig.build.json.ejs +9 -0
- package/generators/node-server/templates/server/tsconfig.json.ejs +23 -0
- package/generators/node-server/templates/server/typeorm-migration.ts.ejs +18 -0
- package/generators/node-server/templates/server/vitest.config.e2e.ts.ejs +16 -0
- package/generators/node-server/templates/server/vitest.config.ts.ejs +16 -0
- package/generators/server/command.js +7 -0
- package/generators/server/generator.js +20 -0
- package/generators/server/generators/bootstrap/command.js +5 -0
- package/generators/server/generators/bootstrap/generator.js +15 -0
- package/generators/server/generators/bootstrap/index.js +2 -0
- package/generators/server/index.js +2 -0
- package/package.json +75 -4
|
@@ -0,0 +1,269 @@
|
|
|
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
|
+
<!--[](https://opencollective.com/nest#backer)
|
|
25
|
+
[](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: when an entity changes, add the migration of the change
|
|
107
|
+
(`npm run typeorm:migration:generate`) or recreate the development database. Like the Liquibase changelogs without
|
|
108
|
+
incremental changelogs, a regeneration rewrites the migrations of the entity changed (a new column in the migration of its
|
|
109
|
+
table): restore the migrations a database ran already (`git restore src/migrations`), keeping the entities, before
|
|
110
|
+
generating the migration of the change, so an empty database runs them all.
|
|
111
|
+
|
|
112
|
+
The application runs the migrations [src/orm.config.ts](src/orm.config.ts) lists: import the class of a migration of
|
|
113
|
+
your own and add it to `migrations`, so the application runs it at startup, like the ones JHipster adds. The
|
|
114
|
+
`typeorm:migration:run` script runs every migration of the `src/migrations` folder (built in `dist/migrations`).
|
|
115
|
+
|
|
116
|
+
TypeORM runs the migrations in the order of the timestamp ending their class name. The `typeorm:migration:create` and
|
|
117
|
+
`typeorm:migration:generate` scripts give a migration of your own its time plus <%= nodejsMigrationTimestampOffset %>
|
|
118
|
+
(see [typeorm-migration.ts](typeorm-migration.ts)), so it runs after the migrations JHipster generates for the entities,
|
|
119
|
+
on an empty database too, like the changelogs added at the end of the `master.xml` of Liquibase.
|
|
120
|
+
<%_ } _%>
|
|
121
|
+
|
|
122
|
+
The `typeorm` npm scripts build the server and run the typeorm CLI on the database `BACKEND_ENV` selects (see
|
|
123
|
+
[ormconfig.ts](ormconfig.ts)):
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
<%_ if (databaseTypeSql) { _%>
|
|
127
|
+
# generate a migration from the changes of the entities
|
|
128
|
+
$ npm run typeorm:migration:generate
|
|
129
|
+
<%_ } _%>
|
|
130
|
+
# create an empty migration
|
|
131
|
+
$ npm run typeorm:migration:create
|
|
132
|
+
# run, revert or list the migrations
|
|
133
|
+
$ npm run typeorm:migration:run
|
|
134
|
+
$ npm run typeorm:migration:revert
|
|
135
|
+
$ npm run typeorm:migration:show
|
|
136
|
+
<%_ if (databaseTypeSql) { _%>
|
|
137
|
+
# show the SQL that would synchronize the schema with the entities
|
|
138
|
+
$ npm run typeorm:schema:log
|
|
139
|
+
<%_ } _%>
|
|
140
|
+
```
|
|
141
|
+
<%_ if (databaseTypeMongodb) { _%>
|
|
142
|
+
|
|
143
|
+
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
|
|
144
|
+
schema to compare, so migrations are written by hand with the MongoDB API (`queryRunner.query()` does not support
|
|
145
|
+
MongoDB): use `queryRunner.dataSource.mongoManager`.
|
|
146
|
+
<%_ } _%>
|
|
147
|
+
|
|
148
|
+
## Running the app
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# development
|
|
152
|
+
$ npm run start
|
|
153
|
+
|
|
154
|
+
# watch mode
|
|
155
|
+
$ npm run start:dev
|
|
156
|
+
|
|
157
|
+
# build transpiling files in javascript
|
|
158
|
+
$ npm run build
|
|
159
|
+
|
|
160
|
+
# run javascript build from the source project
|
|
161
|
+
$ npm run start:prod
|
|
162
|
+
|
|
163
|
+
# run javascript build with node
|
|
164
|
+
$ node dist/main.js
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Development profile and .env file
|
|
168
|
+
|
|
169
|
+
The development scripts (`npm start`, `npm run start:dev`, `npm run start:debug`) run with the **BACKEND_ENV** of the
|
|
170
|
+
[.env.dev](.env.dev) file, **dev**: the dev database and settings, the sample secrets and the API documentation. The
|
|
171
|
+
built application (`npm run start:prod`, `node dist/main.js`, the Docker image) does not read it, like a Spring Boot jar
|
|
172
|
+
built with the prod profile: set **BACKEND_ENV** where it runs, like `prod`.
|
|
173
|
+
|
|
174
|
+
An optional `.env` file, ignored by git, holds local settings, like secrets: the application loads it with
|
|
175
|
+
[dotenv](https://www.npmjs.com/package/dotenv) when it exists. A variable set in the environment wins over both files.
|
|
176
|
+
|
|
177
|
+
### Profiles
|
|
178
|
+
|
|
179
|
+
Like `spring.profiles.active` in a Spring Boot application, **BACKEND_ENV** is a comma separated list of profiles, for
|
|
180
|
+
example `prod,api-docs`. Each profile loads its `application-{profile}.yml` file of the [config folder](src/config), when
|
|
181
|
+
there is one, in the order of the list (the last one wins), and the profiles of its group (`profiles.group` of
|
|
182
|
+
[application.yml](src/config/application.yml)): `dev` activates `secret-samples` and `api-docs`, `test` activates
|
|
183
|
+
`secret-samples`. The standard profiles are:
|
|
184
|
+
|
|
185
|
+
- `dev`, `prod` and `test`: the database and the settings of each environment;
|
|
186
|
+
- `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' %>;
|
|
187
|
+
- `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
|
|
188
|
+
[application-secret-samples.yml](src/config/application-secret-samples.yml). In production, set them with environment
|
|
189
|
+
variables instead, like `<%= authenticationType === 'oauth2' ? 'JHIPSTER_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENTSECRET' : authenticationType === 'session' ? 'JHIPSTER_SECURITY_SESSION_SECRET' : 'JHIPSTER_SECURITY_AUTHENTICATION_JWT_BASE64SECRET' %>`;
|
|
190
|
+
- `tls`: HTTPS, with your PKCS#12 keystore (`SERVER_SSL_KEY_STORE` and `SERVER_SSL_KEY_STORE_PASSWORD`);
|
|
191
|
+
- `tls-samples`: with `tls`, the self-signed sample keystore of [src/config/tls](src/config/tls), for development only.
|
|
192
|
+
|
|
193
|
+
> You can define your custom profiles, with an application-{profile}.yml file in your [config folder](src/config); an
|
|
194
|
+
> environment of its own needs the `database` section of that environment.
|
|
195
|
+
|
|
196
|
+
The `/management/info` endpoint gives the active profiles to the client, which shows its ribbon on the
|
|
197
|
+
`info.display-ribbon-on-profiles` ones.
|
|
198
|
+
|
|
199
|
+
**BACKEND_ENV** can also be set in the environment of the process.
|
|
200
|
+
For example:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
|
|
204
|
+
# development in prod environment, with the API documentation and the sample secrets
|
|
205
|
+
# in linux
|
|
206
|
+
$ BACKEND_ENV=prod,api-docs,secret-samples npm run start
|
|
207
|
+
# in windows
|
|
208
|
+
$ set BACKEND_ENV=prod,api-docs,secret-samples&& npm run start
|
|
209
|
+
|
|
210
|
+
# run javascript build with node in prod environment
|
|
211
|
+
# in linux
|
|
212
|
+
$ BACKEND_ENV=prod node dist/main.js
|
|
213
|
+
# in windows
|
|
214
|
+
$ set BACKEND_ENV=prod&& node dist/main.js
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Lint
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# run lint
|
|
221
|
+
$ npm run lint
|
|
222
|
+
|
|
223
|
+
# fix lint issues
|
|
224
|
+
$ npm run lint:fix
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Debug
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# run this and after you can execute debug task in VSCode
|
|
232
|
+
$ npm run start:debug
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Test
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# unit tests
|
|
240
|
+
$ npm run test
|
|
241
|
+
|
|
242
|
+
# lint
|
|
243
|
+
$ npm run lint
|
|
244
|
+
|
|
245
|
+
# fix lint issues
|
|
246
|
+
$ npm run lint:fix
|
|
247
|
+
|
|
248
|
+
# test coverage of unit tests
|
|
249
|
+
$ npm run test:cov
|
|
250
|
+
|
|
251
|
+
# e2e tests with full app coverage report
|
|
252
|
+
$ npm run test:e2e
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Support
|
|
257
|
+
|
|
258
|
+
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).
|
|
259
|
+
|
|
260
|
+
## Stay in touch
|
|
261
|
+
|
|
262
|
+
- Community - [jhipster homepage](https://www.jhipster.tech)
|
|
263
|
+
- Stream Lead - [Angelo Manganiello](https://github.com/amanganiello90)
|
|
264
|
+
- Website And Guide - [https://nestjs.com](https://nestjs.com/)
|
|
265
|
+
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
|
266
|
+
|
|
267
|
+
## License
|
|
268
|
+
|
|
269
|
+
Nest is [MIT licensed](LICENSE).
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<%_
|
|
2
|
+
// The values of the fields as the API exchanges them, reproducible: the faker of the entity is seeded for this test.
|
|
3
|
+
resetFakerSeed('nodejs-database-e2e');
|
|
4
|
+
const created = nodejsApiFakeEntity();
|
|
5
|
+
const updated = nodejsApiFakeEntity();
|
|
6
|
+
const approximateFields = created.approximateFields;
|
|
7
|
+
// The relationships of the entity with a join column or a join table (the persistableRelationships of JHipster): stored
|
|
8
|
+
// by the id of the related record.
|
|
9
|
+
const storedRelationships = databaseTypeSql ? persistableRelationships : [];
|
|
10
|
+
const anyUserRelationship = storedRelationships.some(relationship => relationship.otherEntity.builtInUser);
|
|
11
|
+
// The relationships the other entity stores (nodejsMappedByRelationships), with another entity of the application.
|
|
12
|
+
const inverseRelationships = databaseTypeSql
|
|
13
|
+
? nodejsMappedByRelationships.filter(relationship => !relationship.otherEntity.builtIn && relationship.otherRelationship?.propertyName)
|
|
14
|
+
: [];
|
|
15
|
+
const literal = value => JSON.stringify(value);
|
|
16
|
+
_%>
|
|
17
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
18
|
+
import { INestApplication } from '@nestjs/common';
|
|
19
|
+
import { Test, TestingModule } from '@nestjs/testing';
|
|
20
|
+
import request from 'supertest';
|
|
21
|
+
<%_ if (anyUserRelationship) { _%>
|
|
22
|
+
import { DataSource } from 'typeorm';
|
|
23
|
+
<%_ } _%>
|
|
24
|
+
|
|
25
|
+
import { AppModule } from '../src/app.module.ts';
|
|
26
|
+
import { configureApp } from '../src/app.config.ts';
|
|
27
|
+
<%_ if (anyUserRelationship) { _%>
|
|
28
|
+
import { <%= user.persistClass %> } from '../src/users/user.entity.ts';
|
|
29
|
+
<%_ } _%>
|
|
30
|
+
import { AuthGuard } from '../src/auth/guards/auth.guard.ts';
|
|
31
|
+
import { RolesGuard } from '../src/auth/guards/roles.guard.ts';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* <%= entityClass %> stored in the database and read back through the REST API, like the resource tests of JHipster
|
|
35
|
+
* Spring Boot: the values of every field as the API exchanges them<% if (storedRelationships.length > 0) { %>, and the relationships stored by the id of the related
|
|
36
|
+
* record, without changing it<% } %>.
|
|
37
|
+
*/
|
|
38
|
+
describe('<%= entityClass %> on the database', () => {
|
|
39
|
+
let app: INestApplication;
|
|
40
|
+
|
|
41
|
+
// The values of the fields, of a creation then of an update.
|
|
42
|
+
const createdValues: Record<string, any> = {
|
|
43
|
+
<%_ for (const [name, value] of Object.entries(created.values)) { _%>
|
|
44
|
+
<%= name %>: <%- literal(value) %>,
|
|
45
|
+
<%_ } _%>
|
|
46
|
+
};
|
|
47
|
+
const updatedValues: Record<string, any> = {
|
|
48
|
+
<%_ for (const [name, value] of Object.entries(updated.values)) { _%>
|
|
49
|
+
<%= name %>: <%- literal(value) %>,
|
|
50
|
+
<%_ } _%>
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** The values read back: a Float is approximate on the databases keeping it in single precision. */
|
|
54
|
+
const expected = (values: Record<string, any>): Record<string, any> => ({
|
|
55
|
+
...values,
|
|
56
|
+
<%_ for (const name of approximateFields) { _%>
|
|
57
|
+
<%= name %>: expect.closeTo(values.<%= name %>, 1),
|
|
58
|
+
<%_ } _%>
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
beforeAll(async () => {
|
|
62
|
+
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
63
|
+
imports: [AppModule],
|
|
64
|
+
})
|
|
65
|
+
.overrideGuard(AuthGuard)
|
|
66
|
+
.useValue({ canActivate: () => true })
|
|
67
|
+
.overrideGuard(RolesGuard)
|
|
68
|
+
.useValue({ canActivate: () => true })
|
|
69
|
+
.compile();
|
|
70
|
+
|
|
71
|
+
app = moduleFixture.createNestApplication();
|
|
72
|
+
configureApp(app);
|
|
73
|
+
await app.init();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
afterAll(async () => {
|
|
77
|
+
await app?.close();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('should store every field and read it back, then update and delete it', async () => {
|
|
81
|
+
const server = app.getHttpServer();
|
|
82
|
+
const { body: stored } = await request(server).post('/api/<%= entityApiUrl %>').send(createdValues).expect(201);
|
|
83
|
+
const { body: read } = await request(server).get(`/api/<%= entityApiUrl %>/${stored.<%= primaryKey.name %>}`).expect(200);
|
|
84
|
+
expect(read).toMatchObject(expected(createdValues));
|
|
85
|
+
|
|
86
|
+
await request(server)
|
|
87
|
+
.put(`/api/<%= entityApiUrl %>/${stored.<%= primaryKey.name %>}`)
|
|
88
|
+
.send({ ...updatedValues, <%= primaryKey.name %>: stored.<%= primaryKey.name %> })
|
|
89
|
+
.expect(200);
|
|
90
|
+
const { body: readUpdated } = await request(server).get(`/api/<%= entityApiUrl %>/${stored.<%= primaryKey.name %>}`).expect(200);
|
|
91
|
+
expect(readUpdated).toMatchObject(expected(updatedValues));
|
|
92
|
+
|
|
93
|
+
await request(server).delete(`/api/<%= entityApiUrl %>/${stored.<%= primaryKey.name %>}`).expect(204);
|
|
94
|
+
await request(server).get(`/api/<%= entityApiUrl %>/${stored.<%= primaryKey.name %>}`).expect(404);
|
|
95
|
+
});
|
|
96
|
+
<%_ for (const relationship of storedRelationships) {
|
|
97
|
+
const otherEntity = relationship.otherEntity;
|
|
98
|
+
const otherId = otherEntity.primaryKey.name;
|
|
99
|
+
const collection = relationship.relationshipType === 'many-to-many';
|
|
100
|
+
const property = relationship.propertyName;
|
|
101
|
+
const otherValues = relationship.nodejsRelatedValues;
|
|
102
|
+
// A text field of the related record, sent changed with its id: the relationship does not store it (no cascade).
|
|
103
|
+
const otherTextField = otherValues && otherEntity.fields.find(field => !field.id && field.fieldType === 'String' && field.fieldName in otherValues);
|
|
104
|
+
_%>
|
|
105
|
+
|
|
106
|
+
it('should store the <%= property %> relationship by the id of the related record, without changing it', async () => {
|
|
107
|
+
const server = app.getHttpServer();
|
|
108
|
+
<%_ if (otherEntity.builtInUser) { _%>
|
|
109
|
+
// A user of this test: the applications without seed users (OAuth2) have none.
|
|
110
|
+
const users = app.get(DataSource).getRepository(<%= user.persistClass %>);
|
|
111
|
+
const related = await users.save(
|
|
112
|
+
users.create({
|
|
113
|
+
login: '<%= entityInstance.toLowerCase() %>-<%= property.toLowerCase() %>-e2e',
|
|
114
|
+
email: '<%= entityInstance.toLowerCase() %>-<%= property.toLowerCase() %>-e2e@localhost',
|
|
115
|
+
password: '',
|
|
116
|
+
activationKey: 'e2e-activation-key',
|
|
117
|
+
resetKey: 'e2e-reset-key',
|
|
118
|
+
}),
|
|
119
|
+
);
|
|
120
|
+
<%_ } else { _%>
|
|
121
|
+
const relatedValues: Record<string, any> = <%- literal(otherValues) %>;
|
|
122
|
+
const { body: related } = await request(server).post('/api/<%= otherEntity.entityApiUrl %>').send(relatedValues).expect(201);
|
|
123
|
+
<%_ } _%>
|
|
124
|
+
<%_ if (otherTextField) { _%>
|
|
125
|
+
const reference = { <%= otherId %>: related.<%= otherId %>, <%= otherTextField.fieldName %>: 'not stored through the relationship' };
|
|
126
|
+
<%_ } else { _%>
|
|
127
|
+
const reference = { <%= otherId %>: related.<%= otherId %> };
|
|
128
|
+
<%_ } _%>
|
|
129
|
+
const { body: stored } = await request(server)
|
|
130
|
+
.post('/api/<%= entityApiUrl %>')
|
|
131
|
+
.send({ ...createdValues, <%= property %>: <%- collection ? '[reference]' : 'reference' %> })
|
|
132
|
+
.expect(201);
|
|
133
|
+
|
|
134
|
+
const { body: read } = await request(server).get(`/api/<%= entityApiUrl %>/${stored.<%= primaryKey.name %>}`).expect(200);
|
|
135
|
+
<%_ if (collection) { _%>
|
|
136
|
+
expect(read.<%= property %>).toEqual([expect.objectContaining({ <%= otherId %>: related.<%= otherId %> })]);
|
|
137
|
+
<%_ } else { _%>
|
|
138
|
+
expect(read.<%= property %>).toMatchObject({ <%= otherId %>: related.<%= otherId %> });
|
|
139
|
+
<%_ } _%>
|
|
140
|
+
<%_ if (otherEntity.builtInUser) { _%>
|
|
141
|
+
// The keys of the user never in a response, like the @JsonIgnore keys of JHipster Spring Boot.
|
|
142
|
+
expect(JSON.stringify(read.<%= property %>)).not.toMatch(/e2e-(activation|reset)-key/);
|
|
143
|
+
<%_ } _%>
|
|
144
|
+
<%_ if (otherTextField) { _%>
|
|
145
|
+
const { body: relatedRead } = await request(server).get(`/api/<%= otherEntity.entityApiUrl %>/${related.<%= otherId %>}`).expect(200);
|
|
146
|
+
expect(relatedRead.<%= otherTextField.fieldName %>).toBe(relatedValues.<%= otherTextField.fieldName %>);
|
|
147
|
+
<%_ } _%>
|
|
148
|
+
|
|
149
|
+
await request(server).delete(`/api/<%= entityApiUrl %>/${stored.<%= primaryKey.name %>}`).expect(204);
|
|
150
|
+
<%_ if (otherEntity.builtInUser) { _%>
|
|
151
|
+
await users.remove(related);
|
|
152
|
+
<%_ } else if (!otherEntity.builtIn) { _%>
|
|
153
|
+
await request(server).delete(`/api/<%= otherEntity.entityApiUrl %>/${related.<%= otherId %>}`).expect(204);
|
|
154
|
+
<%_ } _%>
|
|
155
|
+
});
|
|
156
|
+
<%_ } _%>
|
|
157
|
+
<%_ for (const relationship of inverseRelationships) {
|
|
158
|
+
const otherEntity = relationship.otherEntity;
|
|
159
|
+
const otherId = otherEntity.primaryKey.name;
|
|
160
|
+
const property = relationship.propertyName;
|
|
161
|
+
const collection = relationship.relationshipType !== 'one-to-one';
|
|
162
|
+
const otherProperty = relationship.otherRelationship.propertyName;
|
|
163
|
+
const otherCollection = relationship.relationshipType === 'many-to-many';
|
|
164
|
+
const otherValues = relationship.nodejsRelatedValues;
|
|
165
|
+
_%>
|
|
166
|
+
|
|
167
|
+
it('should not store the <%= property %> relationship from this side, like the mappedBy side of JHipster Spring Boot', async () => {
|
|
168
|
+
const server = app.getHttpServer();
|
|
169
|
+
const { body: stored } = await request(server).post('/api/<%= entityApiUrl %>').send(createdValues).expect(201);
|
|
170
|
+
const reference = { <%= primaryKey.name %>: stored.<%= primaryKey.name %> };
|
|
171
|
+
const { body: related } = await request(server)
|
|
172
|
+
.post('/api/<%= otherEntity.entityApiUrl %>')
|
|
173
|
+
.send({ ...<%- literal(otherValues) %>, <%= otherProperty %>: <%- otherCollection ? '[reference]' : 'reference' %> })
|
|
174
|
+
.expect(201);
|
|
175
|
+
|
|
176
|
+
await request(server)
|
|
177
|
+
.put(`/api/<%= entityApiUrl %>/${stored.<%= primaryKey.name %>}`)
|
|
178
|
+
.send({ ...stored, <%= property %>: <%- collection ? '[]' : 'null' %> })
|
|
179
|
+
.expect(200);
|
|
180
|
+
|
|
181
|
+
const { body: relatedRead } = await request(server).get(`/api/<%= otherEntity.entityApiUrl %>/${related.<%= otherId %>}`).expect(200);
|
|
182
|
+
<%_ if (otherCollection) { _%>
|
|
183
|
+
expect(relatedRead.<%= otherProperty %>).toEqual([expect.objectContaining(reference)]);
|
|
184
|
+
<%_ } else { _%>
|
|
185
|
+
expect(relatedRead.<%= otherProperty %>).toMatchObject(reference);
|
|
186
|
+
<%_ } _%>
|
|
187
|
+
|
|
188
|
+
await request(server).delete(`/api/<%= otherEntity.entityApiUrl %>/${related.<%= otherId %>}`).expect(204);
|
|
189
|
+
await request(server).delete(`/api/<%= entityApiUrl %>/${stored.<%= primaryKey.name %>}`).expect(204);
|
|
190
|
+
});
|
|
191
|
+
<%_ } _%>
|
|
192
|
+
});
|