Protected routes

This commit is contained in:
Nedim
2023-11-10 17:32:17 +01:00
parent 367b5d51f2
commit 99b9df5066
14 changed files with 172 additions and 100 deletions

View File

@@ -2,6 +2,7 @@ package routes
import (
"gitlab.com/pactual1/backend/controllers"
"gitlab.com/pactual1/backend/middlewares"
"github.com/gin-gonic/gin"
)
@@ -12,42 +13,42 @@ func RegisterPublicRoutes(r *gin.Engine) {
r.GET("/health", controllers.HealthCheck)
// Map dashboard
r.GET("/dashboard/map/contract/devices", controllers.GetDevicesByContract)
r.GET("/dashboard/map/contracts", controllers.GetLatestContracts)
r.GET("/dashboard/map/device_data", controllers.GetDeviceData)
r.GET("/dashboard/map/contract/devices", middlewares.AuthMiddleware(), controllers.GetDevicesByContract)
r.GET("/dashboard/map/contracts", middlewares.AuthMiddleware(), controllers.GetLatestContracts)
r.GET("/dashboard/map/device_data", middlewares.AuthMiddleware(), controllers.GetDeviceData)
// Invoices
r.GET("/invoices", controllers.GetInvoices)
r.GET("/invoices/:id", controllers.GetInvoiceByID)
r.GET("/invoices", middlewares.AuthMiddleware(), controllers.GetInvoices)
r.GET("/invoices/:id", middlewares.AuthMiddleware(), controllers.GetInvoiceByID)
r.POST("/device_data/save", controllers.SaveDeviceInfo)
r.GET("/buyers", controllers.ListCompanies)
r.GET("/products", controllers.ListProductTemplates)
r.GET("/templates", controllers.ListTextTemplates)
r.POST("/templates/save", controllers.CreateTextTemplate)
r.GET("/products/:template_id", controllers.GetProductTemplate)
r.GET("/buyers", middlewares.AuthMiddleware(), controllers.ListCompanies)
r.GET("/products", middlewares.AuthMiddleware(), middlewares.AuthMiddleware(), controllers.ListProductTemplates)
r.GET("/templates", middlewares.AuthMiddleware(), controllers.ListTextTemplates)
r.POST("/templates/save", middlewares.AuthMiddleware(), controllers.CreateTextTemplate)
r.GET("/products/:template_id", middlewares.AuthMiddleware(), controllers.GetProductTemplate)
// Contracts
r.GET("/contracts/statuses", controllers.GetContractStatuses)
r.GET("/contracts", controllers.GetBuyerContracts)
r.POST("/contracts/create", controllers.CreateContract)
r.GET("/contracts/statuses", middlewares.AuthMiddleware(), controllers.GetContractStatuses)
r.GET("/contracts", middlewares.AuthMiddleware(), controllers.GetBuyerContracts)
r.POST("/contracts/create", middlewares.AuthMiddleware(), controllers.CreateContract)
r.GET("/contracts/:contract_id", controllers.GetContractByID)
r.PATCH("/contracts/:contract_id", controllers.UpdateContract)
r.GET("/contracts/:contract_id", middlewares.AuthMiddleware(), controllers.GetContractByID)
r.PATCH("/contracts/:contract_id", middlewares.AuthMiddleware(), controllers.UpdateContract)
// Locations
r.GET("/locations", controllers.SearchPlace)
r.GET("/locations", middlewares.AuthMiddleware(), controllers.SearchPlace)
// Notifications
r.GET("/notifications", controllers.GetNotifications)
r.GET("/notifications", middlewares.AuthMiddleware(), controllers.GetNotifications)
// Stats
r.GET("/stats/measurements", controllers.GetCompanyRelatedDeviceInfoCount)
r.GET("/stats/devices", controllers.GetCompanyRelatedDeviceInfoCountWithTempRange)
r.GET("/stats/contracts", controllers.GetContractCountByStatus)
r.GET("/stats/contracts/total", controllers.GetTotalContractCount)
r.GET("/stats/invoices", controllers.GetInvoiceCountByStatus)
r.GET("/stats/milestones", controllers.GetContractsMatchingDeviceLocation)
r.GET("/stats/measurements", middlewares.AuthMiddleware(), controllers.GetCompanyRelatedDeviceInfoCount)
r.GET("/stats/devices", middlewares.AuthMiddleware(), controllers.GetCompanyRelatedDeviceInfoCountWithTempRange)
r.GET("/stats/contracts", middlewares.AuthMiddleware(), controllers.GetContractCountByStatus)
r.GET("/stats/contracts/total", middlewares.AuthMiddleware(), controllers.GetTotalContractCount)
r.GET("/stats/invoices", middlewares.AuthMiddleware(), controllers.GetInvoiceCountByStatus)
r.GET("/stats/milestones", middlewares.AuthMiddleware(), controllers.GetContractsMatchingDeviceLocation)
//Users
r.POST("/user/reset/password", controllers.ResetPassword)