> For the complete documentation index, see [llms.txt](https://kinesis-school-of-programming.gitbook.io/nestjs-unleashed/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinesis-school-of-programming.gitbook.io/nestjs-unleashed/introduction/updates/1.1.md).

# 1.1

After the initial full release of the course, many more ideas of refactors and improvements arose, apart from dependency version updates (mainly Nest v9 to v10). Due to the big amount of changes, I decided to call this the 1.1 update. Changes are as follows:

## Core module

* Update packages with **ncu** (Nest v9 -> v10)
* Update project's base files as according to Nest v10 template
* Improvements in basic project configuration
  * No more need to struggle with EoL (Nest CLI generates line breaks accordingly to OS)
  * ESLint file back to JS (more versatile)
  * In Prettier file, enable **organize-imports** plugin and use **EoL** as **auto**
* More explicit about creating folder <mark style="color:purple;">domain</mark>/<mark style="color:purple;">users</mark> during first steps
* Insomnia (updated)
  * How to create first request
  * Access base environment
  * Access folder env
  * **Improvement**: better setup of path parameters
* Update Docker compose file
  * Remove version (<mark style="color:red;">obsolete</mark>)
  * Named volume for database
* More explicit about using migrations with npm
* <mark style="color:purple;">.env.example</mark> with sample data (easier to understand & avoids need for defaults)
* Use <mark style="color:blue;">`port()`</mark> in env validation schema
* Use <mark style="color:blue;">`ConfigService`</mark> in <mark style="color:purple;">main</mark> file (environment variable for **APP\_PORT**)
* Generate the database url inside codebase (better for deploy)
* Validate uniqueness of arrays with <mark style="color:blue;">`@ArrayUnique()`</mark>&#x20;
  * **Identifier functions** for arrays of objects
* **New lesson**: function overload for wrapping ids
* Fix: add <mark style="color:blue;">`@IsDefined()`</mark> to <mark style="color:blue;">`@IsEntity()`</mark>
* Use simplified transaction syntax

## Improvements/Tips

* Rename some files for simplicity
  * Folder <mark style="color:purple;">text-validation</mark> with just <mark style="color:purple;">text</mark>
  * Validators <mark style="color:purple;">at-least-one</mark>... with <mark style="color:purple;">contains</mark>...
* **New lesson**: More validations
  * Max value for id - postgres integer (32-bit)
  * User name with letters and spaces (no consecutive, leading or trailing)

## Authentication/Authorization

* Define <mark style="color:blue;">`LoginDto`</mark> as <mark style="color:blue;">`PickType`</mark> of <mark style="color:blue;">`CreateUserDto`</mark> (alternative)
* Fix: use <mark style="color:blue;">`flatMap()`</mark> in **middleware** instead of <mark style="color:blue;">`join()`</mark> (for many constraints)
* **New lesson**: generic middleware
* Better explanation about JWT cookie options
* Explanations about different forms of setting route metadata
  * Alternative definition of <mark style="color:blue;">`Public`</mark> decorator (directly receive <mark style="color:blue;">`SetMetadata()`</mark>)
  * Alternative definition of <mark style="color:blue;">`Roles`</mark> decorator (<mark style="color:blue;">`Reflector.createDecorator()`</mark>)
* Updates to throttler
  * Use helper instead of directly converting to ms
  * Use <mark style="color:blue;">as const</mark> in array instead of inner object
  * Explanation about it not working in <mark style="color:blue;">`login()`</mark> route (due to middleware)
  * Fix: relocate <mark style="color:blue;">`ThrottlerGuard`</mark> as first guard

## Exception Filters

* Remove <mark style="color:blue;">`extractFromText()`</mark> function and use regexes with **lookbehind** (ES2018)
* Use <mark style="color:blue;">switch(true)</mark> to avoid using <mark style="color:blue;">if-else</mark> cascades

## OpenAPI Specification

* Use <mark style="color:blue;">`documentFactory`</mark> when generating the document
* Remove <mark style="color:blue;">`@ApiTags()`</mark> decorators (no longer necessary)
* Replace <mark style="color:blue;">`HeadersObject`</mark> type in cookie header with more "high-level" type
* **New lesson**: append decorators during system startup with <mark style="color:blue;">`DiscoveryService`</mark>

## File Management

* **Type alias** for <mark style="color:blue;">`Express.Multer.File`</mark>
* New type <mark style="color:blue;">`FileSizeMagnitude`</mark> when validating file size
* Transaction for deleting product and its base directory
* **New lesson**: make products' images available through **serve static**
* Better type safety when catching <mark style="color:blue;">`SyntaxError`</mark> inside <mark style="color:blue;">`BodyInterceptor`</mark>
* Update files exception filter to use lookbehind regexes and <mark style="color:blue;">switch(true)</mark>

## Advanced Querying

* **New lesson**: Document paginated responses
* Rename DTOs such as <mark style="color:blue;">`ProductsFilterDto`</mark> to <mark style="color:blue;">`FilterProductsDto`</mark> (like <mark style="color:blue;">`CreateProductDto`</mark>, maintain this pattern)
* Explanation about replacing enums with const arrays
* Better type for <mark style="color:blue;">`Sort`</mark> array, enforcing <mark style="color:blue;">`Product`</mark> fields
* Showcase of TypeScript new autocomplete for switch case
* Improved algorithm for <mark style="color:blue;">`toFilterOperationDto()`</mark>

## Automated Testing

* Add paths of jest config files to <mark style="color:blue;">`ignorePatterns`</mark> in ESLint file
* Improvements to testing utilities
  * <mark style="color:blue;">`MockRepository`</mark> actually requires entity type for signature inference
  * Single function to encapsulate <mark style="color:blue;">`mock()`</mark> (variable already typed)
* Use **parameter default** in <mark style="color:blue;">`genUser()`</mark> function
* Change <mark style="color:blue;">`server`</mark> type to <mark style="color:blue;">`Server`</mark> (<mark style="color:blue;">`HttpServer`</mark> not accepted anymore by <mark style="color:blue;">`request()`</mark>)
* Fix: script to remove test database now also removes the volume
* Use <mark style="color:purple;">.env</mark> file for testing
* Use chainable matcher instead of <mark style="color:blue;">`expect.objectContaining()`</mark>
* Remove spread of <mark style="color:blue;">`createUserDto`</mark> from inside <mark style="color:blue;">`updateUserDto`</mark> (no longer necessary)
* Use hardcoded <mark style="color:blue;">`phone`</mark> in e2e test (due to updated validation in class validator)
* Type assert the <mark style="color:blue;">`body`</mark> in <mark style="color:blue;">`response`</mark> for better type safety

## Other changes

* Easier command to use node lts version with nvm
* Explanation about formatting project to replace all LF line breaks with CRLF (Windows)
* Update <mark style="color:blue;">`phone`</mark> in Insomnia (new **class-validator** validation)
* Pluralize DefaultPageSize elements
* Inline JSDocs
* Rename database credentials in <mark style="color:purple;">.env</mark>
* No more need to put <mark style="color:purple;">.env</mark> file in <mark style="color:purple;">.gitignore</mark> manually
* In <mark style="color:blue;">`reduce()`</mark> lambda expression, rename parameters to be more expressive
* Correction in commit name for validating booleans
* Remove LF lesson (no longer necessary)
* Link in complementary material about **Request lifecycle** (execution order of enhancers)
* Remove generics when obtaining references from within modules in tests (optional)
* Remove General Refactors section, and integrate refactors in respective lessons
