Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.3 KiB

package main
import (
"flag"
"log"
"net/http"
"os"
"git.tovijaeschke.xyz/tovi/Envelope/Backend/Api"
"git.tovijaeschke.xyz/tovi/Envelope/Backend/Database"
"git.tovijaeschke.xyz/tovi/Envelope/Backend/Database/Seeder"
"git.tovijaeschke.xyz/tovi/Envelope/Backend/Service"
"github.com/gorilla/mux"
"github.com/joho/godotenv"
)
var (
seed bool
sendNotification bool
)
func init() {
var err error
err = godotenv.Load()
if err != nil {
panic(err)
}
Database.Init()
flag.BoolVar(&seed, "seed", false, "Seed database for development")
flag.BoolVar(&sendNotification, "test-notify", false, "Send test notification")
flag.Parse()
}
func main() {
var (
router *mux.Router
err error
)
if seed && os.Getenv("GO_ENV") != "production" {
Seeder.Seed()
return
}
if sendNotification && os.Getenv("GO_ENV") != "production" {
Service.SendNotification(
[]string{"eoGWtGAOR3OON6uQTVwjwM:APA91bH68gggBHj1jm68xMY10LQBWVO1r5x0JH4An7dpq4nJJ1GjQw8EJVoKpkz8BSXvxFxU2p5azeO4HE0yUqmfJlCGVBwrBvi4ZmgiIMkg6LajsZuPu96gPblKIjpVnxL99AvQYFib"},
"Test Message",
make(map[string]string),
)
return
}
router = mux.NewRouter()
Api.InitAPIEndpoints(router)
log.Println("Listening on port :8080")
err = http.ListenAndServe(":8080", router)
if err != nil {
panic(err)
}
}