forked from ocamllabs/vscode-ocaml-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow users to generate documentation for packages in switches using odig
- Loading branch information
Showing
22 changed files
with
616 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(library | ||
(name polka) | ||
(preprocess | ||
(pps gen_js_api.ppx)) | ||
(js_of_ocaml | ||
(javascript_files polka_stub.js)) | ||
(libraries interop promise_jsoo jsonoo js_of_ocaml gen_js_api node) | ||
(modes byte)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
open Interop | ||
|
||
module Server = struct | ||
include Interface.Make () | ||
|
||
module Address = struct | ||
include Interface.Make () | ||
|
||
include [%js: val port : t -> int [@@js.get]] | ||
|
||
include [%js: val address : t -> string [@@js.get]] | ||
end | ||
|
||
include | ||
[%js: | ||
val close : | ||
t -> ?callback:(Node.JsError.t or_undefined -> unit) -> unit -> t | ||
[@@js.call "close"] | ||
|
||
val address : t -> Address.t or_undefined [@@js.call] | ||
|
||
val on : t -> string -> Ojs.t -> unit [@@js.call]] | ||
|
||
let on t = function | ||
| `Close f -> on t "close" @@ [%js.of: unit -> unit] f | ||
| `Error f -> on t "error" @@ [%js.of: err:Node.JsError.t -> unit] f | ||
end | ||
|
||
type polka = Ojs.t [@@js] | ||
|
||
module Middleware = struct | ||
module Request = struct | ||
include Interface.Make () | ||
end | ||
|
||
module Response = struct | ||
include Interface.Make () | ||
end | ||
|
||
type t = | ||
request:Request.t -> response:Response.t -> next:(unit -> polka) -> polka | ||
[@@js] | ||
end | ||
|
||
include | ||
[%js: | ||
val create : unit -> polka [@@js.global "polka"] | ||
|
||
val listen_ : | ||
polka | ||
-> int | ||
-> ?hostname:string | ||
-> ?callback:(unit -> unit) | ||
-> unit | ||
-> polka | ||
[@@js.call "listen"] | ||
|
||
val get_ : polka -> string -> (unit -> unit) -> polka [@@js.call "get"] | ||
|
||
val use_ : polka -> (Middleware.t list[@js.variadic]) -> polka | ||
[@@js.call "use"] | ||
|
||
val server : polka -> Server.t [@@js.get]] | ||
|
||
let get path callback t = get_ t path callback | ||
|
||
let listen port ?hostname ?callback t = listen_ t port ?hostname ?callback | ||
|
||
let use middlewares t = use_ t middlewares | ||
|
||
module Sirv = struct | ||
module Options = struct | ||
include Interface.Make () | ||
|
||
include [%js: val create : dev:bool -> t [@@js.builder]] | ||
end | ||
|
||
include | ||
[%js: | ||
val serve : | ||
string -> ?options:Options.t -> unit -> (Middleware.t[@js.dummy]) | ||
[@@js.global "sirv"]] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
open Interop | ||
|
||
module Server : sig | ||
module Address : sig | ||
include Js.T | ||
|
||
val port : t -> int | ||
|
||
val address : t -> string | ||
end | ||
|
||
type t | ||
|
||
val close : t -> ?callback:(Node.JsError.t or_undefined -> unit) -> unit -> t | ||
|
||
val address : t -> Address.t or_undefined | ||
(* TODO: the return type can also be a string in case the server uses a pipe | ||
or Unix Domain Socket, but we don't handle that case *) | ||
|
||
val on : | ||
t | ||
-> [ `Close of unit -> unit | `Error of err:Node.JsError.t -> unit ] | ||
-> unit | ||
end | ||
|
||
type polka | ||
|
||
module Middleware : sig | ||
module Request : sig | ||
include Js.T | ||
end | ||
|
||
module Response : sig | ||
include Js.T | ||
end | ||
|
||
type t = | ||
request:Request.t -> response:Response.t -> next:(unit -> polka) -> polka | ||
end | ||
|
||
val create : unit -> polka | ||
|
||
val listen : | ||
int -> ?hostname:string -> ?callback:(unit -> unit) -> polka -> unit -> polka | ||
|
||
val get : string -> (unit -> unit) -> polka -> polka | ||
|
||
val use : Middleware.t list -> polka -> polka | ||
|
||
val server : polka -> Server.t | ||
|
||
module Sirv : sig | ||
module Options : sig | ||
type t | ||
|
||
val create : dev:bool -> t | ||
end | ||
|
||
val serve : string -> ?options:Options.t -> unit -> Middleware.t | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
joo_global_object.polka = require("polka"); | ||
joo_global_object.sirv = require("sirv"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.