Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop branch #96

Merged
merged 20 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/drasl
/node_modules
/public/bundle.js
/swagger
15 changes: 14 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: "^swagger.json$"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
Expand All @@ -11,11 +12,23 @@ repos:
rev: v1.0.0-rc.1
hooks:
- id: go-fmt-repo
- repo: https://github.com/muya/swaggo-hooks
rev: v1.1.1
hooks:
- id: swag-fmt
- repo: https://github.com/kamadorueda/alejandra
rev: 3.0.0
hooks:
- id: alejandra-system
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8" # Use the sha or tag you want to point at
rev: v3.0.3
hooks:
- id: prettier
- repo: local
hooks:
- id: swag
name: Generate Swagger documentation
entry: make swag
language: system
files: \.go$
pass_filenames: false
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
swagger.json
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
prefix ?= /usr
.DEFAULT_GOAL := build

prebuild:
npm-install:
npm install

swag:
swag init --generalInfo api.go --output . --outputTypes json

prebuild: npm-install swag
node esbuild.config.js

build: prebuild
Expand All @@ -18,8 +23,9 @@ install: build
cp -R assets view public "$(prefix)/share/drasl/"

clean:
rm drasl
rm -r public/* public/.*
rm -f drasl
rm -f swagger.json
rm -f public/bundle.js

test: prebuild
go test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ See [doc/usage.md](doc/usage.md) for post-installation instructions and guidance

## API

Drasl has its own API for managing users and invitations, but consider it in a beta state. v1 of this API is likely to be deprecated quickly. Documentation is [here](https://doc.drasl.unmojang.org).

Drasl implements the Mojang API, documented here on [wiki.vg](https://wiki.vg):

- [Mojang API](https://wiki.vg/Mojang_API)
Expand All @@ -76,8 +78,6 @@ If you find that an API route behaves substantively different than the Mojang AP

Drasl also implements (almost all of) the authlib-injector API at `/authlib-injector`, to the extent that it differs from Mojang's. The authlib-injector API is documented [here](https://github.com/yushijinhun/authlib-injector/wiki/Yggdrasil-%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%8A%80%E6%9C%AF%E8%A7%84%E8%8C%83) ([Google Translated to English](https://github-com.translate.goog/yushijinhun/authlib-injector/wiki/Yggdrasil-%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%8A%80%E6%9C%AF%E8%A7%84%E8%8C%83?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US)).

A Drasl API for creating and administering accounts is [planned](https://github.com/unmojang/drasl/issues/18).

## Building

If using Nix (with flakes), simply run `nix build`.
Expand Down
5 changes: 4 additions & 1 deletion account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestAccount(t *testing.T) {

t.Run("Test /users/profiles/minecraft/:playerName", ts.testAccountPlayerNameToID)
t.Run("Test /profiles/minecraft", ts.makeTestAccountPlayerNamesToIDs("/profiles/minecraft"))
t.Run("Test /users/security/location", ts.testAccountVerifySecurityLocation)
}
{
ts := &TestSuite{}
Expand Down Expand Up @@ -67,6 +68,7 @@ func (ts *TestSuite) testAccountPlayerNameToID(t *testing.T) {
rec = ts.Get(t, ts.Server, "/users/profiles/minecraft/"+TEST_USERNAME_UPPERCASE, nil, nil)
assert.Nil(t, json.NewDecoder(rec.Body).Decode(&response))
uuid, err = IDToUUID(response.ID)
assert.Nil(t, err)
assert.Equal(t, user.UUID, uuid)
}

Expand Down Expand Up @@ -106,6 +108,7 @@ func (ts *TestSuite) testAccountPlayerNameToIDFallback(t *testing.T) {
assert.Equal(t, http.StatusOK, rec.Code)
assert.Nil(t, json.NewDecoder(rec.Body).Decode(&response))
uuid, err = IDToUUID(response.ID)
assert.Nil(t, err)
assert.Equal(t, uuid, user.UUID)
}

Expand Down Expand Up @@ -145,5 +148,5 @@ func (ts *TestSuite) testAccountPlayerNamesToIDsFallback(t *testing.T) {

func (ts *TestSuite) testAccountVerifySecurityLocation(t *testing.T) {
rec := ts.Get(t, ts.Server, "/user/security/location", nil, nil)
assert.Equal(t, http.StatusOK, rec.Code)
assert.Equal(t, http.StatusNoContent, rec.Code)
}
Loading
Loading