Rose Nettoyeur
Rose Nettoyeur

Reputation: 895

Does it make sense to use Angular and NestJS in a monorepo?

Does it make sense to use Angular (Frontend) and NestJS (Backend) in a monorepo (e.g. Nx or Lerna)?

What kind of code could you share? I only can think of Models (e.g. User-Class). However, NestJS uses TypeORM, which "pollutes" the Model with additional decorates (@Entity, @Column, ...). These decorators are fine in a NestJS context, but you don't want these decorators in a Angular context.

Why does this still make sense? What are the advantages of it? What are your thoughts?

Upvotes: 0

Views: 168

Answers (1)

Arnaud Denoyelle
Arnaud Denoyelle

Reputation: 31235

Entities should definitely stay on backend side, never expose your database structure.

You can share :

  • DTOs,
  • enums / constants / reference data / error codes
  • static validation rules on DTOs
  • Common util functions like time, formatting, parsing etc

Which means less duplication. With this configuration, OpenAPI/Swagger becomes useless. You directly share DTOs and get live reload on both sides as soon as you modify a DTO

Upvotes: 0

Related Questions