DEV Community

Cover image for [Nestia] Boost up NestJS server much faster and easier (maximum 20,000x faster + tRPC similar)

[Nestia] Boost up NestJS server much faster and easier (maximum 20,000x faster + tRPC similar)

Jeongho Nam on April 27, 2023

Preface As I've promised in the previous Typia Series Articles (dev.to), I'll introduce you my new library nestia, which can make Nest...
Collapse
 
cmcnicholas profile image
Craig McNicholas

Been interesting following your articles, I think you're doing a great job but the title is a bit misleading. This is making serialising and validating a hell of a lot faster but that is only one aspect of the "speed" most people will think of, your major resource/time intensive operations tend to be connected to other services like database read/write, file storage, cache access etc. So I'm not sure 20k times faster is really applicable in the real world, for most they will shave a few milliseconds off their APIs, but this is still great when you think about heavily active apis and the amount of time "wasted".

Great stuff, hope I get chance to give typia a go sometime.

Collapse
 
samchon profile image
Jeongho Nam • Edited

Titles are always difficult for me.

A title listing all the core features of Typia and nestia would be too long. In contrary, when I tried to find a great word to summarize them all at once, there was no other word like that.

At first, I tried to appeal to the SDK or pure typescript type DTO, but it was too unfamiliar and unfamiliar to people. Therefore, I explored elements that could introduce my library well, and studied how other open sources introduced themselves.

What I learned from studying other open source cases is that most open sources emphasize speed first when appealing, even if they have various advantages other than speed. Speed is clearly revealed as an objective figure, and these kinds of performance improvements seem to stimulate the developers' desire.

Because of that, I first appeal for speed, and then I talk about the next merits. I also introduce my open source library, and I always think about how to write a title, but I haven't been able to find something clear other than this speed yet. If you have any good ideas, please let me know.

Collapse
 
gamedevsam profile image
Samuel Batista

Very interesting library, I'd like to read some more articles describing how the speed-ups are achieved and what are the downsides of your approach as opposed to alternatives (also an explanation why "ts-patch" is required).

I'd also like to see a benchmark package, so your performance claims can be reproduced by myself and others so we can make an informed decision before adopting the library in production.

Collapse
 
samchon profile image
Jeongho Nam
Collapse
 
devgancode profile image
Ganesh Patil

Informative article
Learning nextjs now this may be help me in next project.

Thankyou....!!

Collapse
 
realtrynna profile image
realtrynna

Holy Molly Shit is so amazing.

Collapse
 
glen profile image
치와와

what the... is so amazing👍

Collapse
 
jmcelreavey profile image
John McElreavey

Is there a full stack mono repo example of this? Would love to see one!

Collapse
 
galwa profile image
Gal

What about async validation ? cannt find referance

Collapse
 
samchon profile image
Jeongho Nam

Why asynchronous validation is required in DTO level?

Can you give me an exmaple case?

Collapse
 
galwa profile image
Gal

Any use case were it doesnt make sense to seperate the buissness logic validation from the DTO itself for rexample You have DTO A that Point to DTO B and yuwant validate the B exists

Collapse
 
vandres profile image
Volker Andres

Replacing decorators with JSDoc feels like going 10 steps back.

Collapse
 
samchon profile image
Jeongho Nam

Well, if you think below code seems advanced, nothing to say:

export class BbsArticle {
    @IsString()
    @ApiProperty({
        format: "uuid",
    })
    id!: string;

    // DUPLICATED SCHEMA DEFINITION
    // - duplicated function call + property type
    // - have to specify `isArray` and `nullable` props by yourself
    @IsArray()
    @IsObject()
    @ValidateNested()
    @Type(() => AttachmentFile)
    @ApiProperty({
        type: () => AttachmentFile,
        nullable: true,
        isArray: true,
        description: "List of attached files.",
    })
    files!: AttachmentFile[] | null;

    @IsString()
    @IsOptional()
    @ApiProperty({
        type: "string",
        nullable: true,
        minLength: 5,
        maxLength: 100,
        description: "Title of the article.",
    })
    title!: string | null;

    @IsString()
    @ApiProperty({
        description: "Main content body of the article."
    })
    body!: string;

    @IsString()
    @ApiProperty({
        format: "date-time",
        description: "Creation time of article",
    })
    created_at!: string;
}

export class AttachmentFile {
    @IsString()
    @IsOptional()
    @ApiProperty({
        type: "string",
        nullable: true,
        maxLength: 255,
        pattern: "^[a-zA-Z0-9-_]+$",
        description: "File name.",
    })
    name!: string | null;

    @IsString()
    @IsOptional()
    @ApiProperty({
        type: "string",
        nullable: true,
        maxLength: 255,
        pattern: "^[a-zA-Z0-9-_]+$",
        description: "File extension.",
    })
    extension!: string | null;

    @IsString()
    @ApiProperty({
        format: "url",
        description: "URL of the file.",
    })
    url!: string;
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
zimiovid profile image
zimiovid • Edited

Do you have any plans integrate nestjs with Graphql nest implementation?

Collapse
 
samchon profile image
Jeongho Nam

As I've not used it yet, have no insight about it.

Can you tell me which points of gql in NestJS are inconvenient, so that how feature do you want in nestia, as an issue?