-
Notifications
You must be signed in to change notification settings - Fork 110
Previous Versions
The following breaking changes must be observed when updating typescript-rest to 2.X version.
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);
}
}
-
Starting from version 2.0.0, the method
Server.setParamConverter
was removed and replaced byServer.addParameterConverter
. -
The method
Server.swagger
was refactored to receive anSwaggerOptions
object. -
Deprecated
ForbidenError
was removed in favor ofForbiddenError
. -
The decorator
@Preprocessor
was renamed to@PreProcessor
.
- 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.
- Server
- @Path Decorator
- Http Methods
- Request Parameters
- Types and languages
- @BodyOptions Decorator
- Service Context
- Service Return
- @Security Decorator
- Express Middlewares
- @PreProcessor Decorator
- @PostProcessor Decorator
- Server Errors
- Service Factory and IoC
- Inheritance and Abstract Services
- Swagger Documentation