Feat(ktm-booking): Initial commit
Some checks failed
ktm-booking-bot/ktm-booking-bot/pipeline/head Something is wrong with the build of this commit
Some checks failed
ktm-booking-bot/ktm-booking-bot/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
31
backend/internal/ktmtrainbot/main.go
Normal file
31
backend/internal/ktmtrainbot/main.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package ktmtrainbot
|
||||
|
||||
import (
|
||||
"git.samuelpua.com/telboon/ktm-train-bot/backend/internal/user"
|
||||
"github.com/go-chi/chi"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Env struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
func KTMTrainBotRoutes(db *gorm.DB) chi.Router {
|
||||
var env Env
|
||||
env.DB = db
|
||||
|
||||
// Start running job
|
||||
go env.BackgroundJobRunner()
|
||||
|
||||
userEnv := user.NewUserEnv(db)
|
||||
|
||||
r := chi.NewRouter()
|
||||
checkLoggedInUserGroup := r.Group(nil)
|
||||
r.Get("/current-time", env.getCurrentTime)
|
||||
checkLoggedInUserGroup.Use(userEnv.CheckUserMiddleware)
|
||||
checkLoggedInUserGroup.Get("/booking", env.getBookingRoute)
|
||||
checkLoggedInUserGroup.Post("/booking", env.createBookingRoute)
|
||||
checkLoggedInUserGroup.Delete("/booking/{bookingID}", env.deleteBookingRoute)
|
||||
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user