Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 22 21:12
    pirouet opened #650
  • Sep 20 10:52
    Romakita commented #648
  • Sep 20 10:34
    dileepgopal commented #648
  • Sep 20 10:20
    ringolin93 closed #649
  • Sep 20 09:26
    Romakita commented #649
  • Sep 20 09:21
    ringolin93 edited #649
  • Sep 20 09:20
    ringolin93 edited #649
  • Sep 20 09:19
    ringolin93 opened #649
  • Sep 20 08:35
    Romakita commented #648
  • Sep 20 06:00
    dileepgopal opened #648
  • Sep 19 12:40
    Romakita unlabeled #646
  • Sep 19 12:40
    Romakita labeled #646
  • Sep 19 12:40
    Romakita commented #646
  • Sep 19 12:25
    dileepgopal commented #646
  • Sep 19 11:17
    Romakita labeled #646
  • Sep 19 11:17
    Romakita unlabeled #646
  • Sep 19 11:17
    Romakita unlabeled #646
  • Sep 19 11:17
    Romakita commented #646
  • Sep 19 11:11
    Romakita commented #642
  • Sep 19 10:09
    karlos1337 commented #642
Romain Lenzotti
@Romakita
yes yes :)
Jean
@chapelle_gitlab
With what version of typescript is this version compatible ?
For a reason I can't explain, I'm getting typescript transpilation error with version 2.6.1
I know this is old ...
Romain Lenzotti
@Romakita
The version used in v4.31 is typescript 3.0.1
Jean
@chapelle_gitlab
Ok thanks, I'll try that right away
Jean
@chapelle_gitlab
I works thanks
Romain Lenzotti
@Romakita
;)
Jean
@chapelle_gitlab
;-)
Jean
@chapelle_gitlab
Hey, I have another version issue on one of my other projects.
node_modules/@tsed/multipartfiles/lib/middlewares/MultipartFileMiddleware.d.ts:9:19 - error TS2749: 'EndpointInfo' refers to a value, but is being used as a type here.
with following versions
"typescript": "3.4.1"
"@tsed/multipartfiles": "^5.12.0",
Do you know why I see this ?
Romain Lenzotti
@Romakita
Did you use the same version for all tsed package ?
Jean
@chapelle_gitlab
Nope
Romain Lenzotti
@Romakita
Ha ^^
Jean
@chapelle_gitlab
"@tsed/ajv": "^5.6.0",
"@tsed/common": "5.2.4",
"@tsed/core": "5.2.4",
"@tsed/di": "5.2.4",
"@tsed/multipartfiles": "^5.12.0",
"@tsed/swagger": "5.2.4",
"@tsed/testing": "5.2.4",
"@tsed/typeorm": "^5.6.0",
Romain Lenzotti
@Romakita
ok this is the problem. Endpoint can be used as type since a specific version of Ts.ED
Jean
@chapelle_gitlab
I'll try that ;-)
Oh ok ;-)
Romain Lenzotti
@Romakita
you can try to set 5.2.4 for multipartfiles
I’m not sure if multpartfile have specific fix/feat since 5.2.4 (excepted refactoring)
Jean
@chapelle_gitlab
Ok I'll try that right away
It worked. Thanks
;-)
Romain Lenzotti
@Romakita
nice :)
Romain Lenzotti
@Romakita
Hello v6 roadmap is created. Here the github issue TypedProject/ts-express-decorators#619
Míla Kuchta
@kuchta
Guys, I've encountered DeprecationWarning: $onMountingMiddlewares hook is deprecated. Use $onBeforeRoutesInit instead. But documentation isn't probably updated: https://tsed.io/docs/server-loader.html
and something must changed, because after upgrade from 5.13 to 5.27 my AuthenticatedUser() decorator stoped working...
Míla Kuchta
@kuchta
@Filter()
class ContextFilter implements IFilter {
    transform(expression: string, req: any, response: any) {
        if (!req[AUTHENTICATED_USER]) {
            throw new Unauthorized("The user is not authenticated or available");
        }
        if (expression) {
            return req.context && getValue(expression, req[AUTHENTICATED_USER]);
        }

        return req[AUTHENTICATED_USER];
    }
}

