@@ -133,9 +133,7 @@ export class Cookie<T> implements ElysiaCookie {
133133 ) { }
134134
135135 get cookie ( ) {
136- if ( ! ( this . name in this . jar ) ) this . jar [ this . name ] = this . initial
137-
138- return this . jar [ this . name ]
136+ return this . jar [ this . name ] ?? this . initial
139137 }
140138
141139 set cookie ( jar : ElysiaCookie ) {
@@ -144,98 +142,106 @@ export class Cookie<T> implements ElysiaCookie {
144142 this . jar [ this . name ] = jar
145143 }
146144
145+ protected get setCookie ( ) {
146+ if ( ! ( this . name in this . jar ) ) this . jar [ this . name ] = this . initial
147+
148+ return this . jar [ this . name ]
149+ }
150+
151+ protected set setCookie ( jar : ElysiaCookie ) {
152+ this . cookie = jar
153+ }
154+
147155 get value ( ) : T {
148156 return this . cookie . value as T
149157 }
150158
151159 set value ( value : T ) {
152- this . cookie . value = value
160+ this . setCookie . value = value
153161 }
154162
155163 get expires ( ) {
156164 return this . cookie . expires
157165 }
158166
159167 set expires ( expires ) {
160- this . cookie . expires = expires
161-
162- console . log ( this . cookie )
168+ this . setCookie . expires = expires
163169 }
164170
165171 get maxAge ( ) {
166172 return this . cookie . maxAge
167173 }
168174
169175 set maxAge ( maxAge ) {
170- this . cookie . maxAge = maxAge
176+ this . setCookie . maxAge = maxAge
171177 }
172178
173179 get domain ( ) {
174180 return this . cookie . domain
175181 }
176182
177183 set domain ( domain ) {
178- this . cookie . domain = domain
184+ this . setCookie . domain = domain
179185 }
180186
181187 get path ( ) {
182188 return this . cookie . path
183189 }
184190
185191 set path ( path ) {
186- this . cookie . path = path
192+ this . setCookie . path = path
187193 }
188194
189195 get secure ( ) {
190196 return this . cookie . secure
191197 }
192198
193199 set secure ( secure ) {
194- this . cookie . secure = secure
200+ this . setCookie . secure = secure
195201 }
196202
197203 get httpOnly ( ) {
198204 return this . cookie . httpOnly
199205 }
200206
201207 set httpOnly ( httpOnly ) {
202- this . cookie . httpOnly = httpOnly
208+ this . setCookie . httpOnly = httpOnly
203209 }
204210
205211 get sameSite ( ) {
206212 return this . cookie . sameSite
207213 }
208214
209215 set sameSite ( sameSite ) {
210- this . cookie . sameSite = sameSite
216+ this . setCookie . sameSite = sameSite
211217 }
212218
213219 get priority ( ) {
214220 return this . cookie . priority
215221 }
216222
217223 set priority ( priority ) {
218- this . cookie . priority = priority
224+ this . setCookie . priority = priority
219225 }
220226
221227 get partitioned ( ) {
222228 return this . cookie . partitioned
223229 }
224230
225231 set partitioned ( partitioned ) {
226- this . cookie . partitioned = partitioned
232+ this . setCookie . partitioned = partitioned
227233 }
228234
229235 get secrets ( ) {
230236 return this . cookie . secrets
231237 }
232238
233239 set secrets ( secrets ) {
234- this . cookie . secrets = secrets
240+ this . setCookie . secrets = secrets
235241 }
236242
237243 update ( config : Updater < Partial < ElysiaCookie > > ) {
238- this . cookie = Object . assign (
244+ this . setCookie = Object . assign (
239245 this . cookie ,
240246 typeof config === 'function' ? config ( this . cookie ) : config
241247 )
@@ -244,7 +250,7 @@ export class Cookie<T> implements ElysiaCookie {
244250 }
245251
246252 set ( config : Updater < Partial < ElysiaCookie > > ) {
247- this . cookie = Object . assign (
253+ this . setCookie = Object . assign (
248254 {
249255 ...this . initial ,
250256 value : this . value
0 commit comments