Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V8] Roadmap #2818

Closed
6 of 8 tasks
Romakita opened this issue Sep 8, 2024 · 1 comment
Closed
6 of 8 tasks

[V8] Roadmap #2818

Romakita opened this issue Sep 8, 2024 · 1 comment
Assignees

Comments

@Romakita
Copy link
Collaborator

Romakita commented Sep 8, 2024

Why ?

Some new feature require a breaking change for all projects based on v7:

useDefineForClassFields

useDefineForClassFields in tsconfig must be configured to false. Changing this option can change the runtime behavior. Latest v7 support twice configuration but v8 doesn't support useDefineForClassFields totrue because inject/constant/value use Reflect.defineProperty to declare property.

Reflect.defineProperty resolve the problem when you trying to get the injected value using decorators:

class MyService {
  @Constant("my.value")
  value: string;
  
    @Inject()
  client: Client;
  
  constructor() {
     console.log(this.value) // undefined in v7, in v8 value is defined
     console.log(this.client) // undefined in v7, in v8 value is defined
  }
}

See PR: #2812

Remove CommonJs support

It's time to on a full ESM project! Maintaining code compliant with CommonJS and ESM in v7 is very complicated.
Now the ESM ecosystem is stable. Ts.ED repository will move on full ESM.

Migrate @tsed/graphql on apollo v4

Apollo v4 introduce a lot of breaking change. The new @tsed/apollo, @tsed/typegraphql will be available with the v8
See #2493

New features

Angular style injection

V8 add the angular style injection using simple function:

class MyService {
  value = constant("my.value");
  client = inject(Client)
    
  constructor() {
     console.log(this.value)
     console.log(this.client)
  }
}

Replace platform-log-middleware by platform-log-request

@tsed/platform-log-request is a new module introduced in v8 alpha and replace the @tsed/platform-log-middleware which is not cross platform compatible.

This new module support WWW platform (common) and Serverless platform. It provide new options which gives you control over the logger information and better customization depending on the log level. It's a little more powerful than the old module and is lighter in terms of code.

Attaching more data from the $ctx instance to each log request will be more simpler:

const loggerSettings = {
    alterLog(level: string, data: Record<string,  unknown>, $ctx: PlatformContext) {
      
       switch (level) {
           case "info": 
             return {
                ...data, 
                // add you extra data
                tenant_id: $ctx.request.params.tenant_id
             } 
       }
       
       return data;
    }
}


@Configuration({
   logger: loggerSettings
})

by default this module generate log as follows:

export function defaultAlterLog(level: string, obj: Record<string, unknown>, ctx: BaseContext) {
  const minimalLog = {
    method: ctx.request.method,
    url: ctx.request.url,
    route: ctx.request.route || ctx.request.url,
    ...obj
  };

  if (level === "info") {
    return minimalLog;
  }

  return {
    ...minimalLog,
    headers: ctx.request.headers,
    body: ctx.request.body,
    query: ctx.request.query,
    params: ctx.request.params
  };
}

Other Stuff

  • Update mongoose to v8
  • Update @tsed/prisma to v5 prisma client
  • Migrate @tsed/adapters codebase to v7 lowdb library
  • Remove @tsed/typeorm package (v0.3.x doesn't need. dedicated package)
  • Remove @tsed/vite-ssr-plugin (replaced by @tsed/vike)
  • Remove @Ignore decorator (post pone)
  • Update documentation (v8 migration note)
  • Publish new website
@Romakita Romakita self-assigned this Sep 8, 2024
@Romakita Romakita moved this from To do to Review in progress in Global Board Oct 1, 2024
@Romakita Romakita moved this from Review in progress to In progress in Global Board Oct 1, 2024
@Romakita Romakita pinned this issue Oct 31, 2024
@Romakita Romakita closed this as completed Dec 3, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in Global Board Dec 3, 2024
Copy link

github-actions bot commented Dec 3, 2024

🎉 Are you happy?

If you appreciated the support, know that it is free and is carried out on personal time ;)

A support, even a little bit makes a difference for me and continues to bring you answers!

github opencollective

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

1 participant