@buntal/http 0.0.5 → 0.0.7

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.
package/app/cookie.ts CHANGED
@@ -11,7 +11,7 @@ export type CookieOptions = {
11
11
  sameSite?: 'Strict' | 'Lax' | 'None'
12
12
  }
13
13
 
14
- export const cookie = {
14
+ export const Cookie = {
15
15
  get: (req: Req, name: string) => {
16
16
  const cookies = req.headers.get('cookie')
17
17
  if (!cookies) return null
@@ -31,7 +31,7 @@ export const cookie = {
31
31
  return cookieArray.reduce((acc, cookie) => {
32
32
  const [key, value] = cookie.split('=') as [string, string?]
33
33
  return { ...acc, [key]: decodeURIComponent(value || '') }
34
- }, {})
34
+ }, {} as Record<string, string>)
35
35
  },
36
36
  set: (
37
37
  res: Res,
package/app/request.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { cookie } from './cookie'
1
+ import { Cookie } from './cookie'
2
2
 
3
3
  export class Req<P = Record<string, string>, T = unknown> extends Request {
4
4
  public params: P = {} as P
@@ -6,6 +6,6 @@ export class Req<P = Record<string, string>, T = unknown> extends Request {
6
6
  public context?: T
7
7
 
8
8
  get cookies() {
9
- return cookie.getAll(this)
9
+ return Cookie.getAll(this)
10
10
  }
11
11
  }
package/app/response.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { BodyInit } from 'bun'
2
- import { cookie, type CookieOptions } from './cookie'
2
+ import { Cookie, type CookieOptions } from './cookie'
3
3
 
4
4
  export class Res {
5
5
  private options: {
@@ -59,9 +59,9 @@ export class Res {
59
59
 
60
60
  cookie(name: string, value?: string | null, options?: CookieOptions) {
61
61
  if (value) {
62
- cookie.set(this, name, value, options)
62
+ Cookie.set(this, name, value, options)
63
63
  } else {
64
- cookie.delete(this, name)
64
+ Cookie.delete(this, name)
65
65
  }
66
66
  return this
67
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buntal/http",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {