<commit_before>package main

import (
	"fmt"
	"github.com/roblaszczak/go-chat/chat"
	"github.com/roblaszczak/go-chat/config"
	"github.com/roblaszczak/go-chat/websocket"
	"log"
	"net/http"
)

func main() {
	RunServer(config.SERVER_HOST, config.SERVER_PORT)
}

func RunServer(host string, port int) {
	websocketController := websocket.NewWebsocketController()
	http.Handle("/chat", websocketController)

	chatCore := chat.NewChat()
	bridge := websocket.NewChatBridge(websocketController, chatCore)
	bridge.Listen()

	fs := http.FileServer(http.Dir(config.PUBLIC_DIR))
	http.Handle("/", fs)
	log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%d", host, port), nil))
}<commit_msg>added panic on missing app js file<commit_after>package main

import (
	"fmt"
	"github.com/roblaszczak/go-chat/chat"
	"github.com/roblaszczak/go-chat/config"
	"github.com/roblaszczak/go-chat/websocket"
	"log"
	"net/http"
	"os"
)

func main() {
	RunServer(config.SERVER_HOST, config.SERVER_PORT)
}

func RunServer(host string, port int) {
	websocketController := websocket.NewWebsocketController()
	http.Handle("/chat", websocketController)

	chatCore := chat.NewChat()
	bridge := websocket.NewChatBridge(websocketController, chatCore)
	bridge.Listen()

	assertPublicDirFiles()
	fs := http.FileServer(http.Dir(config.PUBLIC_DIR))
	http.Handle("/", fs)
	log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%d", host, port), nil))
}

func assertPublicDirFiles() {
	appJsFile := config.PUBLIC_DIR + "/app.js"
	if _, err := os.Stat(appJsFile); err != nil {
		panic(appJsFile + " doesn't exists. You need to dump JS files using 'make buildjs' command.")
	}
}
{'fraction_non_alphanumeric': 0.15389369592089, 'fraction_numerical': 0.0, 'mean_word_length': 5.450199203187251, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2421966', 'n_tokens_mistral': 609, 'n_tokens_neox': 590, 'n_words': 103}