SoXX
802764092e
As mentioned in Issue #11, the folder structure got an overall as some file names Co-authored-by: Fenpaws <soxx@fenpa.ws> Reviewed-on: anthrove/e621-to-graph#14 Reviewed-by: Lennard Brinkhaus <lennard.brinkhaus@noreply.localhost> Co-authored-by: SoXX <fenpaws@noreply.localhost> Co-committed-by: SoXX <fenpaws@noreply.localhost>
70 lines
1.6 KiB
Go
70 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"git.dragse.it/anthrove/e621-to-graph/internal/api"
|
|
"git.dragse.it/anthrove/e621-to-graph/internal/config"
|
|
"git.dragse.it/anthrove/e621-to-graph/internal/database/neo4j"
|
|
"git.dragse.it/anthrove/e621-to-graph/internal/e621"
|
|
"git.dragse.it/anthrove/e621-to-graph/pkg/logic"
|
|
log "github.com/sirupsen/logrus"
|
|
"net/http"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func init() {
|
|
// Log as JSON instead of the default ASCII formatter.
|
|
//log.SetFormatter(&log.JSONFormatter{})
|
|
|
|
// Output to stdout instead of the default stderr
|
|
// Can be any io.Writer, see below for File example
|
|
log.SetOutput(os.Stdout)
|
|
|
|
// Only log the warning severity or above.
|
|
log.SetLevel(log.DebugLevel)
|
|
|
|
// Logging Method Name
|
|
//log.SetReportCaller(true)
|
|
}
|
|
|
|
func main() {
|
|
|
|
var graphConnection logic.GraphConnection
|
|
ctx := context.Background()
|
|
|
|
// Loads Config
|
|
config, err := config.LoadConfig()
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
|
|
switch strings.ToLower(config.DBType) {
|
|
case "neo4j":
|
|
log.Println("Setup Neo4J Connection")
|
|
graphConnection = neo4j.NewNeo4JConnection()
|
|
err = graphConnection.Connect(ctx, config.DBEndpoint, config.DBUsername, config.DBPassword)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
log.Println("Connection successful")
|
|
default:
|
|
panic("No Database was selected!")
|
|
}
|
|
|
|
// Initialize the e621API
|
|
e621Client := e621.NewClient(config.E621APIKey, config.E621Username)
|
|
|
|
log.Printf("Im ready!")
|
|
|
|
// Register the ScapeUserFavourites with the "/user" route
|
|
http.HandleFunc("/user", api.ScapeUserFavourites(ctx, graphConnection, e621Client))
|
|
|
|
// Start the HTTP server
|
|
err = http.ListenAndServe(":8080", nil)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
}
|