-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.go
31 lines (26 loc) · 927 Bytes
/
index.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
package main
import (
"fmt"
"net/http"
"os"
"github.com/BeatAllTech/ChitSlip/auth/src/db"
"github.com/BeatAllTech/ChitSlip/auth/src/routes"
"github.com/somtooo/Chit-Slip-Lib/commons/errors"
"github.com/somtooo/Chit-Slip-Lib/commons/middlewares/currentuser"
)
func main() {
if os.Getenv("JWT_KEY") == "" {
panic("JWT_KEY must be definied")
}
http.Handle("/api/users/currentuser", currentuser.CurrentUser(http.HandlerFunc(routes.HandleCurrentUser)))
http.HandleFunc("/api/users/signup", routes.HandleSignUp)
http.HandleFunc("/api/users/signout", routes.HandleSignOut)
http.HandleFunc("/api/users/signin", routes.HandleSignIn)
http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
var notFound errors.BadRequestError = "No link Found"
errors.HTTPError(res, notFound, http.StatusBadRequest)
})
db.ConnectDb()
fmt.Println("Listening on port 3000!")
http.ListenAndServe(":3000", nil)
}