Skip to content

Releases: ditsmod/ditsmod

Ditsmod v2.52.0 Released!

01 Apr 21:59
Compare
Choose a tag to compare

Breaking Changes

  • renamed SingletonHttpFrontend to DefaultSingletonHttpFrontend 34c1f18eb4.
  • renamed SingletonChainMaker to DefaultSingletonChainMaker 6f6bdd4c64.
  • renamed SingletonHttpErrorHandler to DefaultSingletonHttpErrorHandler d3be41e942.
Commit Type Description
5af42900c4 feat added Res#setHeaders.
16141c9cfd feat added ability pass headers to Res#send().
b2c9fdd160 feat extended RequestContext.
951e096b2d feat added HttpHeaders interface.
9e1f71972c feat added RequestContext to defaultProvidersPerApp.
5f0fe6e030 fix fixed import makeClassDecorator for GuardMetadata.
e52d41f3ff fix fixed type for A_PATH_PARAMS.
a0149e582b refactor refactoring Logger and ConsoleLogger.
fd63181078 refactor refactoring ConsoleLogger.
9189d9644d refactor change default log level for ErrorOpts.
66f468f783 refactor apply new methods for RequestContext.

Full Changelog: core-2.51.2...core-2.52.0

Ditsmod v2.50.0 Released!

30 Sep 10:47
Compare
Choose a tag to compare

Features

  • Introduced RequestContext for HTTP interceptors:

    interface HttpInterceptor {
      intercept(next: HttpHandler, ctx: RequestContext): Promise<any>;
    }
  • Introduced @controller({ isSingleton: true }) options. You can now specify that your controller is a singleton. In this case, the controller receives a RequestContext, but an injector is not created for it on every request. Routes in such a controller are very fast.

v2.49.0

15 Sep 08:13
Compare
Choose a tag to compare

Features

  • Added a check to determine if the imported module is external. This change applies to exporting providers and extensions from the root module. Previously, these extensions and providers were added to all modules without exception, including external modules (which are usually placed in the node_modules folder). And it was unnecessary, because external modules do not need "global" providers and extensions. Therefore, it is no longer available in this release.

  • Added bufferLogs option:

    import { Application } from '@ditsmod/core';
    import { AppModule } from './app/app.module.js';
    
    const app = await new Application().bootstrap(AppModule, { bufferLogs: false });
    app.server.listen(3000, 'localhost');

    If { bufferLogs: true }, all messages are buffered during application initialization and flushed afterwards. This can be useful if you want all messages to be recorded by the final logger, which is configured after the application is fully initialized.

    Default - true.

  • Reduced Logger interface requirements. Now the logger you can use to substitute the default ConsoleLogger should have only three methods:

    log(level: InputLogLevel, ...args: any[]);
    
    setLevel(value: OutputLogLevel);
    
    getLevel(): OutputLogLevel;
  • Now res.nodeRes is public property, so you can use this native Node.js response object.

Bug fixes

  • When appending modules, their providersPerApp was ignored. In this release, they are taken into account.
  • Fixed cleanErrorTrace().

v2.48.0

07 Sep 09:44
Compare
Choose a tag to compare

Features

  • Added Injector#pull() method.
    If the nearest provider with the given token is in the parent injector, then this method pulls that provider into the current injector. After that, it works the same as injector.get(). If the nearest provider with the given token is in the current injector, then this method behaves exactly like injector.get(). This method is primarily useful because it allows you, in the context of the current injector, to rebuild instances of providers that depend on a particular configuration that may be different in the current and parent injectors:

    import { injectable, Injector } from '@ditsmod/core';
    
    class Config {
      one: any;
      two: any;
    }
    
    @injectable()
    class Service {
      constructor(public config: Config) {}
    }
    
    const parent = Injector.resolveAndCreate([Service, { token: Config, useValue: { one: 1, two: 2 } }]);
    const child = parent.resolveAndCreateChild([{ token: Config, useValue: { one: 11, two: 22 } }]);
    child.get(Service).config; // returns from parent injector: { one: 1, two: 2 }
    child.pull(Service).config; // pulls Service in current injector: { one: 11, two: 22 }
    child.get(Service).config; // now, in current injector, works cache: { one: 11, two: 22 }
  • Added isClassFactoryProvider() type guard.

  • For Logger, added mergeConfig() and getConfig().

  • In Providers helper, added support for FunctionFactoryProvider.

v2.47.0

29 Aug 00:37
Compare
Choose a tag to compare

Features

Migration to ESM!

v2.46.0

24 Aug 20:52
Compare
Choose a tag to compare

Features

  • Added support for the second useFactory form. Now you can use a simple function (instead of a class method):
function fn1(service1: Service1, service2: Service2) {
  // ...
  return 'some value';
}

{ token: 'token3', useFactory: fn1, deps: [Service1, Service2] }

v2.40.0

10 Aug 06:47
Compare
Choose a tag to compare

Features

  • added normalizeProviders(), getToken() to index.ts;
  • added T param to ValueProvider<T>;
  • added some code to support new package @ditsmod/testing.