2022-04-02 12:05:32 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/go-chi/chi/v5/middleware"
|
|
|
|
|
|
|
|
"github.com/jtom38/newsbot/collector/routes"
|
2022-05-15 21:48:23 -07:00
|
|
|
"github.com/jtom38/newsbot/collector/services/cron"
|
2022-04-02 12:05:32 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2022-04-17 07:25:49 -07:00
|
|
|
//dc := database.NewDatabaseClient()
|
|
|
|
//err := dc.Diagnosis.Ping()
|
|
|
|
//if err != nil { log.Fatalln(err) }
|
2022-05-15 21:48:23 -07:00
|
|
|
cron.EnableScheduler()
|
2022-04-02 12:05:32 -07:00
|
|
|
|
|
|
|
app := chi.NewRouter()
|
|
|
|
app.Use(middleware.Logger)
|
|
|
|
app.Use(middleware.Recoverer)
|
|
|
|
|
|
|
|
//app.Mount("/swagger", httpSwagger.WrapHandler)
|
|
|
|
app.Mount("/api", routes.RootRoutes())
|
|
|
|
|
|
|
|
log.Println("API is online and waiting for requests.")
|
|
|
|
log.Println("API: http://localhost:8081/api")
|
|
|
|
//log.Println("Swagger: http://localhost:8080/swagger/index.html")
|
2022-04-29 13:02:25 -07:00
|
|
|
err := http.ListenAndServe(":8081", app)
|
2022-04-02 12:05:32 -07:00
|
|
|
if err != nil { log.Fatalln(err) }
|
|
|
|
}
|