Git Product home page Git Product logo

go-jwt-auth's Introduction

Metrics

go-jwt-auth's People

Contributors

solrac97gr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-jwt-auth's Issues

Failed to fetch from swagger

Description of the bug

When testing the API from swagger, I always get "Failed to fetch" error.
Doing it on CLI is fine though.

Steps To Reproduce

  1. Go to http://my.server.name:5050/docs/
  2. Test the "Register" API from swagger

Additional Information

image

The reason that I'm reporting here is that, I'm also trying another template -- https://github.com/create-go-app/fiber-go-template/, which seems to be doing no difference than what you're doing regarding CORS:

package middleware

import (
        "github.com/gofiber/fiber/v2"
        "github.com/gofiber/fiber/v2/middleware/cors"
        "github.com/gofiber/fiber/v2/middleware/logger"
)

// FiberMiddleware provide Fiber's built-in middlewares.
// See: https://docs.gofiber.io/api/middleware
func FiberMiddleware(a *fiber.App) {
        a.Use(
                // Add CORS to each route.
                cors.New(),
                // Add simple logger.
                logger.New(),
        )
}

Yet, its CORS/swagger is working just fine:

image

What could possibly cause the difference?
How can I make the swagger work out of the box please?

Where to define the interfaces please?

go-jwt-auth/README.md

Lines 60 to 73 in f52fb4a

6. Define your interfaces inside the `repository.go`,`handlers.go` and `application.go` file.
```go
package ports
import "github.com/your_user/your_project/internal/post/domain/model"
type PostRepository interface {
Create(post *model.Post) error
FindAll() ([]*model.Post, error)
FindByID(id string) (*model.Post, error)
Update(post *model.Post) error
Delete(id string) error
}
```

Define your interfaces inside the repository.go,handlers.go and application.go file.

Hi, I don't quite get where exactly the above interfaces code should be put -- it should be put in only one of the above three files, not all of them right? If so, which one then?

[FEAT]: to be able to use one or other DB

Description

Hi,
I am learning Golang, and I am reading through your repo. It is really helpful to read the code for learning, however, I see something that would make it difficult to change later on. letΒ΄s pretend I want to start a project using Postgres, and then I see this file:

`package repositories

import (
"context"
"github.com/solrac97gr/go-jwt-auth/internal/user/domain/models"
)

func (repo *UserMongoDB) Save(user *models.User) error {
_, err := repo.collection.InsertOne(context.Background(), user)
if err != nil {
repo.logger.Error("Error saving user", err)
return err
}
return nil
}`

I am not sure how would I switch from mongoDB to Postgres easily.

thanks for your time.

Additional Information

No response

[FEAT]: Restructure as per the Repository pattern

Description

As per The Repository Pattern

Keeping logic of your application along with your database logic makes your application much more complex, hard to test, and maintain.

There is already a proven and simple pattern that solves these issues. The pattern that allows you to separate your application logic from database logic. It allows you to make your code simpler and easier to add new functionalities.

This is not just another article with random code snippets.
This post is part of a bigger series where we show how to build Go applications that are easy to develop, maintain, and fun to work with in the long term. We are doing it by sharing proven techniques based on many experiments we did with teams we lead and scientific research.

So it is better to move the database logic out of repositories layer into adapters, like in the trainer example.

Additional Information

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.