-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
96 lines (75 loc) · 2.23 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package main
import (
"go-fiber-auth/controllers"
"go-fiber-auth/routes"
"log"
"net/http"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/joho/godotenv"
"gopkg.in/asaskevich/govalidator.v9"
)
func init() {
err := godotenv.Load()
if err != nil {
log.Panicln(err)
}
govalidator.SetFieldsRequiredByDefault(true)
}
func main() {
app := fiber.New(fiber.Config{
BodyLimit: 10 * 1024 * 1024,
})
app.Use(logger.New())
app.Static("/storage", "./uploads")
app.Use(cors.New(cors.Config{
AllowMethods: "POST, GET, OPTIONS, PUT, DELETE",
AllowOrigins: "*",
AllowHeaders: "Origin, Content-Type, Accept, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization",
AllowCredentials: true,
ExposeHeaders: "true",
}))
app.Get("/", func(ctx *fiber.Ctx) error {
return ctx.Status(http.StatusOK).JSON(fiber.Map{"message": "helll world"})
})
routes.Install(app)
defer controllers.Close()
// controllers.Save(&newUser)
// res, err := controllers.GetByEmail("akashs2000@gmail.com")
// utix.CheckErorr(err)
// fmt.Println(res["password"])
// res, _ := controllers.GetByKey("password", "bcrytitpls")
// if erro != nil {
// fmt.Println(erro)
// }
// fmt.Println(res.Email)
// alldocs := controllers.GetAll()
// // fmt.Println(alldocs[0])
// for i := 0; i < len(alldocs); i++ {
// fmt.Println(alldocs[i])
// }
// res, err := controllers.Delete("6136273639da1dca9045e348")
// if err != nil {
// panic(err)
// }
// fmt.Println(res.DeletedCount)
//var newuser models.User
//controllers.Update("email", "headflake@gmail.com", "username", "funcissogoood")
// has, erer := security.EncryptPassword("sass")
// utix.CheckErorr(erer)
// fmt.Println(has, "this is the hash")
// serror := security.VerifyPassword(has, "sass")
// if serror == nil {
// fmt.Println("PASSWORD CORRECT")
// }
// utix.CheckErorr(serror)
// token, err := security.NewToken("6136e3cfc24585d52e907467")
// utix.CheckErorr(err)
// fmt.Println("_________ token")
// fmt.Println(token)
// newUser, err := controllers.GetByKey("email", "akashd2000@gmail.com")
// fmt.Println(newUser)
// utix.CheckErorr(err)
log.Fatal(app.Listen(":8080"))
}