diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..855582c0 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @rtrox \ No newline at end of file diff --git a/.github/goreleaser-dist.yaml b/.github/goreleaser-dist.yaml new file mode 100644 index 00000000..3c813e35 --- /dev/null +++ b/.github/goreleaser-dist.yaml @@ -0,0 +1,22 @@ +project_name: "lybbrio" +archives: + - id: main + wrap_in_directory: true + files: + - "README.md" +builds: + - main: ./cmd/lybbrio/main.go + binary: lybbrio + ldflags: + - -s -w -X main.version={{.Version}} -X main.revision={{.Commit}} -X main.buildTime={{.CommitTimestamp}} + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + mod_timestamp: '{{ .CommitTimestamp }}' +changelog: + use: github-native diff --git a/.github/lint/golangci.yaml b/.github/lint/golangci.yaml new file mode 100644 index 00000000..e68a6273 --- /dev/null +++ b/.github/lint/golangci.yaml @@ -0,0 +1,18 @@ +run: + timeout: 3m +linters: + # https://golangci-lint.run/usage/linters/#enabled-by-default + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - typecheck + - unused + # - wsl + # - dupl + # - errorlint + # - gofmt + # - goconst + # - revive diff --git a/.github/lint/precommit-ci.yaml b/.github/lint/precommit-ci.yaml new file mode 100644 index 00000000..ac293b05 --- /dev/null +++ b/.github/lint/precommit-ci.yaml @@ -0,0 +1,15 @@ +fail_fast: false +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v0.7.1 + hooks: + - id: check-merge-conflict + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/adrienverge/yamllint + rev: v1.28.0 + hooks: + - args: + - --config-file + - .github/lint/yamllint.yaml + id: yamllint diff --git a/.github/lint/yamllint.yaml b/.github/lint/yamllint.yaml new file mode 100644 index 00000000..533d4060 --- /dev/null +++ b/.github/lint/yamllint.yaml @@ -0,0 +1,14 @@ +extends: default +rules: + truthy: + allowed-values: ["true", "false", "on"] + comments: + min-spaces-from-content: 1 + line-length: disable + braces: + min-spaces-inside: 0 + max-spaces-inside: 1 + brackets: + min-spaces-inside: 0 + max-spaces-inside: 0 + indentation: enable diff --git a/.github/release.yaml b/.github/release.yaml new file mode 100644 index 00000000..6f070773 --- /dev/null +++ b/.github/release.yaml @@ -0,0 +1,19 @@ +# .github/release.yml +changelog: + exclude: + labels: + - ignore-for-release + authors: + - rtrox + categories: + - title: Breaking Changes 🛠 + labels: + - Semver-Major + - breaking-change + - title: Exciting New Features 🎉 + labels: + - Semver-Minor + - enhancement + - title: Other Changes + labels: + - "*" diff --git a/.github/renovate.json5 b/.github/renovate.json5 new file mode 100644 index 00000000..5a387f57 --- /dev/null +++ b/.github/renovate.json5 @@ -0,0 +1,58 @@ +{ + "extends": [ + "config:base" + ], + "enabled": true, + "timezone": "America/Los_Angeles", + "semanticCommits": "enabled", + "dependencyDashboard": true, + "dependencyDashboardTitle": "Renovate Dashboard 🤖", + "commitBody": "Signed-off-by: Russell Troxel ", + "suppressNotifications": ["prIgnoreNotification"], + "rebaseWhen": "conflicted", + "commitMessageTopic": "{{depName}}", + "commitMessageExtra": "to {{newVersion}}", + "commitMessageSuffix": "", + "git-submodules": { + "enabled": true + }, + "enabledManagers": [ + "dockerfile", + "gomod", + "git-submodules", + "pre-commit", + "github-actions" + ], + "assignees": ["rtrox"], + "assignAutomerge": true, + "labels": ["dependencies"], + "packageRules": [ + // add labels according to package and update types + { + "matchDepTypes": ["optionalDependencies"], + "addLabels": ["optional"] + }, + { + "matchUpdateTypes": ["major"], + "addLabels": ["dep/major"] + }, + { + "matchUpdateTypes": ["minor"], + "addLabels": ["dep/minor"], + }, + { + "matchUpdateTypes": ["patch"], + "addLabels": ["dep/patch"], + }, + { + "matchDatasources": ["docker"], + "addLabels": ["dep/docker"], + }, + { + "matchDatasources": ["git-refs"], + "addLabels": ["dep/git-ref"], + }, + // enable auto-merge + { "updateTypes": ["minor", "patch", "pin", "digest"], "automerge": true } + ] +} \ No newline at end of file diff --git a/.github/workflows/on-push.yaml b/.github/workflows/on-push.yaml new file mode 100644 index 00000000..4abb3c51 --- /dev/null +++ b/.github/workflows/on-push.yaml @@ -0,0 +1,10 @@ +name: Handle Push to Main Branch +# https://dev.to/koddr/github-action-for-release-your-go-projects-as-fast-and-easily-as-possible-20a2 +# https://github.com/orgs/community/discussions/25244 +on: + push: + branches: + - main +jobs: + tests: + uses: ./.github/workflows/tests.yaml diff --git a/.github/workflows/on-tag.yaml b/.github/workflows/on-tag.yaml new file mode 100644 index 00000000..a705018f --- /dev/null +++ b/.github/workflows/on-tag.yaml @@ -0,0 +1,53 @@ +name: Create Release +# https://dev.to/koddr/github-action-for-release-your-go-projects-as-fast-and-easily-as-possible-20a2 +# https://github.com/orgs/community/discussions/25244 +on: + push: + tags: + - "v*.*.*" +jobs: + tests: + uses: ./.github/workflows/tests.yaml + main-branch-check: + runs-on: ubuntu-latest + needs: tests + outputs: + on_main_branch: ${{ steps.register_tag.outputs.on_main_branch }} + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - uses: rickstaa/action-contains-tag@v1 + id: contains_tag + with: + reference: "main" + tag: "${{ github.ref }}" + - name: register output + id: register_tag + run: | + echo "retval: ${{ steps.contains_tag.outputs.retval }}" + echo "::set-output name=on_main_branch::${{ steps.contains_tag.outputs.retval }}" + release-tag: + runs-on: ubuntu-latest + needs: main-branch-check + if: ${{ needs.main-branch-check.outputs.on_main_branch }} == true + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.21.4 + id: go + - name: Create Release + uses: goreleaser/goreleaser-action@v4 + with: + version: latest + args: release --rm-dist --config .github/goreleaser-dist.yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 00000000..2fb1ddac --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,60 @@ +name: Run Tests +on: + workflow_call: +jobs: + pre-commit-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - uses: pre-commit/action@v3.0.0 + with: + extra_args: --config .github/lint/precommit-ci.yaml + golangci-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ">=1.21.4" + - name: Check Go Fmt + run: | + go version + go fmt ./... + git diff --exit-code + - name: Check Go mod + run: | + go version + go mod tidy + git diff --exit-code + - uses: golangci/golangci-lint-action@v2 + with: + version: v1.51.2 + args: --timeout 5m --config .github/lint/golangci.yaml + go-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ">=1.21.4" + - name: Tidy + run: | + go version + go mod tidy + git diff --exit-code + - name: Run Unit tests + run: | + go version + go test -v -race -covermode atomic -coverprofile=covprofile ./... + +# - name: Install goveralls +# run: | +# go version +# go install github.com/mattn/goveralls@latest + +# - name: Send coverage +# env: +# COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# run: goveralls -coverprofile=covprofile -service=github diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..b75dfc28 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +fail_fast: false +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v0.7.1 + hooks: + - id: check-merge-conflict + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/adrienverge/yamllint + rev: v1.28.0 + hooks: + - args: + - --config-file + - .github/lint/yamllint.yaml + id: yamllint + - repo: https://github.com/golangci/golangci-lint + rev: v1.51.2 + hooks: + - id: golangci-lint + args: + - --config + - .github/lint/golangci.yaml diff --git a/docs/swagger.json b/docs/swagger.json index 57eba74c..da18b963 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1137,4 +1137,4 @@ } } } -} \ No newline at end of file +} diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 96684a3b..e3ed0c89 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -290,15 +290,15 @@ paths: /authors: get: consumes: - - application/json + - application/json description: List Authors parameters: - - description: Pagination cursor - in: query - name: cursor - type: string + - description: Pagination cursor + in: query + name: cursor + type: string produces: - - application/json + - application/json responses: "200": description: OK @@ -326,20 +326,20 @@ paths: $ref: '#/definitions/internal_handlers.ErrResponse' summary: List Authors tags: - - authors + - authors /authors/{authorId}: get: consumes: - - application/json + - application/json description: Get an author by ID parameters: - - description: Author ID - in: path - name: authorId - required: true - type: integer + - description: Author ID + in: path + name: authorId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -367,20 +367,20 @@ paths: $ref: '#/definitions/internal_handlers.ErrResponse' summary: Get an author tags: - - authors + - authors /authors/{authorId}/books: get: consumes: - - application/json + - application/json description: Get an author's books by ID parameters: - - description: Author ID - in: path - name: authorId - required: true - type: integer + - description: Author ID + in: path + name: authorId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -408,20 +408,20 @@ paths: $ref: '#/definitions/internal_handlers.ErrResponse' summary: Get an author's books tags: - - authors + - authors /authors/{authorId}/series: get: consumes: - - application/json + - application/json description: Get an author's series by ID parameters: - - description: Author ID - in: path - name: authorId - required: true - type: integer + - description: Author ID + in: path + name: authorId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -449,19 +449,19 @@ paths: $ref: '#/definitions/internal_handlers.ErrResponse' summary: Get an author's series tags: - - authors + - authors /books: get: consumes: - - application/json + - application/json description: List Books parameters: - - description: Pagination cursor - in: query - name: cursor - type: string + - description: Pagination cursor + in: query + name: cursor + type: string produces: - - application/json + - application/json responses: "200": description: OK @@ -489,20 +489,20 @@ paths: $ref: '#/definitions/internal_handlers.ErrResponse' summary: List Books tags: - - books + - books /books/{bookId}: get: consumes: - - application/json + - application/json description: Get Book by ID parameters: - - description: Book ID - in: path - name: bookId - required: true - type: integer + - description: Book ID + in: path + name: bookId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -530,14 +530,14 @@ paths: $ref: '#/definitions/internal_handlers.ErrResponse' summary: Get Book by ID tags: - - books + - books /languages: get: consumes: - - application/json + - application/json description: Get all languages produces: - - application/json + - application/json responses: "200": description: OK @@ -545,20 +545,20 @@ paths: $ref: '#/definitions/internal_handlers.LanguageListResponse' summary: Get all languages tags: - - Languages + - Languages /languages/{languageId}: get: consumes: - - application/json + - application/json description: Get a language by ID parameters: - - description: Language ID - in: path - name: languageId - required: true - type: integer + - description: Language ID + in: path + name: languageId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -566,20 +566,20 @@ paths: $ref: '#/definitions/lybbrio_internal_calibre.Language' summary: Get a language tags: - - Languages + - Languages /languages/{languageId}/books: get: consumes: - - application/json + - application/json description: Get books for a language by ID parameters: - - description: Language ID - in: path - name: languageId - required: true - type: integer + - description: Language ID + in: path + name: languageId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -587,12 +587,12 @@ paths: $ref: '#/definitions/internal_handlers.BookListResponse' summary: Get books for a language tags: - - Languages + - Languages /publishers: get: description: Get all publishers produces: - - application/json + - application/json responses: "200": description: OK @@ -600,18 +600,18 @@ paths: $ref: '#/definitions/internal_handlers.PublisherListResponse' summary: Get all publishers tags: - - publishers + - publishers /publishers/{publisherId}: get: description: Get a publisher by ID parameters: - - description: Publisher ID - in: path - name: publisherId - required: true - type: integer + - description: Publisher ID + in: path + name: publisherId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -619,18 +619,18 @@ paths: $ref: '#/definitions/lybbrio_internal_calibre.Publisher' summary: Get a publisher tags: - - publishers + - publishers /publishers/{publisherId}/books: get: description: Get a publisher's books by ID parameters: - - description: Publisher ID - in: path - name: publisherId - required: true - type: integer + - description: Publisher ID + in: path + name: publisherId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -638,12 +638,12 @@ paths: $ref: '#/definitions/internal_handlers.BookListResponse' summary: Get a publisher's books tags: - - publishers + - publishers /series: get: description: Get all series produces: - - application/json + - application/json responses: "200": description: OK @@ -651,18 +651,18 @@ paths: $ref: '#/definitions/lybbrio_internal_handlers.SeriesListResponse' summary: Get all series tags: - - series + - series /series/{seriesId}: get: description: Get a series by ID parameters: - - description: Series ID - in: path - name: seriesId - required: true - type: integer + - description: Series ID + in: path + name: seriesId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -670,18 +670,18 @@ paths: $ref: '#/definitions/lybbrio_internal_calibre.Series' summary: Get a series tags: - - series + - series /series/{seriesId}/books: get: description: Get a series' books by ID parameters: - - description: Series ID - in: path - name: seriesId - required: true - type: integer + - description: Series ID + in: path + name: seriesId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -689,12 +689,12 @@ paths: $ref: '#/definitions/lybbrio_internal_handlers.BookListResponse' summary: Get a series' books tags: - - series + - series /tags: get: description: Get all tags produces: - - application/json + - application/json responses: "200": description: OK @@ -702,18 +702,18 @@ paths: $ref: '#/definitions/internal_handlers.TagListResponse' summary: Get all tags tags: - - tags + - tags /tags/{tagId}: get: description: Get a tag by ID parameters: - - description: Tag ID - in: path - name: tagId - required: true - type: integer + - description: Tag ID + in: path + name: tagId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -721,18 +721,18 @@ paths: $ref: '#/definitions/lybbrio_internal_calibre.Tag' summary: Get a tag tags: - - tags + - tags /tags/{tagId}/books: get: description: Get books for a tag by ID parameters: - - description: Tag ID - in: path - name: tagId - required: true - type: integer + - description: Tag ID + in: path + name: tagId + required: true + type: integer produces: - - application/json + - application/json responses: "200": description: OK @@ -740,5 +740,5 @@ paths: $ref: '#/definitions/internal_handlers.BookListResponse' summary: Get books for a tag tags: - - tags + - tags swagger: "2.0" diff --git a/internal/calibre/model.go b/internal/calibre/model.go index c544dfc3..1c896685 100644 --- a/internal/calibre/model.go +++ b/internal/calibre/model.go @@ -30,7 +30,7 @@ type Book struct { Identifiers []Identifier `json:"identifiers,omitempty" gorm:"foreignKey:book"` Publisher []Publisher `json:"publishers,omitempty" gorm:"many2many:books_publishers_link;foreignKey:id;joinForeignKey:book;References:ID;JoinReferences:publisher"` Comments Comment `json:"comments" gorm:"foreignKey:book"` - Languages []Language `json:"languages, omitempty" gorm:"many2many:books_languages_link;foreignKey:id;joinForeignKey:book;References:ID;JoinReferences:lang_code"` + Languages []Language `json:"languages,omitempty" gorm:"many2many:books_languages_link;foreignKey:id;joinForeignKey:book;References:ID;JoinReferences:lang_code"` } type Identifier struct { diff --git a/internal/handlers/author.go b/internal/handlers/author.go index 0ccc26b0..89238e15 100644 --- a/internal/handlers/author.go +++ b/internal/handlers/author.go @@ -40,7 +40,7 @@ func AuthorCtx(cal calibre.Calibre) func(http.Handler) http.Handler { s := chi.URLParam(r, "authorId") if s == "" { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } log := log.Ctx(r.Context()) @@ -50,13 +50,13 @@ func AuthorCtx(cal calibre.Calibre) func(http.Handler) http.Handler { ctx := log.WithContext(r.Context()) authorId, err := strconv.ParseInt(s, 10, 64) if err != nil { - render.Render(w, r, ErrBadRequest(err)) + render.Render(w, r, ErrBadRequest(err)) //nolint:errcheck return } author, err := cal.GetAuthor(ctx, authorId) if err != nil { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } ctx = context.WithValue(ctx, authorCtxKey, author) @@ -107,12 +107,12 @@ func GetAuthorBooks(cal calibre.Calibre) http.HandlerFunc { pagination := PaginationFromCtx(ctx) books, err := Paginate(cal, pagination.Token).GetAuthorBooks(ctx, author.ID) if err != nil { - render.Render(w, r, ErrInternalError( + render.Render(w, r, ErrInternalError( //nolint:errcheck AppError{ErrAuthorBooksDB, err.Error()}, )) return } - render.Render(w, r, BookListResponse{Items: books, Page: &pagination.Response}) + render.Render(w, r, BookListResponse{Items: books, Page: &pagination.Response}) //nolint:errcheck } } @@ -137,12 +137,12 @@ func GetAuthorSeries(cal calibre.Calibre) http.HandlerFunc { pagination := PaginationFromCtx(ctx) series, err := Paginate(cal, pagination.Token).GetAuthorSeries(ctx, author.ID) if err != nil { - render.Render(w, r, ErrInternalError( + render.Render(w, r, ErrInternalError( //nolint:errcheck AppError{ErrAuthorBooksDB, err.Error()}, )) return } - render.Render(w, r, SeriesListResponse{Items: series, Page: &pagination.Response}) + render.Render(w, r, SeriesListResponse{Items: series, Page: &pagination.Response}) //nolint:errcheck } } @@ -166,9 +166,9 @@ func GetAuthors(cal calibre.Calibre) http.HandlerFunc { pagination := PaginationFromCtx(ctx) authors, err := Paginate(cal, pagination.Token).GetAuthors(ctx) if err != nil { - render.Render(w, r, ErrInternalError(AppError{ErrRender, err.Error()})) + render.Render(w, r, ErrInternalError(AppError{ErrRender, err.Error()})) //nolint:errcheck return } - render.Render(w, r, AuthorListResponse{Items: authors, Page: &pagination.Response}) + render.Render(w, r, AuthorListResponse{Items: authors, Page: &pagination.Response}) //nolint:errcheck } } diff --git a/internal/handlers/books.go b/internal/handlers/books.go index 36510d7f..61b56a5e 100644 --- a/internal/handlers/books.go +++ b/internal/handlers/books.go @@ -40,7 +40,7 @@ func BookCtx(cal calibre.Calibre) func(http.Handler) http.Handler { s := chi.URLParam(r, "bookId") if s == "" { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } log := log.Ctx(r.Context()) @@ -50,13 +50,13 @@ func BookCtx(cal calibre.Calibre) func(http.Handler) http.Handler { ctx := log.WithContext(r.Context()) bookId, err := strconv.ParseInt(s, 10, 64) if err != nil { - render.Render(w, r, ErrBadRequest(err)) + render.Render(w, r, ErrBadRequest(err)) //nolint:errcheck return } book, err := cal.GetBook(ctx, bookId) if err != nil { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } @@ -107,10 +107,10 @@ func GetBooks(cal calibre.Calibre) http.HandlerFunc { pagination := PaginationFromCtx(ctx) books, err := Paginate(cal, pagination.Token).GetBooks(ctx) if err != nil { - render.Render(w, r, ErrInternalError(AppError{ErrBooksDB, err.Error()})) + render.Render(w, r, ErrInternalError(AppError{ErrBooksDB, err.Error()})) //nolint:errcheck return } - render.Render(w, r, BookListResponse{ + render.Render(w, r, BookListResponse{ //nolint:errcheck Items: books, Page: &pagination.Response, }) diff --git a/internal/handlers/errors.go b/internal/handlers/errors.go index 4e59cee3..ec0cfb5f 100644 --- a/internal/handlers/errors.go +++ b/internal/handlers/errors.go @@ -45,7 +45,7 @@ func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error { return nil } -func ErrInvalidRequest(err error) render.Renderer { +func ErrInvalidRequest(err error) render.Renderer { //nolint:errcheck return &ErrResponse{ Err: err, HTTPStatusCode: http.StatusBadRequest, @@ -54,7 +54,7 @@ func ErrInvalidRequest(err error) render.Renderer { } } -func ErrInternalError(err AppError) render.Renderer { +func ErrInternalError(err AppError) render.Renderer { //nolint:errcheck return &ErrResponse{ Err: err, HTTPStatusCode: http.StatusInternalServerError, @@ -64,7 +64,7 @@ func ErrInternalError(err AppError) render.Renderer { } } -func ErrBadRequest(err error) render.Renderer { +func ErrBadRequest(err error) render.Renderer { //nolint:errcheck return &ErrResponse{ Err: err, HTTPStatusCode: http.StatusBadRequest, @@ -76,5 +76,5 @@ func ErrBadRequest(err error) render.Renderer { var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."} func NotFoundHandler(w http.ResponseWriter, r *http.Request) { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck } diff --git a/internal/handlers/language.go b/internal/handlers/language.go index 1ac5acb8..b4cce3e4 100644 --- a/internal/handlers/language.go +++ b/internal/handlers/language.go @@ -40,7 +40,7 @@ func LanguageCtx(cal calibre.Calibre) func(http.Handler) http.Handler { s := chi.URLParam(r, "languageId") if s == "" { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } log := log.Ctx(r.Context()) @@ -50,13 +50,13 @@ func LanguageCtx(cal calibre.Calibre) func(http.Handler) http.Handler { ctx := log.WithContext(r.Context()) languageId, err := strconv.ParseInt(s, 10, 64) if err != nil { - render.Render(w, r, ErrBadRequest(err)) + render.Render(w, r, ErrBadRequest(err)) //nolint:errcheck return } language, err := cal.GetLanguage(ctx, languageId) if err != nil { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } ctx = context.WithValue(ctx, languageCtxKeyKey, language) @@ -97,10 +97,10 @@ func GetLanguageBooks(cal calibre.Calibre) http.HandlerFunc { pagination := PaginationFromCtx(ctx) books, err := Paginate(cal, pagination.Token).GetLanguageBooks(ctx, language.ID) if err != nil { - render.Render(w, r, ErrInternalError(AppError{ErrLanguageBooksDB, err.Error()})) + render.Render(w, r, ErrInternalError(AppError{ErrLanguageBooksDB, err.Error()})) //nolint:errcheck return } - render.Render(w, r, BookListResponse{Items: books, Page: &pagination.Response}) + render.Render(w, r, BookListResponse{Items: books, Page: &pagination.Response}) //nolint:errcheck } } @@ -118,9 +118,9 @@ func GetLanguages(cal calibre.Calibre) http.HandlerFunc { pagination := PaginationFromCtx(ctx) languages, err := Paginate(cal, pagination.Token).GetLanguages(ctx) if err != nil { - render.Render(w, r, ErrInternalError(AppError{ErrLanguagesDB, err.Error()})) + render.Render(w, r, ErrInternalError(AppError{ErrLanguagesDB, err.Error()})) //nolint:errcheck return } - render.Render(w, r, LanguageListResponse{Items: languages, Page: &pagination.Response}) + render.Render(w, r, LanguageListResponse{Items: languages, Page: &pagination.Response}) //nolint:errcheck } } diff --git a/internal/handlers/pagination.go b/internal/handlers/pagination.go index 2505bbd5..d4fd62b6 100644 --- a/internal/handlers/pagination.go +++ b/internal/handlers/pagination.go @@ -91,12 +91,12 @@ func PaginationCtx(next http.Handler) http.Handler { log := log.Ctx(ctx) if err != nil { log.Error().Err(err).Msg("Error processing pagination token.") - render.Render(w, r, ErrBadRequest(err)) + render.Render(w, r, ErrBadRequest(err)) //nolint:errcheck return } nextToken, err := MarshalPaginationToken(token.Next()) if err != nil { - render.Render(w, r, ErrInternalError(AppError{ErrPaginationToken, err.Error()})) + render.Render(w, r, ErrInternalError(AppError{ErrPaginationToken, err.Error()})) //nolint:errcheck return } obj := PaginationContextObject{ diff --git a/internal/handlers/publisher.go b/internal/handlers/publisher.go index 031658bd..4e5e69f8 100644 --- a/internal/handlers/publisher.go +++ b/internal/handlers/publisher.go @@ -40,7 +40,7 @@ func PublisherCtx(cal calibre.Calibre) func(http.Handler) http.Handler { s := chi.URLParam(r, "publisherId") if s == "" { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } log := log.Ctx(r.Context()) @@ -50,13 +50,13 @@ func PublisherCtx(cal calibre.Calibre) func(http.Handler) http.Handler { ctx := log.WithContext(r.Context()) publisherId, err := strconv.ParseInt(s, 10, 64) if err != nil { - render.Render(w, r, ErrBadRequest(err)) + render.Render(w, r, ErrBadRequest(err)) //nolint:errcheck return } publisher, err := cal.GetPublisher(ctx, publisherId) if err != nil { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } @@ -96,7 +96,7 @@ func GetPublisherBooks(cal calibre.Calibre) http.HandlerFunc { publisher := publisherFromContext(ctx) books, err := Paginate(cal, pagination.Token).GetPublisherBooks(ctx, publisher.ID) if err != nil { - render.Render(w, r, ErrInternalError(AppError{ErrPublisherBooksDB, err.Error()})) + render.Render(w, r, ErrInternalError(AppError{ErrPublisherBooksDB, err.Error()})) //nolint:errcheck return } render.JSON(w, r, books) @@ -116,11 +116,11 @@ func GetPublishers(cal calibre.Calibre) http.HandlerFunc { pagination := PaginationFromCtx(ctx) publishers, err := Paginate(cal, pagination.Token).GetPublishers(ctx) if err != nil { - render.Render(w, r, ErrInternalError(AppError{ErrPublishersDB, err.Error()})) + render.Render(w, r, ErrInternalError(AppError{ErrPublishersDB, err.Error()})) //nolint:errcheck return } - render.Render(w, r, PublisherListResponse{ + render.Render(w, r, PublisherListResponse{ //nolint:errcheck Items: publishers, Page: &pagination.Response, }) diff --git a/internal/handlers/series.go b/internal/handlers/series.go index ac16890c..dcc7d683 100644 --- a/internal/handlers/series.go +++ b/internal/handlers/series.go @@ -40,7 +40,7 @@ func SeriesCtx(cal calibre.Calibre) func(http.Handler) http.Handler { s := chi.URLParam(r, "seriesId") if s == "" { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } log := log.Ctx(r.Context()) @@ -50,13 +50,13 @@ func SeriesCtx(cal calibre.Calibre) func(http.Handler) http.Handler { ctx := log.WithContext(r.Context()) seriesId, err := strconv.ParseInt(s, 10, 64) if err != nil { - render.Render(w, r, ErrBadRequest(err)) + render.Render(w, r, ErrBadRequest(err)) //nolint:errcheck return } series, err := cal.GetSeries(ctx, seriesId) if err != nil { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } @@ -96,9 +96,9 @@ func GetSeriesBooks(cal calibre.Calibre) http.HandlerFunc { pagination := PaginationFromCtx(ctx) books, err := Paginate(cal, pagination.Token).GetSeriesBooks(ctx, series.ID) if err != nil { - render.Render(w, r, ErrInternalError(AppError{ErrSeriesBooksDB, err.Error()})) + render.Render(w, r, ErrInternalError(AppError{ErrSeriesBooksDB, err.Error()})) //nolint:errcheck } - render.Render(w, r, BookListResponse{Items: books, Page: &pagination.Response}) + render.Render(w, r, BookListResponse{Items: books, Page: &pagination.Response}) //nolint:errcheck } } @@ -115,9 +115,9 @@ func GetSeriesList(cal calibre.Calibre) http.HandlerFunc { pagination := PaginationFromCtx(ctx) series, err := Paginate(cal, pagination.Token).GetSeriesList(ctx) if err != nil { - render.Render(w, r, ErrInternalError(AppError{ErrSeriesDB, err.Error()})) + render.Render(w, r, ErrInternalError(AppError{ErrSeriesDB, err.Error()})) //nolint:errcheck return } - render.Render(w, r, SeriesListResponse{Items: series, Page: &pagination.Response}) + render.Render(w, r, SeriesListResponse{Items: series, Page: &pagination.Response}) //nolint:errcheck } } diff --git a/internal/handlers/tag.go b/internal/handlers/tag.go index 21a15308..590b2505 100644 --- a/internal/handlers/tag.go +++ b/internal/handlers/tag.go @@ -40,7 +40,7 @@ func TagCtx(cal calibre.Calibre) func(next http.Handler) http.Handler { s := chi.URLParam(r, "tagId") if s == "" { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } log := log.Ctx(r.Context()) @@ -50,13 +50,13 @@ func TagCtx(cal calibre.Calibre) func(next http.Handler) http.Handler { ctx := log.WithContext(r.Context()) tagId, err := strconv.ParseInt(s, 10, 64) if err != nil { - render.Render(w, r, ErrBadRequest(err)) + render.Render(w, r, ErrBadRequest(err)) //nolint:errcheck return } tag, err := cal.GetTag(ctx, tagId) if err != nil { - render.Render(w, r, ErrNotFound) + render.Render(w, r, ErrNotFound) //nolint:errcheck return } @@ -96,10 +96,10 @@ func GetTagBooks(cal calibre.Calibre) http.HandlerFunc { pagination := PaginationFromCtx(ctx) books, err := Paginate(cal, pagination.Token).GetTagBooks(ctx, tag.ID) if err != nil { - render.Render(w, r, ErrInternalError(AppError{ErrPaginationToken, err.Error()})) + render.Render(w, r, ErrInternalError(AppError{ErrPaginationToken, err.Error()})) //nolint:errcheck return } - render.Render(w, r, BookListResponse{Items: books, Page: &pagination.Response}) + render.Render(w, r, BookListResponse{Items: books, Page: &pagination.Response}) //nolint:errcheck } } @@ -116,9 +116,9 @@ func GetTags(cal calibre.Calibre) http.HandlerFunc { pagination := PaginationFromCtx(ctx) tags, err := Paginate(cal, pagination.Token).GetTags(ctx) if err != nil { - render.Render(w, r, ErrInternalError(AppError{ErrPaginationToken, err.Error()})) + render.Render(w, r, ErrInternalError(AppError{ErrPaginationToken, err.Error()})) //nolint:errcheck return } - render.Render(w, r, TagListResponse{Items: tags, Page: &pagination.Response}) + render.Render(w, r, TagListResponse{Items: tags, Page: &pagination.Response}) //nolint:errcheck } } diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 5db72dd6..00000000 --- a/renovate.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:recommended" - ] -}