1module Playground.Handler where
5import Data.Maybe (Maybe)
6import Effect.Aff.Class (liftAff)
7import Effect.Class (class MonadEffect, liftEffect)
8import Node.Buffer (Buffer)
9import Node.Buffer as Buffer
10import Node.Encoding (Encoding(..))
11import Node.Express.Handler (HandlerM)
12import Node.Express.Request (getBody')
13import Node.Express.Response as Response
14import Playground.Playground (asErrorWithCode, compileCode, runCode)
15import Shared.Json (readAff)
16import Shared.Models.Body (RunResult)
17import Shared.Models.Body as Body
18import Simple.JSON (write)
20toBody ∷ ∀ r m. MonadEffect m => { stdout ∷ Buffer, stderr ∷ Buffer | r } -> m RunResult
21toBody result = liftEffect $ ado
22 stdout <- Buffer.toString UTF8 result.stdout
23 stderr <- Buffer.toString UTF8 result.stderr
24 let (code ∷ Maybe Int) = asErrorWithCode result >>= _.code
25 in { code, stdout, stderr } ∷ RunResult
27compileHandler ∷ HandlerM Unit
30 json <- readAff body # liftAff
31 result <- compileCode (json ∷ Body.CompileRequest).code # liftAff
32 Response.send $ write ({ result } ∷ Body.CompileResult)
34runHandler ∷ HandlerM Unit
39 Response.send $ write (result ∷ Body.RunResult)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list