Skip to content

Commit 31de574

Browse files
committed
style: inline constructor arguments
1 parent bd3722c commit 31de574

File tree

6 files changed

+74
-10
lines changed

6 files changed

+74
-10
lines changed

docs/classes/_src_cookie_parser_index_.cookieparser.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
# Class: CookieParser
44

5+
Cookie parser parses the HTTP `cookie` method and collects all cookies
6+
inside an object of `key-value` pair, but doesn't attempt to decrypt
7+
or unsign or decode the individual values.
8+
9+
The cookie values are lazily decrypted, or unsigned to avoid unncessary
10+
processing, which infact can be used as a means to burden the server
11+
by sending too many cookies which even doesn't belongs to the
12+
server.
13+
514
## Hierarchy
615

716
* **CookieParser**
@@ -38,36 +47,47 @@ Name | Type |
3847

3948
### decode
4049

41-
**decode**(`key`: string): *any*
50+
**decode**(`key`: string): *any | null*
51+
52+
Attempts to decode a cookie by the name. When calling this method,
53+
you are assuming that the cookie was just encoded at the first
54+
place and not signed or encrypted.
4255

4356
**Parameters:**
4457

4558
Name | Type |
4659
------ | ------ |
4760
`key` | string |
4861

49-
**Returns:** *any*
62+
**Returns:** *any | null*
5063

5164
___
5265

5366
### decrypt
5467

55-
**decrypt**(`key`: string): *any*
68+
**decrypt**(`key`: string): *null | any*
69+
70+
Attempts to decrypt a cookie by the name. When calling this method,
71+
you are assuming that the cookie was encrypted at the first place.
5672

5773
**Parameters:**
5874

5975
Name | Type |
6076
------ | ------ |
6177
`key` | string |
6278

63-
**Returns:** *any*
79+
**Returns:** *null | any*
6480

6581
___
6682

6783
### list
6884

6985
**list**(): *object*
7086

87+
Returns an object of cookies key-value pair. Do note, the
88+
cookies are not decoded, unsigned or decrypted inside this
89+
list.
90+
7191
**Returns:** *object*
7292

7393
* \[ **key**: *string*\]: any
@@ -76,12 +96,15 @@ ___
7696

7797
### unsign
7898

79-
**unsign**(`key`: string): *any*
99+
**unsign**(`key`: string): *null | any*
100+
101+
Attempts to unsign a cookie by the name. When calling this method,
102+
you are assuming that the cookie was signed at the first place.
80103

81104
**Parameters:**
82105

83106
Name | Type |
84107
------ | ------ |
85108
`key` | string |
86109

87-
**Returns:** *any*
110+
**Returns:** *null | any*

docs/classes/_src_cookie_serializer_index_.cookieserializer.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
# Class: CookieSerializer
44

5+
Cookies serializer is used to serialize a value to be set on the `Set-Cookie`
6+
header. You can `encode`, `sign` on `encrypt` cookies using the serializer
7+
and then set them individually using the `set-cookie` header.
8+
59
## Hierarchy
610

711
* **CookieSerializer**
@@ -38,6 +42,14 @@ Name | Type |
3842

3943
**encode**(`key`: string, `value`: any, `options?`: Partial‹CookieOptions›): *string | null*
4044

45+
Encodes value as a plain cookie. Do note, the value is still JSON.stringified
46+
and converted to base64 encoded string to avoid encoding issues.
47+
48+
**`example`**
49+
```ts
50+
serializer.encode('name', 'virk')
51+
```
52+
4153
**Parameters:**
4254

4355
Name | Type |
@@ -54,6 +66,8 @@ ___
5466

5567
**encrypt**(`key`: string, `value`: any, `options?`: Partial‹CookieOptions›): *string | null*
5668

69+
Encrypts the value and returns it back as a url safe string.
70+
5771
**Parameters:**
5872

5973
Name | Type |
@@ -70,6 +84,9 @@ ___
7084

7185
**sign**(`key`: string, `value`: any, `options?`: Partial‹CookieOptions›): *string | null*
7286

87+
Signs the value and returns it back as a url safe string. The signed value
88+
has a verification hash attached to it to detect data tampering.
89+
7390
**Parameters:**
7491

7592
Name | Type |

docs/modules/_src_cookie_drivers_encrypted_.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
**canUnpack**(`encryptedValue`: string): *boolean*
1818

19+
Returns a boolean, if the unpack method from this module can attempt
20+
to unpack encrypted value.
21+
1922
**Parameters:**
2023

2124
Name | Type |
@@ -30,6 +33,8 @@ ___
3033

3134
**pack**(`key`: string, `value`: any, `encryption`: EncryptionContract): *null | string*
3235

36+
Encrypt a value to be set as cookie
37+
3338
**Parameters:**
3439

3540
Name | Type |
@@ -46,6 +51,10 @@ ___
4651

4752
**unpack**(`key`: string, `encryptedValue`: string, `encryption`: EncryptionContract): *null | any*
4853

54+
Attempts to unpack the encrypted cookie value. Returns null, when fails to do so.
55+
Only call this method, when `canUnpack` returns true, otherwise runtime
56+
exceptions can be raised.
57+
4958
**Parameters:**
5059

5160
Name | Type |

docs/modules/_src_cookie_drivers_plain_.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
**canUnpack**(`encodedValue`: string): *boolean*
1818

19+
Returns true when this `unpack` method of this module can attempt
20+
to unpack the encode value.
21+
1922
**Parameters:**
2023

2124
Name | Type |
@@ -30,6 +33,9 @@ ___
3033

3134
**pack**(`value`: any): *null | string*
3235

36+
Encodes a value into a base64 url encoded string to
37+
be set as cookie
38+
3339
**Parameters:**
3440

3541
Name | Type |
@@ -44,6 +50,9 @@ ___
4450

4551
**unpack**(`encodedValue`: string): *null | any*
4652

53+
Attempts to unpack the value by decoding it. Make sure to call, `canUnpack`
54+
before calling this method
55+
4756
**Parameters:**
4857

4958
Name | Type |

docs/modules/_src_cookie_drivers_signed_.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
**canUnpack**(`signedValue`: string): *boolean*
1818

19+
Returns a boolean, if the unpack method from this module can attempt
20+
to unpack the signed value.
21+
1922
**Parameters:**
2023

2124
Name | Type |
@@ -30,6 +33,9 @@ ___
3033

3134
**pack**(`key`: string, `value`: any, `encryption`: EncryptionContract): *null | string*
3235

36+
Signs a value to be shared as a cookie. The signed output has a
37+
hash to verify tampering with the original value
38+
3339
**Parameters:**
3440

3541
Name | Type |
@@ -46,6 +52,9 @@ ___
4652

4753
**unpack**(`key`: string, `signedValue`: string, `encryption`: EncryptionContract): *null | any*
4854

55+
Attempts to unpack the signed value. Make sure to call `canUnpack` before
56+
calling this method.
57+
4958
**Parameters:**
5059

5160
Name | Type |

src/Server/PreCompiler/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ export class PreCompiler {
8888
*/
8989
private resolver: IocResolverContract
9090

91-
constructor (
92-
container: IocContract,
93-
private middlewareStore: MiddlewareStoreContract,
94-
) {
91+
constructor (container: IocContract, private middlewareStore: MiddlewareStoreContract) {
9592
this.resolver = container.getResolver(undefined, 'httpControllers', 'App/Controllers/Http')
9693
}
9794

0 commit comments

Comments
 (0)