Skip to content

Commit

Permalink
docs: updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pandadiestro committed Nov 20, 2024
1 parent 31f648c commit db0e613
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 12 deletions.
2 changes: 1 addition & 1 deletion stiller-backend/cmd/serve/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func main() {
}

log.Println(
"[ ✅ ] server started at port",
"[ ✅ ] server started at address",
stiller.StillerConfig.Addr,
)

Expand Down
12 changes: 7 additions & 5 deletions stiller-backend/docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

- [Server configuration](configuration.md)
- [FS-based handlers](files.md)
- [`/file/upload`](file/upload.md)
- [`/file/update`](file/update.md)
- [`/file/retrieveall`](file/retrieveall.md)
- [GET `/file/`](file/filetree.md)
- [PATCH `/file/`](file/patchfile.md)
- [POST `/file/new`](file/new.md)
- [GET `/file/dl`](file/dl.md)
- [Auth Handlers](auth.md)
- [`/auth/checkuser/:username`](auth/checkuser.md)
- [`/auth/login`](auth/login.md)
- [GET `/auth/checkuser/:username`](auth/checkuser.md)
- [POST `/auth/login`](auth/login.md)
- [POST `/auth/newuser`](auth/newuser.md)

35 changes: 35 additions & 0 deletions stiller-backend/docs/src/auth/newuser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Creating a new user

## Path

<div align="center">

`POST /auth/newuser`

</div>

## Request body

The request body is a json object of the schema:

```go
type ReqPayload struct {
AvatarId int `json:"avatar_id"`
TierId int `json:"tier_id"`
Username string `json:"username"`
Mail string `json:"mail"`
Passwd string `json:"pwd"`
}
```

The owner Id will be decoded from the token that was used and the `avatar_id`
field represents a `file::id` value, so the caller probably wants to use
`/file/new` before calling this endpoint.

Adding an avatar is totally optional.

## Response body

If succesful, the server will respond with the auth token to be used in future
requests.

26 changes: 26 additions & 0 deletions stiller-backend/docs/src/file/dl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Downloading individual Files

## Path

<div align="center">

<img src="jwt_logo.png" height="10px"/> `GET /file/dl`

</div>

## Request body

The request body is a json object of the schema:

```go
type ReqPayload struct {
FileId int `json:"file_id"`
}
```

The owner Id will be decoded from the token that was used

## Response body

If succesful, the server will respond with the full file.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div align="center">

<img src="jwt_logo.png" height="10px"/> `POST /file/upload`
<img src="jwt_logo.png" height="10px"/> `POST /file/new`

</div>

Expand Down
File renamed without changes.
Binary file added stiller-backend/docs/src/jwt_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions stiller-backend/docs/src/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@ Stiller is built almost totally upon the stdlib http serving packages except for
the router (where
[julienschmidt/httprouter](https://github.com/julienschmidt/httprouter) shines).

## About these docs

These docs contain simple information about each and every one of the server
endpoints. Those which have this logo:

<div align="center" style="text-align: center;">

<img src="./jwt_logo.png" style="width: 100px;"/>

</div>

At the "#Path" section of their documentation are supposed to pass a [`token:
<jwt token>`] along with the endpoint's usual request body and payload elements.

5 changes: 0 additions & 5 deletions stiller-backend/internal/handlers/auth/userlogin/handler.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package userlogin

import (
"log"
"net/http"
"stiller/internal/dbutils"
"stiller/internal/handlers/handleutils"
Expand Down Expand Up @@ -73,9 +72,6 @@ func NetHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
return
}

log.Println("uid:", new_tk.UserId)
log.Println("pwd:", user_bpwd)

cmp_err := bcrypt.CompareHashAndPassword([]byte(user_bpwd), []byte(payload.Pwd))
if handleutils.RequestLog(
cmp_err,
Expand All @@ -92,6 +88,5 @@ func NetHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
}

w.Write(sign_encoded)
w.WriteHeader(http.StatusOK)
}

0 comments on commit db0e613

Please sign in to comment.