diff options
| author | Bobby <[email protected]> | 2026-03-29 22:52:46 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-03-29 22:52:46 +0530 |
| commit | 9eb9b7f4bd552a641235764f66483e1f940fcfd9 (patch) | |
| tree | da520b923b5e6758d5457b6233dd6671fc640914 /nexus/router | |
| parent | 65a143a0871c35989b7c7ea6723d39a0585c089e (diff) | |
| download | echoes-of-vaelun-main.tar.xz echoes-of-vaelun-main.zip | |
Diffstat (limited to 'nexus/router')
| -rw-r--r-- | nexus/router/api.go | 29 | ||||
| -rw-r--r-- | nexus/router/router.go | 21 | ||||
| -rw-r--r-- | nexus/router/web.go | 25 |
3 files changed, 75 insertions, 0 deletions
diff --git a/nexus/router/api.go b/nexus/router/api.go new file mode 100644 index 0000000..6f8314e --- /dev/null +++ b/nexus/router/api.go @@ -0,0 +1,29 @@ +package router
+
+import (
+ "nexus/api/account"
+ "nexus/api/auth"
+ "nexus/api/characters"
+ "nexus/api/realms"
+ nexusAuth "nexus/utils/auth"
+ "nexus/utils/urls"
+)
+
+func init() {
+ urls.SetNamespace("api")
+
+ urls.Path(urls.Post, "/auth/register", auth.Register, "auth.register")
+ urls.Path(urls.Post, "/auth/login", auth.Login, "auth.login")
+ urls.Path(urls.Post, "/auth/refresh", auth.Refresh, "auth.refresh")
+ urls.Path(urls.Post, "/auth/logout", nexusAuth.APIAuth(auth.Logout), "auth.logout")
+
+ urls.Path(urls.Get, "/account", nexusAuth.APIAuth(account.Show), "account.show")
+ urls.Path(urls.Delete, "/account", nexusAuth.APIAuth(account.Delete), "account.delete")
+
+ urls.Path(urls.Get, "/characters", nexusAuth.APIAuth(characters.Index), "characters.index")
+ urls.Path(urls.Get, "/characters/:id", nexusAuth.APIAuth(characters.Show), "characters.show")
+ urls.Path(urls.Post, "/characters", nexusAuth.APIAuth(characters.Create), "characters.create")
+ urls.Path(urls.Delete, "/characters/:id", nexusAuth.APIAuth(characters.Delete), "characters.delete")
+
+ urls.Path(urls.Get, "/realms", nexusAuth.APIAuth(realms.Index), "realms.index")
+}
diff --git a/nexus/router/router.go b/nexus/router/router.go new file mode 100644 index 0000000..4f66ff6 --- /dev/null +++ b/nexus/router/router.go @@ -0,0 +1,21 @@ +package router
+
+import (
+ "nexus/utils/shortcuts"
+ "nexus/utils/urls"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+func Initialize(application *fiber.App) {
+ application.Static("/static", "./static")
+ urls.Attach(application)
+}
+
+func ErrorHandler(context *fiber.Ctx, err error) error {
+ fiberErr, ok := err.(*fiber.Error)
+ if !ok {
+ fiberErr = fiber.NewError(fiber.StatusInternalServerError, err.Error())
+ }
+ return shortcuts.RouteError(context, fiberErr)
+}
diff --git a/nexus/router/web.go b/nexus/router/web.go new file mode 100644 index 0000000..640a0bd --- /dev/null +++ b/nexus/router/web.go @@ -0,0 +1,25 @@ +package router
+
+import (
+ controller "nexus/controllers/auth"
+ accountPage "nexus/pages/account"
+ authPage "nexus/pages/auth"
+ characterPage "nexus/pages/characters"
+ "nexus/utils/auth"
+ "nexus/utils/urls"
+)
+
+func init() {
+ urls.SetNamespace("")
+
+ urls.Path(urls.Get, "/login", authPage.Login, "login")
+ urls.Path(urls.Post, "/login", controller.Login, "login.submit")
+ urls.Path(urls.Get, "/register", authPage.Register, "register")
+ urls.Path(urls.Post, "/register", controller.Register, "register.submit")
+ urls.Path(urls.Get, "/logout", controller.Logout, "logout")
+
+ urls.Path(urls.Get, "/account", auth.WebAuth(accountPage.Index), "account")
+ urls.Path(urls.Get, "/characters", auth.WebAuth(characterPage.Index), "characters")
+ urls.Path(urls.Get, "/characters/create", auth.WebAuth(characterPage.Create), "characters.create")
+ urls.Path(urls.Post, "/characters/create", auth.WebAuth(characterPage.Store), "characters.store")
+}
|
