Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

v0.11.0

Choose a tag to compare

@etsuo etsuo released this 14 Mar 03:07
· 109 commits to develop since this release
973d2bd

See milestone v0.11.0

Breaking Changes

  • src/core/@routable/routable.ts: HttpMethod renamed to ApiMethod (ApiMethod represents valid handlers for a routable class with a model attached to it)

  • IRoutableOptions

    • exposeApi took HttpMethod[] but now takes ApiMethod[]
    • suppressApi took HttpMethod[] and now takes ApiMethod[]
  • HttpMethod is now exported by src/core/@routable/route.ts and represents valid HTTP methods

  • IRoutableMethodOptions

    • method is now more tightly constrained to HttpMethods | HttpMethods[] | HttpMethod | [HttpMethod] (it previously took any string type)
    • Registering a dependency more than once will throw an error

Deprecations

  • SakuraApi.getModelByName has been marked deprecated (see #125)
  • SakuraApi.getRoutableByName has been marked deprecated (see #125)

Changes

@Route now takes an array of HTTP methods or *

See #90.

You can now bind multiple HTTP methods to a handler. For example:

@Routable()
export class SomeApi {
  @Route({
    method: ['get', 'post', 'put']
  })
  someHandler(req, res, next) {
    // route bound to GET, POST, or PUT / route
  }
}

You can also now bind a handler to respond to all methods:

@Routable()
export class SomeApi {
  @Route({
    method: '*'
  })
  someHandler(req, res, next) {
    // route bound to all methods for / route
  }
}

@FormatToJson() and FormatFromJson() now support * context

See #137

This lets you decorate a method in your @Routable class with @FormatToJson('*') or FormatFromJson(*) so that it will be called while marshalling to JSON or from JSON in any context.

@Json() now supports * context

See #130

This lets you decorate a property in your @Rourable class with @Json('*') so that it will be marshalled to and from json in any context.

You can no long register a dependency more than once

See #132

This is mostly for unit testing. Unit Tests might accidentally recycle a service, model or routable between tests, which could lead to strange behavior. You should call deregisterDependencies() on your instance of SakuraApi in your afterEach jasmine method to clean up after a test that registers dependencies with its instance of SakuraApi.

Some polish

  • #125 - @Model and @Routable have updated dependency injection logic that brings them into alignment with hour @Injectable providers work.
    • SakuraApi.getModelByName has been marked deprecated
    • SakuraApi.getRoutableByName has been marked deprecated
  • #133 - SakuraApi's unit tests are once again properly reporting their line numbers in TS if you happen to be working on SakuraApi.
  • #134 - added a Contributing file... help wanted
  • #135 - the never ending pursuit of updated npm packages
  • #142 - the never ending tasking of improving debug and error output for a better developer experience (DX)
  • #143 - better checking for SakuraMongoDbConnection.addConnection to make it more obvious that you accidentally passed in a config object rather than a config string.