Skip to content

Previous Versions

Thiago Bustamante edited this page Aug 17, 2020 · 7 revisions

Upgrade Instructions

The following breaking changes must be observed when updating typescript-rest to 2.X version.

From 0.X to 1.X

Starting from version 1.0.0, it is required to inform the body type on all ReferencedResources, like:

interface NewObject {
   id: string;
}

class TestService {
     @POST
    test(myObject: MyClass): Return.NewResource<NewObject> {
        //...
       return new Return.NewResource<NewObject>(req.url + "/" + generatedId, {id: generatedId}); //Returns a JSON on body {id: generatedId}
     }
  }

Even when you do not provide a body on a ReferencedResource, you need to inform <void>

class TestService {
     @POST
    test(myObject: MyClass): Return.RequestAccepted<void> {
        //...
       return new Return.RequestAccepted<void>(req.url + "/" + generatedId);
     }
  }

From 1.X to 2.X

  • Starting from version 2.0.0, the method Server.setParamConverter was removed and replaced by Server.addParameterConverter.

  • The method Server.swagger was refactored to receive an SwaggerOptions object.

  • Deprecated ForbidenError was removed in favor of ForbiddenError.

  • The decorator @Preprocessor was renamed to @PreProcessor.

From 2.X to 3.X

  • We removed the dependency with typescript-ioc library. So, the method Server.useIoC() was also removed. To integrate typescript-ioc and typescript-rest, you need to use a service factory that is available in the npm module typesctipt-rest-ioc.

So, you need to install the factory:

npm i --save typesctipt-rest-ioc

Then edit the file rest.config in the root of your project to:

{
  "serviceFactory": "typesctipt-rest-ioc"
}

Or, you can also call the method Server.registerServiceFactory, like:

import IoCServiceFactory from 'typescript-rest-ioc';
import { Server } from 'typescript-rest';

Server.registerServiceFactory(IoCServiceFactory);

If you don't use typescript-ioc, your code should work without any change.