 import PerfectMarkdown
 
 /// server port to start with
-let port = 7777
+let PORT = 7777
 
+/// web socket protocol
+let PROTOCOL = "editor"
+
+/// web socket api entry
+let API = "editor"
+
+/// WebSocket Event Handler
 public class EditorHandler: WebSocketSessionHandler {
 
-  public let socketProtocol : String? = "editor"
+  public let socketProtocol : String? = PROTOCOL
 
   // This function is called by the WebSocketHandler once the connection has been established.
   public func handleSession(request: HTTPRequest, socket: WebSocket) {


    WebSocketHandler(handlerProducer: { (request: HTTPRequest, protocols: [String]) -> WebSocketSessionHandler? in

      guard protocols.contains("editor") else {
        return nil
      }//end guard


      // convert the input from markdown to HTML
      let output = input.markdownToHTML ?? ""

      // sent it back to the request
      socket.sendStringMessage(string: output, final: true) {
        self.handleSession(request: request, socket: socket)
      }//end send