export function AuthenticatedUser() {
    return (target: any, propertyKey: string, parameterIndex: number): void => {
        ParamRegistry.useFilter(ContextFilter, {
            propertyKey,
            parameterIndex,
            target,
            useConverter: false,
            // @ts-ignore
            paramType: AUTHENTICATED_USER
        });
    };
}
Romain Lenzotti
@Romakita
@kuchta It should be fixed with the latest version :)
Míla Kuchta
@kuchta
Thanks @Romakita . BTW, I've already "fixed" my code and now what's better? This one I've written according docs.
@Filter()
class AuthenticatedUserFilter implements IFilter {
    transform(expression: string, req: Express.Request, res: Express.Response) {
        if (!req[AUTHENTICATED_USER]) {
            throw new Unauthorized("The user is not authenticated or available");
        }

        return req[AUTHENTICATED_USER];
    }
}

export function AuthenticatedUser() {
    return UseFilter(AuthenticatedUserFilter, {
        paramType: ParamTypes.CONTEXT,
        required: true,
        useConverter: false,
        useValidation: false,
    });
}
Romain Lenzotti
@Romakita
Ok but now you can throw error in your filter. This is one of the regression from previous release
Míla Kuchta
@kuchta
I throw error in both cases. What's the difference or what regression do you mean?
Romain Lenzotti
@Romakita
For filter, I use Observable, but before fix the code doesn’t catch error in your filter. The result is, the error is only printed in the log and not sent as an HttpException to the client
Míla Kuchta
@kuchta
@Romakita Thanks for explanation, Romain. BTW, is it better to use ParamRegistry.useFilter method or UseFilter constructor?
Romain Lenzotti
@Romakita
UseFilter
it’s a the base decorator to build a filter now :)
dileepgopal
@dileepgopal

Hi, Appologies for a lenghty message

In my project I am using TSED 5.19.1
"@tsed/common": "5.19.1",
"@tsed/core": "5.19.1",
"@tsed/di": "5.19.1",
"@tsed/mongoose": "5.24.1",
"@tsed/swagger": "5.19.1"

These are my entity models

@Model()
export class FormEntity {

@PropertyName("id")
_id: string;

@PropertyType(FormAttributeEntity)
@Required()
attributes: Array<FormAttributeEntity>;

}

@Model()
export class FormAttributeEntity {

@Property()
@Required()
name: string;

@Property()
@Default(false)
required: boolean = false;

@Property()
@Default("string")
type: string = "string";

}

This is my request payload
{
"attributes": [
{
"name": "string"
"required": false,
"type": "string"
}
]
}

if the attributes property is missing in the request it throws BadRequest and getting a valid message. However, if the "name" property is missing
inside "attributes" I am not getting a BadRequest rather getting a 500 error. Also the message is not legible.
Request
{
"attributes": [
{
"required": false,
"type": "string"
}
]
}

Message
Conversion failed for class "FormEntity" with object => {"attributes":[{"required":false,"type":"string"}]}.<br />For attributes with value [object Object] <br />Property name on class FormAttributeEntity is required.

Can you please help me to validate the required "name" property and throws a BadRequest with legitimate message?

Romain Lenzotti
@Romakita
Hello @dileepgopal Can you open an issue please :) ?
Where come from this part of the message: For attributes with value [object Object]
Because I don’t recognize it (or find it in tsed code)
dileepgopal
@dileepgopal
I will open an issue. Not sure from where the message coming. I haven't given it in my code either
Romain Lenzotti
@Romakita
Did you use ajv ?
dileepgopal
@dileepgopal
no, I didn't
let me try ajv and see if it helps
thanks
Sam Fellers
@spfellers
can someone explain what componentsScan is doing? Everything seems to be working fine without it, even without the default project structure where all services are in services/ dir
Romain Lenzotti
@Romakita
Hello @spfellers
componentsScan is an option to give a list of glob pattern and load your services/provider. By Default componentsScan is already configured to scan ${rootDir}/controllers ${rootDir}/services and $rootDir/middlewares. You don’t have to change this options until you haven’t new folders which is not included in the default glob pattern :)
Sam Fellers
@spfellers
hey thanks for the reply @Romakita I don't use the default pattern so there is no ${rootDir}/services folder. My services still seem to run fine with DI.