eberfreitas / elm-express / Express.Conn

This module provides access to the Conn type, which combines three types: Express.Request, Express.Response, and your application's model/state. The Conn type is designed to easily transfer request information through your application's functions.

Types


type alias Conn model =
{ request : Express.Request.Request
, response : Express.Response.Response
, model : model 
}

The Conn type is a combination of the Express.Request, Express.Response types and your application's model/state. It is used to efficiently pass request information through your app's functions.

Helpers

send : Conn model -> Json.Encode.Value

The send function is a utility function that encodes a Conn into a JSON object that can be sent through the responsePort of your application. The JavaScript part of elm-express expects the JSON object to have a certain format, which can be achieved using this function. Once the Conn has been encoded, you can use the following pattern to send your responses:

conn |> Express.Conn.send |> responsePort

This will send the encoded Conn through the responsePort, allowing you to respond to the client with the appropriate data.