Skip to content

Commit 0ce5924

Browse files
committed
add cookie-parser as a dependency and add .cookie to Middleware module
1 parent 4892d02 commit 0ce5924

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "index.js",
66
"dependencies": {
77
"body-parser": "^1.18.3",
8+
"cookie-parser": "^1.4.5",
89
"express": "^4.16.3"
910
},
1011
"devDependencies": {

src/Express.re

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ module Middleware = {
442442
"type": string,
443443
"limit": Js.Nullable.t(int),
444444
};
445+
type cookieOptions = {. "decode": option(string => Js.Json.t)};
445446
[@bs.module "express"] [@bs.val] external json_ : jsonOptions => t = "json";
446447
[@bs.module "express"] [@bs.val]
447448
external urlencoded_ : urlEncodedOptions => t = "urlencoded";
@@ -488,6 +489,10 @@ module Middleware = {
488489
"limit": ByteLimit.toBytes(limit),
489490
"inflate": inflate,
490491
});
492+
[@bs.module "cookie-parser"] [@bs.val]
493+
external cookie_: (option(string), cookieOptions) => t = "raw";
494+
let cookie = (~secret=?, ~decode=?, ()) =>
495+
cookie_(secret, {"decode": decode});
491496
module type S = {
492497
type f;
493498
type errorF;

src/Express.rei

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ module Middleware: {
304304
unit
305305
) =>
306306
t;
307+
let cookie: (~secret: string=?, ~decode: string => Js.Json.t=?, unit) => t;
307308
module type S = {
308309
type f;
309310
let from: f => t;

0 commit comments

Comments
 (0)