Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/GreenfinityNext.res
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ module Url = GreenfinityNext_Url
module NextServer = GreenfinityNext_NextServer
module Font = GreenfinityNext_Font
module Cache = GreenfinityNext_Cache
module Cookies = GreenfinityNext_Cookies
29 changes: 29 additions & 0 deletions src/GreenfinityNext_Cookies.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
type cookieOptions = {
name?: string,
value?: string,
path?: string,
maxAge?: int,
expires?: Date.t,
httpOnly?: bool,
secure?: bool,
sameSite?: [#strict | #lax | #none],
}

type cookie = {
name: string,
value: string,
}

type t

@module("next/headers") external make: unit => promise<t> = "cookies"

@send @returns(nullable) external get: (t, string) => option<cookie> = "get"

@send external getAll: t => array<cookie> = "getAll"

@send external has: (t, string) => bool = "has"

@send external set: (t, string, string, ~options: cookieOptions=?) => unit = "set"

@send external delete: (t, string) => unit = "delete"
2 changes: 1 addition & 1 deletion src/GreenfinityNext_Next.res
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ module Image = {
module Headers = {
type t

@deprecated("Use makePromise instead and await the result.") @new @module("next/headers")
@deprecated("Use makeAsync instead and await the result.") @new @module("next/headers")
external make: unit => t = "headers"

@new @module("next/headers") external makeAsync: unit => promise<t> = "headers"
Expand Down
13 changes: 3 additions & 10 deletions src/GreenfinityNext_NextServer.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@
// --

module NextRequest = {
module Cookies = {
type t
@send external set: (t, string, string) => unit = "set"
@send external get: (t, string) => string = "get"
@send external getAll: t => dict<string> = "getAll"
@send external delete: (t, string) => unit = "delete"
@send external has: (t, string) => bool = "has"
@send external clear: t => unit = "clear"
}
@deprecated("Use GreenfinityNext.Cookies instead")
module Cookies = GreenfinityNext_Cookies

module URL = {
type t = {
Expand All @@ -36,7 +29,7 @@ module NextRequest = {
type t = {
headers: GreenfinityNext_Fetch.Headers.t,
nextUrl: URL.t,
cookies: Cookies.t,
cookies: GreenfinityNext_Cookies.t,
}

@send external json: t => promise<JSON.t> = "json"
Expand Down