renommage lassistanoque

This commit is contained in:
2026-08-07 00:03:15 +02:00
commit 5810c4c94f
73 changed files with 2601 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package cmd
import (
"github.com/spf13/cobra"
"trankilou.fr/lassistanoque/backend/internal/adapter/database"
)
func init() {
rootCmd.AddCommand(
newLigrateCmd(),
)
}
// newVersionCmd creates the version command for displaying version information.
func newLigrateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "migrate",
Short: "migrate database",
Run: func(cmd *cobra.Command, args []string) {
db, err := database.GetDatabase()
if err != nil {
panic(err)
}
defer db.Close()
err = db.Migrate()
if err != nil {
panic(err)
}
},
}
return cmd
}
+24
View File
@@ -0,0 +1,24 @@
package cmd
import (
"os"
"github.com/spf13/cobra"
)
// var (
// cfgFile string
// )
// rootCmd is the root command for the agence CLI.
var rootCmd = &cobra.Command{
Use: "lassistanoque",
Short: "lassistanoque: autonome agent",
}
// Execute is the main entry point for the CLI application.
func Execute() {
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}
+78
View File
@@ -0,0 +1,78 @@
package cmd
import (
"log/slog"
"time"
"github.com/spf13/cobra"
"trankilou.fr/lassistanoque/backend/internal/adapter/auth/password"
"trankilou.fr/lassistanoque/backend/internal/adapter/database"
"trankilou.fr/lassistanoque/backend/internal/adapter/security"
"trankilou.fr/lassistanoque/backend/internal/http"
"trankilou.fr/lassistanoque/backend/internal/service/auth"
"trankilou.fr/lassistanoque/backend/internal/service/user"
)
func init() {
rootCmd.AddCommand(
newServeCmd(),
)
}
func newServeCmd() *cobra.Command {
var short bool
cmd := &cobra.Command{
Use: "serve",
Short: "Run server",
Run: func(cmd *cobra.Command, args []string) {
runServe()
},
}
cmd.Flags().BoolVarP(&short, "short", "s", false, "show only version number")
return cmd
}
func runServe() {
// database
db, err := database.GetDatabase()
if err != nil {
panic(err)
}
defer db.Close()
err = db.Migrate()
if err != nil {
panic(err)
}
settings, err := db.SettingsReporitory().GetSettings()
if err != nil {
panic(err)
}
// Adapters
tokenManager := security.NewJwtTokenManager(12*time.Hour, 7*24*time.Hour, "lassistanoque")
pwdAuth := password.NewPasswordAuthenticator(tokenManager, db.UserReporitory())
// services
authService := auth.NewService(
db.SettingsReporitory(),
db.UserReporitory(),
map[string]auth.Authenticator{
"password": pwdAuth,
},
)
userService := user.NewService(db.UserReporitory())
// http server
router := http.NewRouter(http.Dependencies{
Settings: settings,
AuthService: authService,
UserService: userService,
TokenManager: tokenManager,
})
if err := router.Start(); err != nil {
slog.Error("failed to start server", "error", err)
}
}
+39
View File
@@ -0,0 +1,39 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(
newVersionCmd(),
)
}
// Version, CommitSHA, and BuildDate are set at build time using ldflags.
var (
Version = "dev"
CommitSHA = "none"
BuildDate = "unknown"
)
// newVersionCmd creates the version command for displaying version information.
func newVersionCmd() *cobra.Command {
var short bool
cmd := &cobra.Command{
Use: "version",
Short: "Show version",
Long: "Display version information for the agence application.",
Run: func(cmd *cobra.Command, args []string) {
if short {
fmt.Println(Version)
return
}
fmt.Printf("lassistanoque %s (commit: %s, built: %s)\n", Version, CommitSHA, BuildDate)
},
}
cmd.Flags().BoolVarP(&short, "short", "s", false, "show only version number")
return cmd
}