-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Allow query params to return all values (#48)
* Feat: Allow query params to return all values * chore(Query): apply feedback from review * fix: lint Co-authored-by: Thomas Cruveilher <[email protected]>
- Loading branch information
1 parent
7c6a7b5
commit 4728f54
Showing
5 changed files
with
241 additions
and
55 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
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 |
---|---|---|
|
@@ -85,33 +85,15 @@ not necessary to grab these properties manually. We can use dedicated decorators | |
instead, such as `@Body()` or `@Query()`, which are available out of the box. | ||
Below is a list of the provided decorators and the plain platform-specific | ||
objects they represent. | ||
|
||
<table> | ||
<tbody> | ||
<tr> | ||
<td><code>@Req()</code></td> | ||
<td><code>ctx.request</code></td></tr> | ||
<tr> | ||
<td><code>@Res()</code><span class='table-code-asterisk'>*</span></td> | ||
<td><code>ctx.response</code></td> | ||
</tr> | ||
<tr> | ||
<td><code>@Param(key: string)</code></td> | ||
<td><code>getQuery(context, { mergeParams: true })[key]</code></td> | ||
</tr> | ||
<tr> | ||
<td><code>@Header(key? : string)</code></td> | ||
<td><code>ctx.request.headers</code> / <code>ctx.request.headers.get(key)</code></td></tr> | ||
<tr> | ||
<td><code>@Body(key?: string)</code></td> | ||
<td><code>ctx.request.body</code> / <code>ctx.request.body[key]</code></td> | ||
</tr> | ||
<tr> | ||
<td><code>@Query(key: string)</code></td> | ||
<td><code>getQuery(context, { mergeParams: true })[key]</code></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
| Decorator | Type | Value | | ||
|-----------|------|-------| | ||
| `@Req()` | [oak.Request](https://deno.land/x/[email protected]/request.ts) | `ctx.request` | | ||
| `@Res()` | [oak.Response](https://deno.land/x/[email protected]/response.ts) | `ctx.response` | | ||
| `@Param(key: string)` | `string` | `context.params[key]` | | ||
| `@Header(key? : string)` | `string \| undefined` | `ctx.request.headers` / `ctx.request.headers.get(key)` | | ||
| `@Body(key?: string)` | `any` | `ctx.request.body` / `ctx.request.body[key]` | | ||
| `@Query(key: string, options?: { value?: 'first' \| 'last' \| 'array' })` | `string \| string[]` | Get the `first`, the `last` or `all` the values for the query parameter named `key` | | ||
| `@Query(options?: { value?: 'first' \| 'last' \| 'array' })` | `{ [key: string]: string \| string[] }` | Get the `first`, the `last` or `all` the values for all the query parameters | | ||
|
||
### Resources | ||
|
||
|
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