- Update API routes for consistency and versioning. any communication with donetick will go through /api/v1. for external will user prefix /eapi/v1

- Update Readme and add Discord and Reddit
- changing the api url should fix #71
This commit is contained in:
Mo Tarbin 2025-01-02 23:21:17 -05:00
commit 310a717294
8 changed files with 26 additions and 10 deletions

View file

@ -46,7 +46,7 @@ func (h *API) GetAllChores(c *gin.Context) {
func APIs(cfg *config.Config, api *API, r *gin.Engine, auth *jwt.GinJWTMiddleware, limiter *limiter.Limiter) {
thingsAPI := r.Group("api/v1/chore")
thingsAPI := r.Group("eapi/v1/chore")
thingsAPI.Use(utils.TimeoutMiddleware(cfg.Server.WriteTimeout), utils.RateLimitMiddleware(limiter))
{

View file

@ -1417,7 +1417,7 @@ func indexOf(arr []chModel.ChoreAssignees, value int) int {
func Routes(router *gin.Engine, h *Handler, auth *jwt.GinJWTMiddleware) {
choresRoutes := router.Group("chores")
choresRoutes := router.Group("api/v1/chores")
choresRoutes.Use(auth.MiddlewareFunc())
{
choresRoutes.GET("/", h.getChores)

View file

@ -427,7 +427,7 @@ func (h *Handler) AcceptJoinRequest(c *gin.Context) {
func Routes(router *gin.Engine, h *Handler, auth *jwt.GinJWTMiddleware) {
log.Println("Registering routes")
circleRoutes := router.Group("circles")
circleRoutes := router.Group("api/v1/circles")
circleRoutes.Use(auth.MiddlewareFunc())
{
circleRoutes.GET("/members", h.GetCircleMembers)

View file

@ -164,7 +164,7 @@ func (h *Handler) deleteLabel(c *gin.Context) {
func Routes(r *gin.Engine, h *Handler, auth *jwt.GinJWTMiddleware) {
labelRoutes := r.Group("labels")
labelRoutes := r.Group("api/v1/labels")
labelRoutes.Use(auth.MiddlewareFunc())
{
labelRoutes.GET("", h.getLabels)

View file

@ -279,7 +279,7 @@ func (h *Handler) DeleteThing(c *gin.Context) {
}
func Routes(r *gin.Engine, h *Handler, auth *jwt.GinJWTMiddleware) {
thingRoutes := r.Group("things")
thingRoutes := r.Group("api/v1/things")
thingRoutes.Use(auth.MiddlewareFunc())
{
thingRoutes.POST("", h.CreateThing)

View file

@ -164,7 +164,7 @@ func validateUserAndThing(c *gin.Context, h *Webhook) (*tModel.Thing, bool) {
func Webhooks(cfg *config.Config, w *Webhook, r *gin.Engine, auth *jwt.GinJWTMiddleware) {
thingsAPI := r.Group("webhooks/things")
thingsAPI := r.Group("eapi/v1/things")
thingsAPI.Use(utils.TimeoutMiddleware(cfg.Server.WriteTimeout))
{

View file

@ -586,7 +586,7 @@ func (h *Handler) updateUserPasswordLoggedInOnly(c *gin.Context) {
func Routes(router *gin.Engine, h *Handler, auth *jwt.GinJWTMiddleware, limiter *limiter.Limiter) {
userRoutes := router.Group("users")
userRoutes := router.Group("api/v1/users")
userRoutes.Use(auth.MiddlewareFunc(), utils.RateLimitMiddleware(limiter))
{
userRoutes.GET("/", h.GetAllUsers())
@ -600,7 +600,7 @@ func Routes(router *gin.Engine, h *Handler, auth *jwt.GinJWTMiddleware, limiter
}
authRoutes := router.Group("auth")
authRoutes := router.Group("api/v1/auth")
authRoutes.Use(utils.RateLimitMiddleware(limiter))
{
authRoutes.POST("/:provider/callback", h.thirdPartyAuthCallback)