2024-10-19 14:36:33 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2024-11-13 14:26:54 +00:00
|
|
|
pkg "git.solsynth.dev/hypernet/nexus/pkg/internal"
|
2024-10-22 15:23:58 +00:00
|
|
|
"git.solsynth.dev/hypernet/nexus/pkg/internal/auth"
|
2024-10-20 16:05:40 +00:00
|
|
|
"git.solsynth.dev/hypernet/nexus/pkg/internal/http/ws"
|
2024-10-19 14:36:33 +00:00
|
|
|
"github.com/gofiber/contrib/websocket"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func MapAPIs(app *fiber.App) {
|
2024-10-20 07:22:19 +00:00
|
|
|
// Some built-in public-accessible APIs
|
2024-10-19 14:36:33 +00:00
|
|
|
wellKnown := app.Group("/.well-known").Name("Well Known")
|
|
|
|
{
|
|
|
|
wellKnown.Get("/", func(c *fiber.Ctx) error {
|
2024-11-13 14:26:54 +00:00
|
|
|
return c.JSON(fiber.Map{
|
|
|
|
"api_level": pkg.ApiLevel,
|
|
|
|
"version": pkg.AppVersion,
|
|
|
|
"status": true,
|
|
|
|
})
|
2024-10-19 14:36:33 +00:00
|
|
|
})
|
|
|
|
wellKnown.Get("/check-ip", getClientIP)
|
|
|
|
wellKnown.Get("/directory/services", listExistsService)
|
|
|
|
}
|
|
|
|
|
2024-10-20 07:22:19 +00:00
|
|
|
// Common websocket gateway
|
2024-10-26 16:36:06 +00:00
|
|
|
app.Get("/ws", auth.ValidatorMiddleware, websocket.New(ws.Listen))
|
2024-10-19 14:36:33 +00:00
|
|
|
|
2024-10-20 16:05:40 +00:00
|
|
|
app.All("/inv/:command", invokeCommand)
|
|
|
|
app.All("/cgi/:service/*", forwardService)
|
2024-10-19 14:36:33 +00:00
|
|
|
}
|