diff options
| author | Bobby <[email protected]> | 2025-09-24 18:44:44 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2025-09-24 18:44:44 +0530 |
| commit | a42336fec9c5ed6cd47e7dc0437c931ae06cfc0a (patch) | |
| tree | 79678ec3cb8913dc55513866e1f38c3eafd41c1a /main.go | |
| parent | effe1ba118911ea3f68c2c7256336ece4277dec2 (diff) | |
| download | thunderbird-ai-compose-server-a42336fec9c5ed6cd47e7dc0437c931ae06cfc0a.tar.xz thunderbird-ai-compose-server-a42336fec9c5ed6cd47e7dc0437c931ae06cfc0a.zip | |
created confid and add env loader
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 41 |
1 files changed, 2 insertions, 39 deletions
@@ -2,56 +2,19 @@ package main import ( "log" - "time" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" ) -type Identity struct { - ID string `json:"id,omitempty"` - Email string `json:"email,omitempty"` - Name string `json:"name,omitempty"` -} - -type ComposeDetails struct { - Subject string `json:"subject,omitempty"` - To []string `json:"to,omitempty"` - Cc []string `json:"cc,omitempty"` - Bcc []string `json:"bcc,omitempty"` - BodyPlain string `json:"bodyPlain,omitempty"` - BodyHTML string `json:"bodyHTML,omitempty"` - IdentityID string `json:"identityId,omitempty"` - IsHTML bool `json:"isHTML"` -} - -type ComposeContext struct { - Account Identity `json:"account"` - Compose ComposeDetails `json:"compose"` -} - -type Payload struct { - Prompt string `json:"prompt"` - Context ComposeContext `json:"context"` -} - func main() { app := fiber.New() - app.Use(cors.New(cors.Config{ - AllowOrigins: "*", - AllowMethods: "GET, HEAD, PUT, PATCH, POST, DELETE, OPTIONS", - AllowHeaders: "Origin, Content-Type, Accept, Authorization, X-Requested-With, X-API-Key, X-CSRF-Token", - ExposeHeaders: "Content-Length, Content-Type, Content-Disposition, X-Pagination, X-Total-Count", - MaxAge: 86400, - })) + app.Use(cors.New()) app.Post("/generate", func(c *fiber.Ctx) error { var payload Payload - // DEBUG: Simulate processing delay - time.Sleep(5 * time.Second) - if err := c.BodyParser(&payload); err != nil { return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "error": "Invalid request payload", @@ -64,6 +27,6 @@ func main() { }) }) - log.Println("Server is running on http://localhost:3000") + log.Printf("Starting server on port %d\n", Config.Port) log.Fatal(app.Listen(":3000")) } |
