feat: add basic app
This commit is contained in:
parent
d4c1af4831
commit
c94098afef
13 changed files with 1850 additions and 0 deletions
35
cmd/api/main.go
Normal file
35
cmd/api/main.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gitlab.mareshq.com/hq/backoffice/backoffice-api/internal/faker"
|
||||
"gitlab.mareshq.com/hq/backoffice/backoffice-api/internal/server"
|
||||
"gitlab.mareshq.com/hq/backoffice/backoffice-api/internal/training"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func main() {
|
||||
logger := log.New(os.Stdout, "backoffice-api: ", log.LstdFlags)
|
||||
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
|
||||
defer cancel()
|
||||
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
logger.Fatalf("error: %v\n", err)
|
||||
}
|
||||
|
||||
trainingRepo := training.NewInMemoryRepository()
|
||||
f := faker.NewFaker(trainingRepo)
|
||||
err = f.GenerateFakeData()
|
||||
if err != nil {
|
||||
logger.Fatalf("error: %v\n", err)
|
||||
}
|
||||
|
||||
s := server.NewServer(hostname, logger, trainingRepo)
|
||||
if err := s.Run(ctx); err != nil {
|
||||
logger.Fatalf("error: %v\n", err)
|
||||
}
|
||||
}
|
||||
Reference in a new issue