-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start working on new REST API. Refactor logic in domains. (#497)
* added 404 template * added auth domain * added embed file for frontend * added base config and dependencies * added basic new http server * added separated server command * updated go modules * removed modd file * Added shortcut to send internal server error response * Added JWT support to Auth Domain * Added JWT support to API * docs: added comments to response struct * naming * inline returns * updated dependencies * production logger * bookmarks endpoint * reverted old views api path * frontend for api v1 * proper 404 error (not working atm) * use response * removed 404 html * server error handler * login and basic auth * adjusted session duration * properly retrieve tags * properly delete bookmark * cleanup * archiver domain * debug routes * bookmark routes * expiration by parameter * move to logrus * logout * frontend cache * updated dependencies * http: migrated to gin * linted * Added version command * unit tests, docs * response test utils and tests * remove logout handler * auth * createtag * improved http test utilities * assert message equals * Remove 1.19 from test matrix * moved api to v1 folder * docs: contribute docs * updated makefile * updated usage docs * warn in server command * updaed docs with shiori version command * Updated documentation * deps: update
- Loading branch information
Showing
117 changed files
with
28,180 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Docs: https://golangci-lint.run/usage/configuration/#config-file | ||
|
||
run: | ||
timeout: 5m | ||
skip-dirs: | ||
- internal/mocks | ||
|
||
issues: | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
|
||
linters-settings: | ||
gofmt: | ||
simplify: true | ||
govet: | ||
enable-all: true | ||
disable: | ||
- fieldalignment | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- gofmt | ||
- gosimple | ||
# - govet # Re-enable when all shadow declarations are fixed | ||
- ineffassign | ||
- predeclared | ||
- exportloopref | ||
- staticcheck | ||
- unconvert | ||
- unused |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ builds: | |
- binary: shiori | ||
env: | ||
- CGO_ENABLED=0 | ||
- GIN_MODE=release | ||
tags: | ||
- netgo | ||
- osusergo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
GO ?= $(shell command -v go 2> /dev/null) | ||
BASH ?= $(shell command -v bash 2> /dev/null) | ||
|
||
# Development | ||
SHIORI_DIR ?= dev-data | ||
|
||
# Testing | ||
GO_TEST_FLAGS ?= -v -race | ||
GOTESTFMT_FLAGS ?= | ||
|
||
# Build | ||
CGO_ENABLED ?= 0 | ||
BUILD_TIME := $(shell date -u +%Y%m%d.%H%M%S) | ||
BUILD_HASH := $(shell git describe --tags) | ||
BUILD_TAGS ?= osusergo,netgo | ||
LDFLAGS += -s -w -X main.version=$(BUILD_HASH) -X main.date=$(BUILD_TIME) | ||
|
||
# Development | ||
GIN_MODE ?= debug | ||
SHIORI_DEVELOPMENT ?= true | ||
|
||
# Help documentatin à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html | ||
.PHONY: help | ||
help: | ||
@cat Makefile | grep -v '\.PHONY' | grep -v '\help:' | grep -B1 -E '^[a-zA-Z0-9_.-]+:.*' | sed -e "s/:.*//" | sed -e "s/^## //" | grep -v '\-\-' | sed '1!G;h;$$!d' | awk 'NR%2{printf "\033[36m%-30s\033[0m",$$0;next;}1' | sort | ||
|
||
## Cleans up build artifacts | ||
.PHONY: clean | ||
clean: | ||
rm -rf dist | ||
|
||
## Runs the legacy http API for local development | ||
.PHONY: serve | ||
serve: | ||
SHIORI_DEVELOPMENT=$(SHIORI_DEVELOPMENT) SHIORI_DIR=$(SHIORI_DIR) go run main.go serve | ||
|
||
## Runs server for local development | ||
.PHONY: run-server | ||
run-server: | ||
GIN_MODE=$(GIN_MODE) SHIORI_DEVELOPMENT=$(SHIORI_DEVELOPMENT) SHIORI_DIR=$(SHIORI_DIR) go run main.go server | ||
|
||
## Generate swagger docs | ||
.PHONY: swagger | ||
swagger: | ||
swag init | ||
|
||
## Run linter | ||
.PHONY: lint | ||
lint: | ||
golangci-lint run | ||
|
||
## Run unit tests | ||
.PHONY: unittest | ||
unittest: | ||
GIN_MODE=$(GIN_MODE) GO_TEST_FLAGS="$(GO_TEST_FLAGS)" GOTESTFMT_FLAGS="$(GOTESTFMT_FLAGS)" $(BASH) -xe ./scripts/test.sh | ||
|
||
## Build binary | ||
.PHONY: build | ||
build: clean | ||
GIN_MODE=$(GIN_MODE) goreleaser build --rm-dist --snapshot | ||
|
||
## Creates a coverage report | ||
.PHONY: coverage | ||
coverage: | ||
$(GO) test $(GO_TEST_FLAGS) -coverprofile=coverage.txt ./... | ||
$(GO) tool cover -html=coverage.txt |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# API v1 | ||
|
||
> ℹ️ **This is the documentation for the new API. This API is still in development and though the finished endpoints should not change please consider that breaking changes may occur once its properly released. If you are looking for the current API, please [see here](./API.md).** | ||
The new API is an ongoing effort to migrate the current API to a more modern and standard API. | ||
|
||
The main goals of this new API are: | ||
- Ease of development | ||
- Use of a [modern framework](https://gin-gonic.com) | ||
- Use of a [standard API specification](https://swagger.io/specification/) | ||
- Self-documented API using [Swag](https://github.com/swaggo/swag) | ||
- Improved authentication and sessions using [JWT](https://jwt.io) | ||
- Deduplicate code between the webserver and the API by refactoring the logic into domains | ||
- Improve testability by using interfaces and dependency injection | ||
|
||
The current status of this new API can be checked [here](https://github.com/go-shiori/shiori/issues/640). | ||
|
||
Since the API is self-docummented, you can check the API documentation by [running the server locally](./Contribute.md#running-the-server-locally) and visiting the [`/swagger/index.html` endpoint](http://localhost:8080/swagger/index.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.