Skip to content

Releases: tsedio/tsed

v5.27.5

28 Aug 08:30
Compare
Choose a tag to compare

5.27.5 (2019-08-28)

Bug Fixes

  • common: Stop outputting settings on server initialization (shown only in debug mode) (fb7dbea)

v5.27.4

22 Aug 10:37
Compare
Choose a tag to compare

5.27.4 (2019-08-22)

Bug Fixes

  • seq: fix seq off log level (f1afe84)

v5.27.3

21 Aug 07:05
Compare
Choose a tag to compare

5.27.3 (2019-08-21)

Bug Fixes

  • test: Fix TestContext.create issue (fe68bf3)

v5.27.2

20 Aug 15:54
Compare
Choose a tag to compare

5.27.2 (2019-08-20)

Bug Fixes

  • common: Deprecate $onMountingMiddleware. Use $beforeRoutesInit instead (b7b3132)

v5.27.1

20 Aug 09:14
Compare
Choose a tag to compare

5.27.1 (2019-08-20)

Bug Fixes

  • typeorm: TypeORMService (createConnection -> getConnectionManager) (0b59d22), closes #579

v5.27.0

20 Aug 07:54
Compare
Choose a tag to compare

5.27.0 (2019-08-20)

Features

  • di: Add isAsync method and useAsyncFactory in Provider class (f3bb044)
  • di: Support async provider with InjectorService.loadAsync() (ce9fc8b), closes #547

Provider.useFactory

The useAsyncFactory is a way of creating asynchronous providers dynamically.
The actual provider will be equal to a returned value of the factory function.
The factory function can either depend on several different providers or stay completely independent.
It means that factory may accept arguments, that DI will resolve and pass during the instantiation process.

Example:

import {ServerSettingsService} from "@tsed/common";
import {registerProvider} from "@tsed/di";
import {DatabaseConnection} from "connection-lib";

export const CONNECTION = Symbol.for("CONNECTION");

registerProvider({
  provide: CONNECTION,
  deps: [ServerSettingsService],
  async useAsyncFactory(settings: ServerSettingsService) {
    const options = settings.get("myOptions");
    const connection = new DatabaseConnection(options);

    await connection.connect();

    return connection;
  }
});

In order to inject custom provider, we use the Inject decorator. This decorator takes a single argument - the token.

import {Inject, Injectable} from "@tsed/common";
import {CONNECTION} from "./connection";

@Injectable()
export class MyService {
  constructor(@Inject(CONNECTION) connection: any) {

  }
}

v5.26.0

19 Aug 18:11
Compare
Choose a tag to compare

5.26.0 (2019-08-19)

Bug Fixes

  • multipartfiles: Update multipartfile (2b67e5c)

Features

  • di: Add Container.addProviders method (4bb0f20)
  • mvc: Request accept expression to get property from Request (5ec5b92)

v5.25.1

08 Aug 12:12
Compare
Choose a tag to compare

5.25.1 (2019-08-08)

Bug Fixes

  • #610: Resolve typing issue on ServerSettings decorator (719e802)

v5.25.0

07 Aug 07:07
Compare
Choose a tag to compare

5.25.0 (2019-08-07)

Bug Fixes

  • Fix tsc compilation issue (013a5bd)

Features

  • di: Add DISettings class (6c69912)

v5.24.2

05 Aug 13:34
Compare
Choose a tag to compare

5.24.2 (2019-08-05)

Bug Fixes

  • converters: throw bad request error on property conversion failure (526ef17)