v1.go 736 B

12345678910111213141516171819202122232425262728293031
  1. package v1
  2. import (
  3. "github.com/labstack/echo/v4"
  4. "github.com/usememos/memos/server/profile"
  5. "github.com/usememos/memos/store"
  6. )
  7. type APIV1Service struct {
  8. Secret string
  9. Profile *profile.Profile
  10. Store *store.Store
  11. }
  12. func NewAPIV1Service(secret string, profile *profile.Profile, store *store.Store) *APIV1Service {
  13. return &APIV1Service{
  14. Secret: secret,
  15. Profile: profile,
  16. Store: store,
  17. }
  18. }
  19. func (s *APIV1Service) Register(rootGroup *echo.Group) {
  20. apiV1Group := rootGroup.Group("/api/v1")
  21. apiV1Group.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
  22. return JWTMiddleware(s, next, s.Secret)
  23. })
  24. s.registerTestRoutes(apiV1Group)
  25. s.registerAuthRoutes(apiV1Group)
  26. s.registerIdentityProviderRoutes(apiV1Group)
  27. }