Skip to content

Commit

Permalink
add cookie-parser as a dependency and add .cookie to Middleware module
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkorp committed Sep 1, 2020
1 parent 4892d02 commit 0ce5924
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"dependencies": {
"body-parser": "^1.18.3",
"cookie-parser": "^1.4.5",
"express": "^4.16.3"
},
"devDependencies": {
Expand Down
5 changes: 5 additions & 0 deletions src/Express.re
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ module Middleware = {
"type": string,
"limit": Js.Nullable.t(int),
};
type cookieOptions = {. "decode": option(string => Js.Json.t)};
[@bs.module "express"] [@bs.val] external json_ : jsonOptions => t = "json";
[@bs.module "express"] [@bs.val]
external urlencoded_ : urlEncodedOptions => t = "urlencoded";
Expand Down Expand Up @@ -488,6 +489,10 @@ module Middleware = {
"limit": ByteLimit.toBytes(limit),
"inflate": inflate,
});
[@bs.module "cookie-parser"] [@bs.val]
external cookie_: (option(string), cookieOptions) => t = "raw";
let cookie = (~secret=?, ~decode=?, ()) =>
cookie_(secret, {"decode": decode});
module type S = {
type f;
type errorF;
Expand Down
1 change: 1 addition & 0 deletions src/Express.rei
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ module Middleware: {
unit
) =>
t;
let cookie: (~secret: string=?, ~decode: string => Js.Json.t=?, unit) => t;
module type S = {
type f;
let from: f => t;
Expand Down

0 comments on commit 0ce5924

Please sign in to comment.