2022-04-02 12:05:32 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-06-08 21:17:08 -07:00
|
|
|
"context"
|
2022-06-19 22:02:44 -07:00
|
|
|
"fmt"
|
2022-04-02 12:05:32 -07:00
|
|
|
"net/http"
|
2022-06-19 22:02:44 -07:00
|
|
|
|
|
|
|
_ "github.com/jtom38/newsbot/collector/docs"
|
2022-04-02 12:05:32 -07:00
|
|
|
"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
|
|
|
)
|
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
// @title NewsBot collector
|
|
|
|
// @version 0.1
|
|
|
|
// @BasePath /api
|
2022-07-13 21:31:53 -07:00
|
|
|
|
2022-04-02 12:05:32 -07:00
|
|
|
func main() {
|
2022-06-08 21:17:08 -07:00
|
|
|
ctx := context.Background()
|
2022-06-19 22:02:44 -07:00
|
|
|
c := cron.New(ctx)
|
|
|
|
c.Start()
|
2022-06-08 21:17:08 -07:00
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
server := routes.NewServer(ctx)
|
2022-04-02 12:05:32 -07:00
|
|
|
|
2022-06-19 22:02:44 -07:00
|
|
|
fmt.Println("API is online and waiting for requests.")
|
|
|
|
fmt.Println("API: http://localhost:8081/api")
|
|
|
|
fmt.Println("Swagger: http://localhost:8081/swagger/index.html")
|
|
|
|
err := http.ListenAndServe(":8081", server.Router)
|
2022-07-13 21:31:53 -07:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-04-02 12:05:32 -07:00
|
|
|
}
|