Created
November 10, 2017 15:23
-
-
Save bkonkle/ec15aa81e99cc0827daf6c170124429e to your computer and use it in GitHub Desktop.
Reason with Koa Router
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
type koaRouter; | |
[@bs.module] external koaRouter : koaRouter = "koa-router"; | |
[@bs.new] external newRouter : unit => koaRouter = "KoaRouter"; | |
[@bs.send] external get : (koaRouter, string, 'a => Js.Promise.t(unit)) => unit = ""; | |
[@bs.send] external post : (koaRouter, string, 'a => Js.Promise.t(unit)) => unit = ""; | |
[@bs.send] external routes : koaRouter => 'a = ""; | |
[@bs.send] external allowedMethods : koaRouter => 'a = ""; | |
let init = (dataProvider) => { | |
koaRouter |> ignore; /* TODO: This is a workaround to get bs to import koa-router */ | |
let router = newRouter(); | |
let room = RoomHandler.init(dataProvider); | |
get( | |
router, | |
"/", | |
(ctx) => { | |
ctx##body#="ok"; | |
Js.Promise.resolve() | |
} | |
); | |
post(router, "/room/link", room.postLink); | |
router | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment