-
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Update documentation about controllers, interceptors and middle…
…wares
- Loading branch information
Showing
13 changed files
with
133 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<mxfile modified="2019-06-13T06:42:52.808Z" host="www.draw.io" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:67.0) Gecko/20100101 Firefox/67.0" etag="1uh4_nf9ed0mNrsc8kY8" version="10.7.7" type="device"><diagram id="DG_1D_lNAm6PYI5epRoH" name="Page-1">7ZtRj+I2EIB/DVL7sFUShyQ8Lix3W7VVJVZV754qk0xI7kzMOWaB/fV1iA1JHSA9hfgOjpVW8YztxDP+PM4YBmiy3L5neJX8QSMgA8eKtgP0NHAc3xuK/4VgVwpcNygFC5ZGpcg+Cl7SN5BCS0rXaQR5rSKnlPB0VReGNMsg5DUZZoxu6tViSup3XeEFaIKXEBNd+nca8aSUBo5/lD9DukjUnW1vVGqWWFWWI8kTHNFNRYSmAzRhlPLyarmdAClsp+xStnt3Qnt4MAYZb9OAPYSPT7s3dzl7/u3X3eztz+2Hfx6QHMcrJms5Yvm0fKdMwOg6i6DoxRqg8SZJObyscFhoN8LnQpbwJRElW1zmnNHPMKGEsn1rNPJ8hD2hiVNCKnKwoyH4Qi4fABiH7cmh2QeDiYkGdAmc7UQV2cCxpI3lJLN9Wd4cXeaqOknFXUMlxHKaLA59Hy0pLqQx/49hvWsbNnDmyGswrDBrELkdGdauG/YwmSuGRXaDYd2rGdbXzAiRIFYWKeMJXdAMk+lROq4b+ljnd0pX0ryfgPOdXH7wmtO68WGb8g9F81+GsvSxonnayp73hZ0qZGK4lUZF8WNVd2y2L6l2mqMty3ej0cGhxXDPu1NYh65ZCGesqJZSzBbAz9Rzm6cHA4J5+lp/js5dbWsITUhaDNWxZvBlDTk/g5T9FUgdLB3TjL/Dy5QUTnkG8go8DXE3TCG3zpSrI2U7DUh51yIq+EFUB0S5LYnyTBLlakS9J3SOi3bLNIoIbMTI846pivzR3LL0QBXH4IVhz7TZqCVu6Fq42eh74a0XbryW3NhWs5/7AadpN+cR8bzjKH0Vl4vi8q8cxhBTBoNiQpXqOVNaJRH3r7Rp6KZGYnObTvm8uEPvlc/AOJ/u98LnNx0P1VvBZbAdo3tMSyP7gPEUh8lVI+M3RZ5jPjK2eGfuAcV+8HDa4jE0iodzGo+rouGFAczjhuwGhiDue9PomA9KwR2hMWyLhm8UjWETGvcTL5DxeOHosft2ofDbQjEyCoV+njDNohVN91m7BGeCDNYxFRcT4b1SYTxUKAjugopRSypOebEnKkZNoeIx5gUL97KJcs3HCz39ebNkHA7LL5KBTJKhOr5vMszHDM8ECDeX83JQW+iMvtSrx6xANwPhygI5lXHO1yuVbv7J/rmSh64oumZy/9GZjIfFn2SyIi8/PbM6NB/F9M3E7UaxtqkAJzAKlJ4KeBFAzSBf0SyHE1g5P7A6YmU8BCJ9J3K7WAUtsUJGD12dpqRn06mr3C9+/fnq5VPa283jecYjGtLzePf2tRTP/Pp3GrbCEDXLe1/WVCke8v1S9igq2N5qWyIk9QqfiajHKCE1SMteT/AlLMvP+S+jGfzHdVKESbrIRDEUnhD3Q+PCT8Jv5FEqyhl1YsLU1++TM6BQyCXc9rqZEQfPnvkihNswIZxrTQhXp1KlcnUU79BfLY7PO/KXKB5/JrDXVX5rgab/Ag==</diagram></mxfile> |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<mxfile modified="2019-06-13T09:48:25.934Z" host="www.draw.io" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:67.0) Gecko/20100101 Firefox/67.0" etag="zNQGLAyjXp85JX7BV83r" version="10.7.7" type="device"><diagram id="-pNohHKRrXRFJF8rd36P" name="Page-1">5VZNc5swEP01nmkPngFkY3yMidtMJzm0PjRXBa1BiWCpEAb311cYiY+QeJJp04/phZHe7rK7b/UEMxKm9UdJ8+QGGYiZ57B6Ri5nnrd2A/1sgGMLLIkBYslZC7k9sOPfwYCOQUvOoBg5KkSheD4GI8wyiNQIo1JiNXbboxhnzWkME2AXUTFFv3KmkhYNvFWPXwGPE5vZ9detJaXW2XRSJJRhNYDIdkZCiajaVVqHIBruLC9t3IdnrF1hEjL1kgD1KaK3F/Po9vMqvNhfX9X7ZD4n7VsOVJSmYVOsOloGgGlCzBalSjDGjIptj24klhmDJo2jd73PNWKuQVeD96DU0UyXlgo1lKhUGGuhJD5AiALlKSdxnNXict1ZLPOas01bX1PUszwYqMBSRnCmeXueqIxBnfHzumnpUw6YgpJHHSdBUMUP4zqoOW9x59ePRC/MVF4xIXcyoVDwplXP+QLfSijUZGL9PBpyq4Qr2OX0REWlRfqz3B9AKqjPsz9lywZYOZj7IDDbqhdX55IMhOU7b8Tv8n9WgPdCBSz+pAK8yYRuOGMCKt3wLz77gXdHfF9b9lyIAc6WELDFW2mC/G2aWDyhCV/orBvGD3oZN8ttxnLkzUXUmnSmgfWJgHfS3lf645jnPIvfW687+Tju8dv+oStu+fvGqbf9D8TJNvgLI9sf</diagram></mxfile> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {IInterceptor, IInterceptorContext, IInterceptorNextHandler, Interceptor} from "@tsed/common"; | ||
|
||
@Interceptor() | ||
export class MyInterceptor implements IInterceptor { | ||
/** | ||
* ctx: The context that holds the dynamic data related to the method execution and the proceed method | ||
* to proceed with the original method execution | ||
* | ||
* opts: Static params that can be provided when the interceptor is attached to a specific method | ||
*/ | ||
intercept(context: IInterceptorContext<any>, next: IInterceptorNextHandler) { | ||
console.log(`the method ${context.propertyKey} will be executed with args ${context.args} and static data ${context.options}`); | ||
// let the original method proceed | ||
const result = context.next(); | ||
|
||
console.log(`the method was executed, and returned ${result}`); | ||
|
||
// must return the returned value back to the caller | ||
// the retValue might be a promise in which case you can use .then to chain other code logic | ||
// or you can use async aroundInvoke and await ctx.proceed() to execute the code in linear fashion | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {Intercept} from "@tsed/common"; | ||
import {MyInterceptor} from "../interceptors/MyInterceptor"; | ||
|
||
export class MyService { | ||
// MyInterceptor is going to be used to intercept this method whenever called | ||
// 'simple data' is static data that will be passed as second arg the the interceptor aroundInvoke | ||
// this can be any data, you can pass array or object for that matter | ||
@Intercept(MyInterceptor, "simple data") | ||
mySimpleMethod() { | ||
console.log("the simple method is executed"); | ||
} | ||
} |
Oops, something went wrong.