purescript-hyper / hyper

Type-safe, statically checked composition of HTTP servers
https://hyper.wickstrom.tech
Mozilla Public License 2.0
282 stars 29 forks source link

[Info/Question] PureScript 0.12 #75

Closed giuliohome closed 5 years ago

giuliohome commented 5 years ago

Just to share the changes I had to do to run the example in the Getting Started

Notice that I had to install the following (which was not specified)

bower i purescript-indexed-monad

and my final code for the Main.purs is

module Main where

import Prelude
import Control.Monad.Indexed ((:*>))
import Effect (Effect)
import Effect.Console (log)
import Hyper.Node.Server (defaultOptionsWithLogging, runServer)
import Hyper.Response (closeHeaders, respond, writeStatus)
import Hyper.Status (statusOK)
import Node.HTTP 

main :: Effect Unit
main =
  let app = writeStatus statusOK
            :*> closeHeaders
            :*> respond "Hello, Hyper!"
  in runServer defaultOptionsWithLogging {} app

It seems that the server is running fine on my localhost port 300 and I'm getting an "Hello, Hyper!" from there...

giuliohome commented 5 years ago

in the meantime I've found the updated doc here

this issue has originated from the fact that the "latest" version shown from https://hyper.wickstrom.tech is misleading

nsaunders commented 5 years ago

Sorry about that. @owickstrom has a lot of other projects and priorities but will upload the docs when time permits. I have also opened #71 to hopefully enable other contributors to keep the docs up-to-date, but I have yet to do any significant work on it.

giuliohome commented 5 years ago

Thank you very much for the prompt response and for the great work.

Excuse me for the off topic, but: is there an example or is there anyone using (twitter) oauth (server side) on purescript (in this case I mean on Hyper)? My initial idea for learning Hyper was indeed porting a Twitter app of mine from my Flutter/Android mobile to Hyper (to run it on my windows laptop). I was wondering if I had to use an Haskell web server, but I thought choosing Purescript/Hyper would have been simpler and lighter... Thanks again for all the useful information.

nsaunders commented 5 years ago

It sounds like a good use case for something like Hyper, but I think you'd have to create your own middleware for OAuth. If you're feeling ambitious, here are some links that might help:

giuliohome commented 5 years ago

Ok, understood, thank you very much for the prompt feedback and the useful links. Much appreciated. Best regards

owickstrom commented 5 years ago

Docs for 0.9.0 are uploaded now. I'm sending a PR with some docs script fixes soon, but we're moving to RTD anyway so not super important.