2026-01-13 20:26:15 +00:00
|
|
|
package sync
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/api"
|
|
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/auth"
|
2026-01-30 18:21:27 +00:00
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/html"
|
2026-01-13 20:26:15 +00:00
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Router() chi.Router {
|
|
|
|
|
r := chi.NewRouter()
|
|
|
|
|
// Root is a special endpoint that is neither authenticated nor unauthenticated
|
|
|
|
|
r.Get("/", getRoot)
|
|
|
|
|
|
|
|
|
|
// Unauthenticated endpoints
|
|
|
|
|
r.Get("/arcgis/oauth/begin", getArcgisOauthBegin)
|
|
|
|
|
r.Get("/arcgis/oauth/callback", getArcgisOauthCallback)
|
|
|
|
|
r.Get("/district", getDistrict)
|
|
|
|
|
|
2026-02-10 16:24:37 +00:00
|
|
|
// Mock endpoints
|
2026-02-16 19:52:20 +00:00
|
|
|
r.Get("/mock", renderMockList)
|
|
|
|
|
addMock(r, "/mock/admin", "sync/mock/admin.html")
|
|
|
|
|
addMock(r, "/mock/admin", "sync/mock/admin.html")
|
|
|
|
|
addMock(r, "/mock/dispatch", "sync/mock/dispatch.html")
|
|
|
|
|
addMock(r, "/mock/dispatch-results", "sync/mock/dispatch-results.html")
|
|
|
|
|
addMock(r, "/mock/report", "sync/mock/report.html")
|
|
|
|
|
addMock(r, "/mock/report/{code}", "sync/mock/report-detail.html")
|
|
|
|
|
addMock(r, "/mock/report/{code}/confirm", "sync/mock/report-confirmation.html")
|
|
|
|
|
addMock(r, "/mock/report/{code}/contribute", "sync/mock/report-contribute.html")
|
|
|
|
|
addMock(r, "/mock/report/{code}/evidence", "sync/mock/report-evidence.html")
|
|
|
|
|
addMock(r, "/mock/report/{code}/schedule", "sync/mock/report-schedule.html")
|
|
|
|
|
addMock(r, "/mock/report/{code}/update", "sync/mock/report-update.html")
|
|
|
|
|
addMock(r, "/mock/service-request/{code}", "sync/mock/service-request-detail.html")
|
|
|
|
|
addMock(r, "/mock/setting", "sync/mock/setting.html")
|
|
|
|
|
addMock(r, "/mock/setting/pesticide", "sync/mock/setting-pesticide.html")
|
|
|
|
|
addMock(r, "/mock/setting/pesticide/add", "sync/mock/setting-pesticide-add.html")
|
|
|
|
|
addMock(r, "/mock/setting/user", "sync/mock/setting-user.html")
|
|
|
|
|
addMock(r, "/mock/setting/user/add", "sync/mock/setting-user-add.html")
|
2026-01-13 20:26:15 +00:00
|
|
|
|
2026-02-10 16:24:37 +00:00
|
|
|
// Utility endpoints
|
2026-01-13 20:26:15 +00:00
|
|
|
r.Get("/oauth/refresh", getOAuthRefresh)
|
2026-01-22 18:37:00 +00:00
|
|
|
r.Get("/privacy", getPrivacy)
|
2026-01-13 20:26:15 +00:00
|
|
|
r.Get("/qr-code/report/{code}", getQRCodeReport)
|
|
|
|
|
r.Get("/signin", getSignin)
|
|
|
|
|
r.Post("/signin", postSignin)
|
|
|
|
|
r.Get("/signup", getSignup)
|
|
|
|
|
r.Post("/signup", postSignup)
|
2026-02-07 05:51:21 +00:00
|
|
|
r.Get("/template-test", getTemplateTest)
|
2026-01-13 20:26:15 +00:00
|
|
|
|
|
|
|
|
// Authenticated endpoints
|
|
|
|
|
r.Route("/api", api.AddRoutes)
|
|
|
|
|
r.Method("GET", "/cell/{cell}", auth.NewEnsureAuth(getCellDetails))
|
2026-01-28 17:15:42 +00:00
|
|
|
r.Method("GET", "/layout-test", auth.NewEnsureAuth(getLayoutTest))
|
2026-02-10 16:24:37 +00:00
|
|
|
r.Method("GET", "/notification", auth.NewEnsureAuth(getNotificationList))
|
2026-02-07 18:26:47 +00:00
|
|
|
r.Method("GET", "/pool", auth.NewEnsureAuth(getPoolList))
|
2026-02-07 20:02:39 +00:00
|
|
|
r.Method("GET", "/pool/upload", auth.NewEnsureAuth(getPoolUpload))
|
2026-02-08 03:47:48 +00:00
|
|
|
r.Method("GET", "/pool/upload/{id}", auth.NewEnsureAuth(getPoolUploadByID))
|
2026-02-08 00:59:41 +00:00
|
|
|
r.Method("POST", "/pool/upload", auth.NewEnsureAuth(postPoolUpload))
|
2026-02-16 19:14:58 +00:00
|
|
|
r.Method("GET", "/radar", auth.NewEnsureAuth(getRadar))
|
2026-02-13 21:14:46 +00:00
|
|
|
r.Method("GET", "/setting", auth.NewEnsureAuth(getSetting))
|
2026-02-16 15:03:26 +00:00
|
|
|
r.Method("GET", "/setting/district", auth.NewEnsureAuth(getSettingDistrict))
|
2026-02-13 21:14:46 +00:00
|
|
|
r.Method("GET", "/setting/integration", auth.NewEnsureAuth(getSettingIntegration))
|
2026-01-28 14:57:50 +00:00
|
|
|
r.Method("GET", "/signout", auth.NewEnsureAuth(getSignout))
|
2026-01-13 20:26:15 +00:00
|
|
|
r.Method("GET", "/source/{globalid}", auth.NewEnsureAuth(getSource))
|
2026-02-12 21:06:35 +00:00
|
|
|
r.Method("GET", "/stadia", auth.NewEnsureAuth(getStadia))
|
2026-01-15 22:12:35 +00:00
|
|
|
r.Method("GET", "/trap/{globalid}", auth.NewEnsureAuth(getTrap))
|
2026-01-28 14:58:13 +00:00
|
|
|
r.Method("GET", "/text/{destination}", auth.NewEnsureAuth(getTextMessages))
|
2026-01-13 20:26:15 +00:00
|
|
|
|
2026-01-30 18:21:27 +00:00
|
|
|
html.AddStaticRoute(r, "/static")
|
2026-01-13 20:26:15 +00:00
|
|
|
return r
|
|
|
|
|
}
|