340 Commits

Author SHA1 Message Date
Lee Donghyun
d88856c3fa test(common): add unit tests for class serializer interceptor
Add comprehensive unit tests for ClassSerializerInterceptor which
previously had no test coverage despite being a public API.

Test coverage includes:
- constructor with custom transformer package injection
- intercept() with RxJS pipe and context options merging
- serialize() for arrays, objects, and StreamableFile handling
- transformToPlain() with type conversion and instanceOf checks
- getContextOptions() with metadata precedence (handler > class)
- Edge cases: null/undefined, mixed arrays, Date objects, primitives

Total: 25+ test cases covering all public methods and edge cases.
2026-01-26 00:38:25 +09:00
Kamil Mysliwiec
a1f6162971 Merge pull request #16202 from som14062005/fix/issue-16195
fix(common): exclude built-in primitives from strip proto keys
2026-01-23 09:44:35 +01:00
neo
979a8e2f04 fix(common): Fix skipping maxArrayLength and maxStringLength option
Fixes #16229
2026-01-21 16:00:28 +09:00
som14062005
8fb17f517c fix(common): exclude built-in primitives from strip proto keys
Skip constructor deletion for Date, RegExp, Error, Map, Set, WeakMap, and WeakSet to fix Jest useFakeTimers compatibility. Maintains prototype pollution protection for regular objects.

Fixes #16195
2026-01-16 02:00:15 +05:30
som14062005
16296b9ce8 fix(common): exclude built-in primitives from strip proto keys
Skip constructor deletion for Date, RegExp, Error, Map, Set, WeakMap, and WeakSet to fix Jest useFakeTimers compatibility. Maintains prototype pollution protection for regular objects.

Fixes #16195
2026-01-15 21:30:09 +05:30
Kamil Mysliwiec
cc2659aba1 Merge pull request #16060 from Jo-Minseok/feat/filevalidator-custom-message
feat(common): add message property to file type validator
2025-12-21 18:21:45 +01:00
J_Coder
b6aa4a2311 test(common): add tests for dynamic custom error message 2025-12-16 02:56:38 +09:00
J_Coder
af671a15ed test(common): add tests for custom error message and deprecated message 2025-12-14 04:10:01 +09:00
J_Coder
abe4efea62 refactor(common): rename message property to error message 2025-12-14 03:21:38 +09:00
taegwon son
af7289e4f5 test(common): Add missing tests for StreamableFile
Add tests for:
- Default error logger behavior (logger.error invocation)
- Edge case when input is neither Uint8Array nor has pipe method

Coverage: 97.06% -> 100%
2025-12-13 16:33:27 +09:00
J_Coder
2f26b30fd9 test(common): add unit tests for file type validator 2025-12-13 02:36:34 +09:00
taegwon son
d4b527f9e7 test(common): Add missing tests for StreamableFile error handling 2025-12-11 14:48:02 +09:00
Kamil Myśliwiec
0c93692bc9 chore: update prettier 2025-12-05 13:35:27 +01:00
Alvis
a4590016c3 fix(common): Support fallbackToMimetype without buffer
Allow FileTypeValidator to validate files saved on disk where no buffer is available.
Use mimetype as a fallback when fallbackToMimetype=true and buffer is missing.
Preserves existing behavior when fallbackToMimetype is not enabled.
2025-12-03 21:23:21 +08:00
Tomer Steinberg
fcfea5ed2a feat(common): add method options to @sse decorator 2025-10-31 17:31:02 +02:00
mag123c
cbf82f678a fix(common): resolve extras in configurable module builder async methods 2025-10-01 10:03:54 +09:00
mag123c
0577b5476b feat(common): add force-console option to console logger 2025-08-05 21:45:16 +09:00
Kamil Myśliwiec
0e95b3b90d refactor(common): move logger utils to dedicated files 2025-05-05 14:07:03 +02:00
Kamil Myśliwiec
9d270a2a91 Merge branch 'julien/log-level-filtering' of github.com:y-nk/nest into y-nk-julien/log-level-filtering 2025-05-05 14:00:04 +02:00
mag123c
8dccc18412 feat(common): Add fallbackToMimetype support in FileTypeValidator
Introduce `fallbackToMimetype` option to allow fallback to mimetype validation
when magic number detection fails (e.g., for small or undetectable buffers like text or CSV files).

