Comments (10)
Like currently search decorator i guess is working like this. it only works for property of string type and lets say we pass search=abc then if available search is on ['firstname', 'email'] then search decorator will transform the values for both firstname and email. and it will be search in database then
from ack-nestjs-boilerplate.
I think that's because of nestjs request life cycle
Our dto will serialize with class-transformer
and then validate with class-validation
from typestack
.ย
The entire process will be carried out in the ValidationPipe
from @nestjs/common
as a global pipe
.
As you can see in the doc request life cycle, the global pipe will run after the pre-interceptor.ย
That why you query params only accessable in interceptor.
So, I guess your problem comes because of the wrong implementation options of ValidationPipe.ย
Try to set false
for whitelist
options, maybe that will help to solve your problem.
Here if you need to read more documentation about ValidationPipe
from ack-nestjs-boilerplate.
I have tried to make it work by setting IsOptional decorator on properties which we don't expect from front-end like availableSort & availableSearch. Without this decorator inside controller these properties were not accessible.
But my problem still exist with search property. Transform decorator for search tries to create regex for each value inside availableSearch array. my question is how we can make it work for non-string values?
How we can make sorting to work with multiple values at same time
from ack-nestjs-boilerplate.
Yes, correct! That will work with string type or number type only
, and then it depends on AvailableSearch
.ย
The logic of search is only for simple usage.ย
The search will use regex to make it case insensitive and contain some value.
eg:
{
"name": {
"first": "ack",
"last": "mongoose"
},
"phone": "621313121111",
"email": "[email protected]"
}
and then, you can make AvailableSearch like this to search inside the object.
const availableSearch = [
'name.first',
'name.last',
'name',
]
Okay, there are 2 questions.
- How we can make it work for non-string values?
If you want to advance usage, I suggest you make an edit toย PaginationModule
with your logic.
For the current version, look in src-> common-> pagination-> decorator-> pagination.decorator.ts -> PaginationSearch
, and then edit the @Transform
Decorator.ย
- How we can make sorting to work with multiple values at same time?
Same with answer 1. You must change the @Transform
Decorator in PaginationSort
with your own logic.ย
The current sort decorator only supports 1 sort.
from ack-nestjs-boilerplate.
Or you can add more PaginationFilter
for other cases.
from ack-nestjs-boilerplate.
The problem you have about not accessible property in controller, maybe because of ValidationPipe
@Module({
controllers: [],
providers: [
{
provide: APP_PIPE,
useFactory: () =>
new ValidationPipe({
transform: true, // <-- try to set it with true
whitelist: false, // <-- try to set it with false
skipNullProperties: false, // <-- try to set it with false
skipUndefinedProperties: false, // <-- try to set it with false
skipMissingProperties: false, // <-- try to set it with false
errorHttpStatusCode: HttpStatus.UNPROCESSABLE_ENTITY,
exceptionFactory: async (errors: ValidationError[]) =>
new UnprocessableEntityException({
statusCode:
ENUM_REQUEST_STATUS_CODE_ERROR.REQUEST_VALIDATION_ERROR,
message: 'http.clientError.unprocessableEntity',
errors,
}),
}),
},
],
imports: [],
})
export class RequestModule {}
from ack-nestjs-boilerplate.
Thanks for your response. if you can provide postman collection you used to test the endpoints of this repo. it would be very helpful as i have some confusion related to passing some of query params to these endpoints.
from ack-nestjs-boilerplate.
Sure, i will.
Endpoint will describe with swagger (on progress) and i will update the documentation.
Stay tuned๐
from ack-nestjs-boilerplate.
Hi @akashabbasi,
I already done to add the API Spec with swagger, go check the current version
Thank you ๐
from ack-nestjs-boilerplate.
Let me check it ๐
from ack-nestjs-boilerplate.
Related Issues (20)
- rate-limit problem ? HOT 1
- the demo isnt working HOT 1
- Docker compose service dependency to ackDatabase HOT 1
- apikey problem HOT 1
- Api key Issue HOT 1
- role creation HOT 3
- How to create and use API Key? HOT 1
- Why do we have a try/catch block at the end of every api in the controller ? HOT 1
- ERROR [I18nService] Translation
- 500 Internal Server for every api endpoint HOT 1
- E2E And Integration Tests HOT 2
- 500 Internal Server Error '/api/v1/auth/user/info' HOT 1
- Grateful! I hope the documentation can be more complete, how to expand development. HOT 4
- How about adding redis store for caching ? HOT 6
- Is there any someone use this boilerplate for production ? HOT 4
- Add TZ to example environment variables (.env.example) HOT 1
- Error while running seed if there are other module imported on usermodule HOT 1
- Password and related information are leaking. HOT 1
- Request for Two-Factor Authentication (2FA) Feature Implementation HOT 3
- Unable to connect to the database. Retrying (1)... HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ack-nestjs-boilerplate.