features/added-user-tables #3
@ -6,9 +6,12 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
_ "github.com/glebarez/go-sqlite"
|
||||
"github.com/pressly/goose/v3"
|
||||
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/docs"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/database"
|
||||
v1 "git.jamestombleson.com/jtom38/newsbot-api/internal/handler/v1"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/handler/v1"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/services"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/services/cron"
|
||||
)
|
||||
@ -17,12 +20,24 @@ import (
|
||||
// @version 0.1
|
||||
// @BasePath /api
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
|
||||
cfg := services.NewConfig()
|
||||
configs := services.GetEnvConfig()
|
||||
address := cfg.GetConfig(services.ServerAddress)
|
||||
docs.SwaggerInfo.Host = fmt.Sprintf("%v:8081", address)
|
||||
|
||||
ctx := context.Background()
|
||||
db, err := sql.Open("postgres", cfg.GetConfig(services.Sql_Connection_String))
|
||||
db, err := sql.Open("sqlite", "newsbot.db")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = goose.SetDialect("sqlite3")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = goose.Up(db, "../internal/database/migrations")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -32,11 +47,11 @@ func main() {
|
||||
c := cron.NewScheduler(ctx)
|
||||
c.Start()
|
||||
|
||||
server := v1.NewServer(ctx, queries)
|
||||
server := v1.NewServer(ctx, queries, configs, db)
|
||||
|
||||
fmt.Println("API is online and waiting for requests.")
|
||||
fmt.Printf("API: http://%v:8081/api\r\n", address)
|
||||
fmt.Printf("Swagger: http://%v:8081/swagger/index.html\r\n", address)
|
||||
fmt.Printf("API: http://%v:8081/api\r\n", configs.ServerAddress)
|
||||
fmt.Printf("Swagger: http://%v:8081/swagger/index.html\r\n", configs.ServerAddress)
|
||||
|
||||
err = http.ListenAndServe(":8081", server.Router)
|
||||
if err != nil {
|
Loading…
Reference in New Issue
Block a user