Also enhanced `buildErrorMessage()` to reflect precise validation failure reasons
depending on buffer presence and mimetype state.

Added unit tests to cover fallback logic and error message variants.
2025-04-21 17:00:59 +09:00
Borewit
de798f6b61 test(common): Fix invalid file type test
Fixes a unit test, which aims to provide a PNG instead of JPEG.
The unit test passes because the file type cannot be recognized,
yet the intention was more likely to detect it was a different file type.

Change the PNG data into valid PNG file data.
Ensure the PNG data is detected as PNG.
2025-04-17 19:59:38 +02:00
Julien Barbay
bb9e847b9e fix(common): fix chai assertions in logger service spec 2025-04-17 12:53:49 +07:00
Julien Barbay
a191c1f905 feat(common): add log filtering function 2025-04-17 12:47:54 +07:00
Kamil Myśliwiec
ab79c566fd chore: minor tweaks 2025-04-11 13:42:34 +02:00
Chathula
3ff90244c7 fix(common): used eval import 2025-04-09 16:31:27 +02:00
Chathula
63d28bf1bc refactor(common): removed async keyword 2025-04-09 16:30:40 +02:00
Chathula
5243fca1dc fix(common): update file mime package and add param skip magic numbers 2025-04-09 16:30:37 +02:00
Chathula
f1f7ede4f9 chore: update import paths 2025-04-09 16:29:18 +02:00
Chathula
b432dd1a55 chore: update validations 2025-04-09 16:28:58 +02:00
Chathula
b623fcf66b fix: rename magic file type validator to file type validator 2025-04-09 16:28:46 +02:00
Chathula
1441fe62ed fix: switch to magic file validator by default 2025-04-09 16:28:25 +02:00
Chathula
87d95dc89d chore: export magic file type validator 2025-04-09 16:28:24 +02:00
Chathula
7a2e5bab44 fix(common): introduce magic file type validator to nestjs common 2025-04-09 16:26:07 +02:00
david
f81ce5f774 fix(common): addLeadingSlash optional group support 2025-01-31 15:36:56 +01:00
mag123c
11f8a4a216 feat(common): add error messages for file validators 2024-11-27 17:58:35 +09:00
Kamil Myśliwiec
d27628aafa chore: resolve conflicts 2024-11-27 09:55:20 +01:00
Kamil Myśliwiec
339be465fe chore: resolve conflicts 2024-11-27 09:49:01 +01:00
Kamil Myśliwiec
b94b0b910e build: use strict null checks part 3 2024-11-26 13:49:07 +01:00
Kamil Myśliwiec
38367e8e88 style: address spec lint errors 2024-11-26 11:57:05 +01:00
Kamil Myśliwiec
236b633a76 style: address integration tests lint errors 2024-11-26 09:39:20 +01:00
Kamil Myśliwiec
03a61e9728 chore: revert apply decorators signature (regression) 2024-11-21 10:41:37 +01:00
Micael Levi L. Cavalcante
de6f7ca20e test(common): improve test suite for getInjectionProviders 2024-11-20 09:40:33 -04:00
Kamil Mysliwiec
397390083f Merge pull request #13278 from johaven/feat-webdav-methods
feat(core,common,platform-fastify): add webdav http methods support
2024-11-18 13:16:35 +01:00
Kamil Mysliwiec
a669981c81 Merge pull request #14121 from nestjs/feat/logger-additions
feat(common): json logger and a few other improvements
2024-11-18 10:09:57 +01:00
Kamil Mysliwiec
07adf37156 Merge pull request #14122 from nestjs/feat/parse-date-pipe
feat(common): add ParseDatePipe, add tsdoc to other pipes
2024-11-15 10:17:52 +01:00
Kamil Myśliwiec
676461ff4e test: add unit tests, minor updates 2024-11-08 15:49:24 +01:00
Kamil Myśliwiec
23e602b712 style: fix linter issues 2024-11-08 14:09:58 +01:00
Kamil Myśliwiec
e767bd364e feat: produce a parseable json when colors off and compact on 2024-11-08 13:49:42 +01:00
Kamil Mysliwiec
8d0a3cd457 Merge pull request #12893 from Hareloo/12864-default-number-query-param-bug
fix(common): when transforming undefined numeric values
2024-11-06 12:49:48 +01:00
Johaven
af4e1d0a33 Merge branch 'nestjs:master' into feat-webdav-methods 2024-11-02 00:22:06 +01:00