web_api_base 2.5.0 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +34 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web_api_base",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "description": "web api base",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -14,19 +14,28 @@ npm install web_api_base
14
14
  ## Usage
15
15
 
16
16
  First of all we need implement the abstract class __Application__.
17
- After that, we need to create some controllers and, they must inherit the abstract class __ControllerBase__.
17
+ After that, we need to create some controllers and they must inherit the abstract class __ControllerBase__.
18
18
 
19
- ### SampleController.ts
19
+ ### ./controllers/SampleController.ts
20
20
 
21
21
  ```typescript
22
22
 
23
- import { ControllerBase, ControllersDecorators as CD, HTTPVerbs as verbs } from "web_api_base";
23
+ import { ControllerBase, HTTPVerbs as verbs, Use, Verb, Route, Action } from "web_api_base";
24
+ /*
24
25
 
25
- @CD.Route("/sample")
26
+ we can use this class to acess all decorators centralized
27
+ import { ControllerDecorators as CD } from "web_api_base";
28
+
29
+ */
30
+
31
+ //@CD.Route("/sample")
32
+ @Route("/sample")
26
33
  export default class SampleController extends ControllerBase
27
34
  {
28
- @CD.Verb(verbs.GET)
29
- @CD.Action("/hello")
35
+ //@CD.Verb(verbs.GET)
36
+ @Verb(verbs.GET)
37
+ //@CD.Action("/hello")
38
+ @Action("/hello")
30
39
  public Hello() : void
31
40
  {
32
41
  this.OK({message: "Hello Word!"})
@@ -48,17 +57,32 @@ export default class App extends Application
48
57
 
49
58
  public override Configure(appConfig: IApplicationConfiguration): void
50
59
  {
51
- appConfig.Host = "0.0.0.0";
52
- appConfig.Port = 5555;
60
+ //to define the host use this property, if that property is not changed, the default value will be 0.0.0.0
61
+ appConfig.Host = "127.0.0.1";
62
+ //to define the app port use this property, if that property is not changed, the default value will be 5555
63
+ appConfig.Port = 1234;
53
64
 
54
65
  //allow CORS
55
66
  this.UseCors();
56
67
 
57
68
  //register in DI service
58
69
  DependecyService.Register(SampleController);
70
+
71
+ */
72
+ if the controlles follow the naming rules, the method UseControllers will automatically append them
73
+
74
+ rootDir -
75
+ |
76
+ | - controllers -
77
+ | - <Name>Controller.ts
78
+ |
79
+ | - App.ts //the class that inherit the Application
80
+
81
+ */
82
+ this.UseControllers();
59
83
 
60
- //append the controller in the pipe line of requests
61
- ControllerBase.AppendController(SampleController,this);
84
+ //if not, we can append manually using the method bellow
85
+ //ControllerBase.AppendController(SampleController,this);
62
86
 
63
87
  }
64
88
  }