Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
PodaruDragos committed Nov 25, 2023
2 parents 70c7464 + 91ae97a commit 574cee2
Show file tree
Hide file tree
Showing 12 changed files with 2,428 additions and 9,537 deletions.
10 changes: 7 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"typescript-sort-keys"
"@typescript-eslint"
],
"rules": {
// Javscript Specific Rules That Are Applied To Typescript Too
Expand Down Expand Up @@ -53,11 +52,16 @@
}
],
// Typescript Specific Rules From This Point On
"typescript-sort-keys/interface": 2,
"typescript-sort-keys/string-enum": 0,
"@typescript-eslint/explicit-function-return-type": 2,
"@typescript-eslint/no-explicit-any": 2,
"@typescript-eslint/no-inferrable-types": 2,
"@typescript-eslint/no-misused-promises": [
"error",
{
"checksVoidReturn": false
}
],
"@typescript-eslint/no-non-null-assertion": 2,
"@typescript-eslint/no-unsafe-call": 2,
"@typescript-eslint/no-unsafe-member-access": 2,
Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Registers the decorated controller method as a request handler for a particular

### `@SHORTCUT(path, [middleware, ...])`

Shortcut decorators which are simply wrappers for `@httpMethod`. Right now these include `@httpGet`, `@httpPost`, `@httpPut`, `@httpPatch`, `@httpHead`, `@httpDelete`, and `@All`. For anything more obscure, use `@httpMethod` (Or make a PR :smile:).
Shortcut decorators which are simply wrappers for `@httpMethod`. Right now these include `@httpGet`, `@httpPost`, `@httpPut`, `@httpPatch`, `@httpHead`, `@httpDelete`, `@httpOptions`, and `@All`. For anything more obscure, use `@httpMethod` (Or make a PR :smile:).

### `@request()`

Expand Down Expand Up @@ -664,6 +664,25 @@ class Service {
The `BaseMiddleware.bind()` method will bind the `TYPES.TraceIdValue` if it hasn't been bound yet or re-bind if it has
already been bound.
### Dealing with CORS
If you access a route from a browser and experience a CORS problem, in other words, your browser stops at the
OPTIONS request, you need to add a route for that method too. You need to write a method in your controller class to
handle the same route but for OPTIONS method, it can have empty body and no parameters though.
```ts
@controller("/api/example")
class ExampleController extends BaseHttpController {
@httpGet("/:id")
public get(req: Request, res: Response) {
return {};
}

@httpOptions("/:id")
public options() { }
}
```
## Route Map
If we have some controllers like for example:
Expand Down
Loading

0 comments on commit 574cee2

Please sign in to comment.