From 82722f374ce6c6e8a44bffa0a25fe4bf2138004d Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Fri, 30 Jun 2023 14:25:40 +0300 Subject: feat: add moderator status into jwt token Former-commit-id: 3034de650c9e5898a1915814ea12c4c7f4f627db --- backend/controllers/loginController.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'backend/controllers/loginController.go') diff --git a/backend/controllers/loginController.go b/backend/controllers/loginController.go index cfe086d..b30d26e 100644 --- a/backend/controllers/loginController.go +++ b/backend/controllers/loginController.go @@ -59,10 +59,20 @@ func Login(c *gin.Context) { database.DB.Exec(`INSERT INTO users (steam_id, user_name, avatar_link, country_code) VALUES ($1, $2, $3, $4)`, steamID, user.PersonaName, user.AvatarFull, user.LocCountryCode) } + moderator := false + rows, _ := database.DB.Query("SELECT title_name FROM titles WHERE user_id = $1", steamID) + for rows.Next() { + var title string + rows.Scan(&title) + if title == "Moderator" { + moderator = true + } + } // Generate JWT token token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ "sub": steamID, "exp": time.Now().Add(time.Hour * 24 * 30).Unix(), + "mod": moderator, }) // Sign and get the complete encoded token as a string using the secret tokenString, err := token.SignedString([]byte(os.Getenv("SECRET_KEY"))) -- cgit v1.2.3 From c071eeca829a18941fc29f4e4eb8b8f93a65b5c4 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Mon, 3 Jul 2023 23:16:42 +0300 Subject: docs: refactor docs Former-commit-id: 3f3833af352d8758ca509a4fe3badedd5250b1ba --- backend/controllers/homeController.go | 26 ++++---- backend/controllers/loginController.go | 38 +++++------ backend/controllers/mapController.go | 68 +++++++++---------- backend/controllers/modController.go | 54 +++++++-------- backend/controllers/recordController.go | 44 ++++++------- backend/controllers/userController.go | 74 ++++++++++----------- docs/docs.go | 112 ++++++++++++++++---------------- docs/swagger.json | 112 ++++++++++++++++---------------- docs/swagger.yaml | 80 +++++++++++------------ 9 files changed, 304 insertions(+), 304 deletions(-) (limited to 'backend/controllers/loginController.go') diff --git a/backend/controllers/homeController.go b/backend/controllers/homeController.go index b5c6b60..2780e63 100644 --- a/backend/controllers/homeController.go +++ b/backend/controllers/homeController.go @@ -23,12 +23,12 @@ func Home(c *gin.Context) { // GET Rankings // -// @Summary Get rankings of every player. -// @Tags rankings -// @Produce json -// @Success 200 {object} models.Response{data=models.RankingsResponse} -// @Failure 400 {object} models.Response -// @Router /demo [get] +// @Description Get rankings of every player. +// @Tags rankings +// @Produce json +// @Success 200 {object} models.Response{data=models.RankingsResponse} +// @Failure 400 {object} models.Response +// @Router /rankings [get] func Rankings(c *gin.Context) { rows, err := database.DB.Query(`SELECT steam_id, user_name FROM users`) if err != nil { @@ -125,13 +125,13 @@ func Rankings(c *gin.Context) { // GET Search With Query // -// @Summary Get all user and map data matching to the query. -// @Tags search -// @Produce json -// @Param q query string false "Search user or map name." -// @Success 200 {object} models.Response{data=models.SearchResponse} -// @Failure 400 {object} models.Response -// @Router /search [get] +// @Description Get all user and map data matching to the query. +// @Tags search +// @Produce json +// @Param q query string false "Search user or map name." +// @Success 200 {object} models.Response{data=models.SearchResponse} +// @Failure 400 {object} models.Response +// @Router /search [get] func SearchWithQuery(c *gin.Context) { query := c.Query("q") query = strings.ToLower(query) diff --git a/backend/controllers/loginController.go b/backend/controllers/loginController.go index b30d26e..ae6e957 100644 --- a/backend/controllers/loginController.go +++ b/backend/controllers/loginController.go @@ -17,13 +17,13 @@ import ( // Login // -// @Summary Get (redirect) login page for Steam auth. -// @Tags login -// @Accept json -// @Produce json -// @Success 200 {object} models.Response{data=models.LoginResponse} -// @Failure 400 {object} models.Response -// @Router /login [get] +// @Description Get (redirect) login page for Steam auth. +// @Tags login +// @Accept json +// @Produce json +// @Success 200 {object} models.Response{data=models.LoginResponse} +// @Failure 400 {object} models.Response +// @Router /login [get] func Login(c *gin.Context) { openID := steam_go.NewOpenId(c.Request) switch openID.Mode() { @@ -95,13 +95,13 @@ func Login(c *gin.Context) { // GET Token // -// @Summary Gets the token cookie value from the user. -// @Tags auth -// @Produce json +// @Description Gets the token cookie value from the user. +// @Tags auth +// @Produce json // -// @Success 200 {object} models.Response{data=models.LoginResponse} -// @Failure 404 {object} models.Response -// @Router /token [get] +// @Success 200 {object} models.Response{data=models.LoginResponse} +// @Failure 404 {object} models.Response +// @Router /token [get] func GetCookie(c *gin.Context) { cookie, err := c.Cookie("token") if err != nil { @@ -119,13 +119,13 @@ func GetCookie(c *gin.Context) { // DELETE Token // -// @Summary Deletes the token cookie from the user. -// @Tags auth -// @Produce json +// @Description Deletes the token cookie from the user. +// @Tags auth +// @Produce json // -// @Success 200 {object} models.Response{data=models.LoginResponse} -// @Failure 404 {object} models.Response -// @Router /token [delete] +// @Success 200 {object} models.Response{data=models.LoginResponse} +// @Failure 404 {object} models.Response +// @Router /token [delete] func DeleteCookie(c *gin.Context) { cookie, err := c.Cookie("token") if err != nil { diff --git a/backend/controllers/mapController.go b/backend/controllers/mapController.go index 7a26554..52b6623 100644 --- a/backend/controllers/mapController.go +++ b/backend/controllers/mapController.go @@ -11,13 +11,13 @@ import ( // GET Map Summary // -// @Summary Get map summary with specified id. -// @Tags maps -// @Produce json -// @Param id path int true "Map ID" -// @Success 200 {object} models.Response{data=models.MapSummaryResponse} -// @Failure 400 {object} models.Response -// @Router /maps/{id}/summary [get] +// @Description Get map summary with specified id. +// @Tags maps +// @Produce json +// @Param id path int true "Map ID" +// @Success 200 {object} models.Response{data=models.MapSummaryResponse} +// @Failure 400 {object} models.Response +// @Router /maps/{id}/summary [get] func FetchMapSummary(c *gin.Context) { id := c.Param("id") response := models.MapSummaryResponse{Map: models.Map{}, Summary: models.MapSummary{Routes: []models.MapRoute{}}} @@ -69,13 +69,13 @@ func FetchMapSummary(c *gin.Context) { // GET Map Leaderboards // -// @Summary Get map leaderboards with specified id. -// @Tags maps -// @Produce json -// @Param id path int true "Map ID" -// @Success 200 {object} models.Response{data=models.Map{data=models.MapRecords}} -// @Failure 400 {object} models.Response -// @Router /maps/{id}/leaderboards [get] +// @Description Get map leaderboards with specified id. +// @Tags maps +// @Produce json +// @Param id path int true "Map ID" +// @Success 200 {object} models.Response{data=models.Map{data=models.MapRecords}} +// @Failure 400 {object} models.Response +// @Router /maps/{id}/leaderboards [get] func FetchMapLeaderboards(c *gin.Context) { // TODO: make new response type id := c.Param("id") @@ -186,12 +186,12 @@ func FetchMapLeaderboards(c *gin.Context) { // GET Games // -// @Summary Get games from the leaderboards. -// @Tags games & chapters -// @Produce json -// @Success 200 {object} models.Response{data=[]models.Game} -// @Failure 400 {object} models.Response -// @Router /games [get] +// @Description Get games from the leaderboards. +// @Tags games & chapters +// @Produce json +// @Success 200 {object} models.Response{data=[]models.Game} +// @Failure 400 {object} models.Response +// @Router /games [get] func FetchGames(c *gin.Context) { rows, err := database.DB.Query(`SELECT id, name FROM games`) if err != nil { @@ -216,13 +216,13 @@ func FetchGames(c *gin.Context) { // GET Chapters of a Game // -// @Summary Get chapters from the specified game id. -// @Tags games & chapters -// @Produce json -// @Param id path int true "Game ID" -// @Success 200 {object} models.Response{data=models.ChaptersResponse} -// @Failure 400 {object} models.Response -// @Router /games/{id} [get] +// @Description Get chapters from the specified game id. +// @Tags games & chapters +// @Produce json +// @Param id path int true "Game ID" +// @Success 200 {object} models.Response{data=models.ChaptersResponse} +// @Failure 400 {object} models.Response +// @Router /games/{id} [get] func FetchChapters(c *gin.Context) { gameID := c.Param("id") intID, err := strconv.Atoi(gameID) @@ -258,13 +258,13 @@ func FetchChapters(c *gin.Context) { // GET Maps of a Chapter // -// @Summary Get maps from the specified chapter id. -// @Tags games & chapters -// @Produce json -// @Param id path int true "Chapter ID" -// @Success 200 {object} models.Response{data=models.ChapterMapsResponse} -// @Failure 400 {object} models.Response -// @Router /chapters/{id} [get] +// @Description Get maps from the specified chapter id. +// @Tags games & chapters +// @Produce json +// @Param id path int true "Chapter ID" +// @Success 200 {object} models.Response{data=models.ChapterMapsResponse} +// @Failure 400 {object} models.Response +// @Router /chapters/{id} [get] func FetchChapterMaps(c *gin.Context) { chapterID := c.Param("id") intID, err := strconv.Atoi(chapterID) diff --git a/backend/controllers/modController.go b/backend/controllers/modController.go index f1874f7..d6dc4d4 100644 --- a/backend/controllers/modController.go +++ b/backend/controllers/modController.go @@ -11,15 +11,15 @@ import ( // POST Map Summary // -// @Summary Create map summary with specified map id. -// @Tags maps -// @Produce json -// @Param Authorization header string true "JWT Token" -// @Param id path int true "Map ID" -// @Param request body models.CreateMapSummaryRequest true "Body" -// @Success 200 {object} models.Response{data=models.CreateMapSummaryRequest} -// @Failure 400 {object} models.Response -// @Router /maps/{id}/summary [post] +// @Description Create map summary with specified map id. +// @Tags maps +// @Produce json +// @Param Authorization header string true "JWT Token" +// @Param id path int true "Map ID" +// @Param request body models.CreateMapSummaryRequest true "Body" +// @Success 200 {object} models.Response{data=models.CreateMapSummaryRequest} +// @Failure 400 {object} models.Response +// @Router /maps/{id}/summary [post] func CreateMapSummary(c *gin.Context) { // Check if user exists user, exists := c.Get("user") @@ -97,15 +97,15 @@ func CreateMapSummary(c *gin.Context) { // PUT Map Summary // -// @Summary Edit map summary with specified map id. -// @Tags maps -// @Produce json -// @Param Authorization header string true "JWT Token" -// @Param id path int true "Map ID" -// @Param request body models.EditMapSummaryRequest true "Body" -// @Success 200 {object} models.Response{data=models.EditMapSummaryRequest} -// @Failure 400 {object} models.Response -// @Router /maps/{id}/summary [put] +// @Description Edit map summary with specified map id. +// @Tags maps +// @Produce json +// @Param Authorization header string true "JWT Token" +// @Param id path int true "Map ID" +// @Param request body models.EditMapSummaryRequest true "Body" +// @Success 200 {object} models.Response{data=models.EditMapSummaryRequest} +// @Failure 400 {object} models.Response +// @Router /maps/{id}/summary [put] func EditMapSummary(c *gin.Context) { // Check if user exists user, exists := c.Get("user") @@ -180,15 +180,15 @@ func EditMapSummary(c *gin.Context) { // DELETE Map Summary // -// @Summary Delete map summary with specified map id. -// @Tags maps -// @Produce json -// @Param Authorization header string true "JWT Token" -// @Param id path int true "Map ID" -// @Param request body models.DeleteMapSummaryRequest true "Body" -// @Success 200 {object} models.Response{data=models.DeleteMapSummaryRequest} -// @Failure 400 {object} models.Response -// @Router /maps/{id}/summary [delete] +// @Description Delete map summary with specified map id. +// @Tags maps +// @Produce json +// @Param Authorization header string true "JWT Token" +// @Param id path int true "Map ID" +// @Param request body models.DeleteMapSummaryRequest true "Body" +// @Success 200 {object} models.Response{data=models.DeleteMapSummaryRequest} +// @Failure 400 {object} models.Response +// @Router /maps/{id}/summary [delete] func DeleteMapSummary(c *gin.Context) { // Check if user exists user, exists := c.Get("user") diff --git a/backend/controllers/recordController.go b/backend/controllers/recordController.go index 409a2e7..af8eb63 100644 --- a/backend/controllers/recordController.go +++ b/backend/controllers/recordController.go @@ -21,20 +21,20 @@ import ( // POST Record // -// @Summary Post record with demo of a specific map. -// @Tags maps -// @Accept mpfd -// @Produce json -// @Param id path int true "Map ID" -// @Param Authorization header string true "JWT Token" -// @Param host_demo formData file true "Host Demo" -// @Param partner_demo formData file false "Partner Demo" -// @Param is_partner_orange formData boolean false "Is Partner Orange" -// @Param partner_id formData string false "Partner ID" -// @Success 200 {object} models.Response -// @Failure 400 {object} models.Response -// @Failure 401 {object} models.Response -// @Router /maps/{id}/record [post] +// @Description Post record with demo of a specific map. +// @Tags maps +// @Accept mpfd +// @Produce json +// @Param id path int true "Map ID" +// @Param Authorization header string true "JWT Token" +// @Param host_demo formData file true "Host Demo" +// @Param partner_demo formData file false "Partner Demo" +// @Param is_partner_orange formData boolean false "Is Partner Orange" +// @Param partner_id formData string false "Partner ID" +// @Success 200 {object} models.Response +// @Failure 400 {object} models.Response +// @Failure 401 {object} models.Response +// @Router /maps/{id}/record [post] func CreateRecordWithDemo(c *gin.Context) { mapId := c.Param("id") // Check if user exists @@ -189,14 +189,14 @@ func CreateRecordWithDemo(c *gin.Context) { // GET Demo // -// @Summary Get demo with specified demo uuid. -// @Tags demo -// @Accept json -// @Produce octet-stream -// @Param uuid query int true "Demo UUID" -// @Success 200 {file} binary "Demo File" -// @Failure 400 {object} models.Response -// @Router /demos [get] +// @Description Get demo with specified demo uuid. +// @Tags demo +// @Accept json +// @Produce octet-stream +// @Param uuid query string true "Demo UUID" +// @Success 200 {file} binary "Demo File" +// @Failure 400 {object} models.Response +// @Router /demos [get] func DownloadDemoWithID(c *gin.Context) { uuid := c.Query("uuid") var locationID string diff --git a/backend/controllers/userController.go b/backend/controllers/userController.go index cbce0fe..e73b1fe 100644 --- a/backend/controllers/userController.go +++ b/backend/controllers/userController.go @@ -13,15 +13,15 @@ import ( // GET Profile // -// @Summary Get profile page of session user. -// @Tags users -// @Accept json -// @Produce json -// @Param Authorization header string true "JWT Token" -// @Success 200 {object} models.Response{data=models.ProfileResponse} -// @Failure 400 {object} models.Response -// @Failure 401 {object} models.Response -// @Router /profile [get] +// @Description Get profile page of session user. +// @Tags users +// @Accept json +// @Produce json +// @Param Authorization header string true "JWT Token" +// @Success 200 {object} models.Response{data=models.ProfileResponse} +// @Failure 400 {object} models.Response +// @Failure 401 {object} models.Response +// @Router /profile [get] func Profile(c *gin.Context) { // Check if user exists user, exists := c.Get("user") @@ -100,15 +100,15 @@ func Profile(c *gin.Context) { // GET User // -// @Summary Get profile page of another user. -// @Tags users -// @Accept json -// @Produce json -// @Param id path int true "User ID" -// @Success 200 {object} models.Response{data=models.ProfileResponse} -// @Failure 400 {object} models.Response -// @Failure 404 {object} models.Response -// @Router /users/{id} [get] +// @Description Get profile page of another user. +// @Tags users +// @Accept json +// @Produce json +// @Param id path int true "User ID" +// @Success 200 {object} models.Response{data=models.ProfileResponse} +// @Failure 400 {object} models.Response +// @Failure 404 {object} models.Response +// @Router /users/{id} [get] func FetchUser(c *gin.Context) { id := c.Param("id") // Check if id is all numbers and 17 length @@ -202,15 +202,15 @@ func FetchUser(c *gin.Context) { // PUT Profile // -// @Summary Update profile page of session user. -// @Tags users -// @Accept json -// @Produce json -// @Param Authorization header string true "JWT Token" -// @Success 200 {object} models.Response{data=models.ProfileResponse} -// @Failure 400 {object} models.Response -// @Failure 401 {object} models.Response -// @Router /profile [post] +// @Description Update profile page of session user. +// @Tags users +// @Accept json +// @Produce json +// @Param Authorization header string true "JWT Token" +// @Success 200 {object} models.Response{data=models.ProfileResponse} +// @Failure 400 {object} models.Response +// @Failure 401 {object} models.Response +// @Router /profile [post] func UpdateUser(c *gin.Context) { // Check if user exists user, exists := c.Get("user") @@ -245,16 +245,16 @@ func UpdateUser(c *gin.Context) { // PUT Profile/CountryCode // -// @Summary Update country code of session user. -// @Tags users -// @Accept json -// @Produce json -// @Param Authorization header string true "JWT Token" -// @Param country_code query string true "Country Code [XX]" -// @Success 200 {object} models.Response -// @Failure 400 {object} models.Response -// @Failure 401 {object} models.Response -// @Router /profile [put] +// @Description Update country code of session user. +// @Tags users +// @Accept json +// @Produce json +// @Param Authorization header string true "JWT Token" +// @Param country_code query string true "Country Code [XX]" +// @Success 200 {object} models.Response +// @Failure 400 {object} models.Response +// @Failure 401 {object} models.Response +// @Router /profile [put] func UpdateCountryCode(c *gin.Context) { // Check if user exists user, exists := c.Get("user") diff --git a/docs/docs.go b/docs/docs.go index bb14382..57984f4 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -22,13 +22,13 @@ const docTemplate = `{ "paths": { "/chapters/{id}": { "get": { + "description": "Get maps from the specified chapter id.", "produces": [ "application/json" ], "tags": [ "games \u0026 chapters" ], - "summary": "Get maps from the specified chapter id.", "parameters": [ { "type": "integer", @@ -66,45 +66,9 @@ const docTemplate = `{ } } }, - "/demo": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "rankings" - ], - "summary": "Get rankings of every player.", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/models.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/models.RankingsResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - } - } - } - }, "/demos": { "get": { + "description": "Get demo with specified demo uuid.", "consumes": [ "application/json" ], @@ -114,10 +78,9 @@ const docTemplate = `{ "tags": [ "demo" ], - "summary": "Get demo with specified demo uuid.", "parameters": [ { - "type": "integer", + "type": "string", "description": "Demo UUID", "name": "uuid", "in": "query", @@ -142,13 +105,13 @@ const docTemplate = `{ }, "/games": { "get": { + "description": "Get games from the leaderboards.", "produces": [ "application/json" ], "tags": [ "games \u0026 chapters" ], - "summary": "Get games from the leaderboards.", "responses": { "200": { "description": "OK", @@ -182,13 +145,13 @@ const docTemplate = `{ }, "/games/{id}": { "get": { + "description": "Get chapters from the specified game id.", "produces": [ "application/json" ], "tags": [ "games \u0026 chapters" ], - "summary": "Get chapters from the specified game id.", "parameters": [ { "type": "integer", @@ -228,6 +191,7 @@ const docTemplate = `{ }, "/login": { "get": { + "description": "Get (redirect) login page for Steam auth.", "consumes": [ "application/json" ], @@ -237,7 +201,6 @@ const docTemplate = `{ "tags": [ "login" ], - "summary": "Get (redirect) login page for Steam auth.", "responses": { "200": { "description": "OK", @@ -268,13 +231,13 @@ const docTemplate = `{ }, "/maps/{id}/leaderboards": { "get": { + "description": "Get map leaderboards with specified id.", "produces": [ "application/json" ], "tags": [ "maps" ], - "summary": "Get map leaderboards with specified id.", "parameters": [ { "type": "integer", @@ -326,6 +289,7 @@ const docTemplate = `{ }, "/maps/{id}/record": { "post": { + "description": "Post record with demo of a specific map.", "consumes": [ "multipart/form-data" ], @@ -335,7 +299,6 @@ const docTemplate = `{ "tags": [ "maps" ], - "summary": "Post record with demo of a specific map.", "parameters": [ { "type": "integer", @@ -401,13 +364,13 @@ const docTemplate = `{ }, "/maps/{id}/summary": { "get": { + "description": "Get map summary with specified id.", "produces": [ "application/json" ], "tags": [ "maps" ], - "summary": "Get map summary with specified id.", "parameters": [ { "type": "integer", @@ -445,13 +408,13 @@ const docTemplate = `{ } }, "put": { + "description": "Edit map summary with specified map id.", "produces": [ "application/json" ], "tags": [ "maps" ], - "summary": "Edit map summary with specified map id.", "parameters": [ { "type": "string", @@ -505,13 +468,13 @@ const docTemplate = `{ } }, "post": { + "description": "Create map summary with specified map id.", "produces": [ "application/json" ], "tags": [ "maps" ], - "summary": "Create map summary with specified map id.", "parameters": [ { "type": "string", @@ -565,13 +528,13 @@ const docTemplate = `{ } }, "delete": { + "description": "Delete map summary with specified map id.", "produces": [ "application/json" ], "tags": [ "maps" ], - "summary": "Delete map summary with specified map id.", "parameters": [ { "type": "string", @@ -627,6 +590,7 @@ const docTemplate = `{ }, "/profile": { "get": { + "description": "Get profile page of session user.", "consumes": [ "application/json" ], @@ -636,7 +600,6 @@ const docTemplate = `{ "tags": [ "users" ], - "summary": "Get profile page of session user.", "parameters": [ { "type": "string", @@ -680,6 +643,7 @@ const docTemplate = `{ } }, "put": { + "description": "Update country code of session user.", "consumes": [ "application/json" ], @@ -689,7 +653,6 @@ const docTemplate = `{ "tags": [ "users" ], - "summary": "Update country code of session user.", "parameters": [ { "type": "string", @@ -728,6 +691,7 @@ const docTemplate = `{ } }, "post": { + "description": "Update profile page of session user.", "consumes": [ "application/json" ], @@ -737,7 +701,6 @@ const docTemplate = `{ "tags": [ "users" ], - "summary": "Update profile page of session user.", "parameters": [ { "type": "string", @@ -781,15 +744,52 @@ const docTemplate = `{ } } }, + "/rankings": { + "get": { + "description": "Get rankings of every player.", + "produces": [ + "application/json" + ], + "tags": [ + "rankings" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/models.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/models.RankingsResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/models.Response" + } + } + } + } + }, "/search": { "get": { + "description": "Get all user and map data matching to the query.", "produces": [ "application/json" ], "tags": [ "search" ], - "summary": "Get all user and map data matching to the query.", "parameters": [ { "type": "string", @@ -828,13 +828,13 @@ const docTemplate = `{ }, "/token": { "get": { + "description": "Gets the token cookie value from the user.", "produces": [ "application/json" ], "tags": [ "auth" ], - "summary": "Gets the token cookie value from the user.", "responses": { "200": { "description": "OK", @@ -863,13 +863,13 @@ const docTemplate = `{ } }, "delete": { + "description": "Deletes the token cookie from the user.", "produces": [ "application/json" ], "tags": [ "auth" ], - "summary": "Deletes the token cookie from the user.", "responses": { "200": { "description": "OK", @@ -900,6 +900,7 @@ const docTemplate = `{ }, "/users/{id}": { "get": { + "description": "Get profile page of another user.", "consumes": [ "application/json" ], @@ -909,7 +910,6 @@ const docTemplate = `{ "tags": [ "users" ], - "summary": "Get profile page of another user.", "parameters": [ { "type": "integer", diff --git a/docs/swagger.json b/docs/swagger.json index 3530d2c..ef422ab 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -15,13 +15,13 @@ "paths": { "/chapters/{id}": { "get": { + "description": "Get maps from the specified chapter id.", "produces": [ "application/json" ], "tags": [ "games \u0026 chapters" ], - "summary": "Get maps from the specified chapter id.", "parameters": [ { "type": "integer", @@ -59,45 +59,9 @@ } } }, - "/demo": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "rankings" - ], - "summary": "Get rankings of every player.", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/models.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/models.RankingsResponse" - } - } - } - ] - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - } - } - } - }, "/demos": { "get": { + "description": "Get demo with specified demo uuid.", "consumes": [ "application/json" ], @@ -107,10 +71,9 @@ "tags": [ "demo" ], - "summary": "Get demo with specified demo uuid.", "parameters": [ { - "type": "integer", + "type": "string", "description": "Demo UUID", "name": "uuid", "in": "query", @@ -135,13 +98,13 @@ }, "/games": { "get": { + "description": "Get games from the leaderboards.", "produces": [ "application/json" ], "tags": [ "games \u0026 chapters" ], - "summary": "Get games from the leaderboards.", "responses": { "200": { "description": "OK", @@ -175,13 +138,13 @@ }, "/games/{id}": { "get": { + "description": "Get chapters from the specified game id.", "produces": [ "application/json" ], "tags": [ "games \u0026 chapters" ], - "summary": "Get chapters from the specified game id.", "parameters": [ { "type": "integer", @@ -221,6 +184,7 @@ }, "/login": { "get": { + "description": "Get (redirect) login page for Steam auth.", "consumes": [ "application/json" ], @@ -230,7 +194,6 @@ "tags": [ "login" ], - "summary": "Get (redirect) login page for Steam auth.", "responses": { "200": { "description": "OK", @@ -261,13 +224,13 @@ }, "/maps/{id}/leaderboards": { "get": { + "description": "Get map leaderboards with specified id.", "produces": [ "application/json" ], "tags": [ "maps" ], - "summary": "Get map leaderboards with specified id.", "parameters": [ { "type": "integer", @@ -319,6 +282,7 @@ }, "/maps/{id}/record": { "post": { + "description": "Post record with demo of a specific map.", "consumes": [ "multipart/form-data" ], @@ -328,7 +292,6 @@ "tags": [ "maps" ], - "summary": "Post record with demo of a specific map.", "parameters": [ { "type": "integer", @@ -394,13 +357,13 @@ }, "/maps/{id}/summary": { "get": { + "description": "Get map summary with specified id.", "produces": [ "application/json" ], "tags": [ "maps" ], - "summary": "Get map summary with specified id.", "parameters": [ { "type": "integer", @@ -438,13 +401,13 @@ } }, "put": { + "description": "Edit map summary with specified map id.", "produces": [ "application/json" ], "tags": [ "maps" ], - "summary": "Edit map summary with specified map id.", "parameters": [ { "type": "string", @@ -498,13 +461,13 @@ } }, "post": { + "description": "Create map summary with specified map id.", "produces": [ "application/json" ], "tags": [ "maps" ], - "summary": "Create map summary with specified map id.", "parameters": [ { "type": "string", @@ -558,13 +521,13 @@ } }, "delete": { + "description": "Delete map summary with specified map id.", "produces": [ "application/json" ], "tags": [ "maps" ], - "summary": "Delete map summary with specified map id.", "parameters": [ { "type": "string", @@ -620,6 +583,7 @@ }, "/profile": { "get": { + "description": "Get profile page of session user.", "consumes": [ "application/json" ], @@ -629,7 +593,6 @@ "tags": [ "users" ], - "summary": "Get profile page of session user.", "parameters": [ { "type": "string", @@ -673,6 +636,7 @@ } }, "put": { + "description": "Update country code of session user.", "consumes": [ "application/json" ], @@ -682,7 +646,6 @@ "tags": [ "users" ], - "summary": "Update country code of session user.", "parameters": [ { "type": "string", @@ -721,6 +684,7 @@ } }, "post": { + "description": "Update profile page of session user.", "consumes": [ "application/json" ], @@ -730,7 +694,6 @@ "tags": [ "users" ], - "summary": "Update profile page of session user.", "parameters": [ { "type": "string", @@ -774,15 +737,52 @@ } } }, + "/rankings": { + "get": { + "description": "Get rankings of every player.", + "produces": [ + "application/json" + ], + "tags": [ + "rankings" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/models.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/models.RankingsResponse" + } + } + } + ] + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/models.Response" + } + } + } + } + }, "/search": { "get": { + "description": "Get all user and map data matching to the query.", "produces": [ "application/json" ], "tags": [ "search" ], - "summary": "Get all user and map data matching to the query.", "parameters": [ { "type": "string", @@ -821,13 +821,13 @@ }, "/token": { "get": { + "description": "Gets the token cookie value from the user.", "produces": [ "application/json" ], "tags": [ "auth" ], - "summary": "Gets the token cookie value from the user.", "responses": { "200": { "description": "OK", @@ -856,13 +856,13 @@ } }, "delete": { + "description": "Deletes the token cookie from the user.", "produces": [ "application/json" ], "tags": [ "auth" ], - "summary": "Deletes the token cookie from the user.", "responses": { "200": { "description": "OK", @@ -893,6 +893,7 @@ }, "/users/{id}": { "get": { + "description": "Get profile page of another user.", "consumes": [ "application/json" ], @@ -902,7 +903,6 @@ "tags": [ "users" ], - "summary": "Get profile page of another user.", "parameters": [ { "type": "integer", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index d4420e2..2fed413 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -242,6 +242,7 @@ info: paths: /chapters/{id}: get: + description: Get maps from the specified chapter id. parameters: - description: Chapter ID in: path @@ -264,40 +265,19 @@ paths: description: Bad Request schema: $ref: '#/definitions/models.Response' - summary: Get maps from the specified chapter id. tags: - games & chapters - /demo: - get: - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/models.Response' - - properties: - data: - $ref: '#/definitions/models.RankingsResponse' - type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' - summary: Get rankings of every player. - tags: - - rankings /demos: get: consumes: - application/json + description: Get demo with specified demo uuid. parameters: - description: Demo UUID in: query name: uuid required: true - type: integer + type: string produces: - application/octet-stream responses: @@ -309,11 +289,11 @@ paths: description: Bad Request schema: $ref: '#/definitions/models.Response' - summary: Get demo with specified demo uuid. tags: - demo /games: get: + description: Get games from the leaderboards. produces: - application/json responses: @@ -332,11 +312,11 @@ paths: description: Bad Request schema: $ref: '#/definitions/models.Response' - summary: Get games from the leaderboards. tags: - games & chapters /games/{id}: get: + description: Get chapters from the specified game id. parameters: - description: Game ID in: path @@ -359,13 +339,13 @@ paths: description: Bad Request schema: $ref: '#/definitions/models.Response' - summary: Get chapters from the specified game id. tags: - games & chapters /login: get: consumes: - application/json + description: Get (redirect) login page for Steam auth. produces: - application/json responses: @@ -382,11 +362,11 @@ paths: description: Bad Request schema: $ref: '#/definitions/models.Response' - summary: Get (redirect) login page for Steam auth. tags: - login /maps/{id}/leaderboards: get: + description: Get map leaderboards with specified id. parameters: - description: Map ID in: path @@ -414,13 +394,13 @@ paths: description: Bad Request schema: $ref: '#/definitions/models.Response' - summary: Get map leaderboards with specified id. tags: - maps /maps/{id}/record: post: consumes: - multipart/form-data + description: Post record with demo of a specific map. parameters: - description: Map ID in: path @@ -464,11 +444,11 @@ paths: description: Unauthorized schema: $ref: '#/definitions/models.Response' - summary: Post record with demo of a specific map. tags: - maps /maps/{id}/summary: delete: + description: Delete map summary with specified map id. parameters: - description: JWT Token in: header @@ -502,10 +482,10 @@ paths: description: Bad Request schema: $ref: '#/definitions/models.Response' - summary: Delete map summary with specified map id. tags: - maps get: + description: Get map summary with specified id. parameters: - description: Map ID in: path @@ -528,10 +508,10 @@ paths: description: Bad Request schema: $ref: '#/definitions/models.Response' - summary: Get map summary with specified id. tags: - maps post: + description: Create map summary with specified map id. parameters: - description: JWT Token in: header @@ -565,10 +545,10 @@ paths: description: Bad Request schema: $ref: '#/definitions/models.Response' - summary: Create map summary with specified map id. tags: - maps put: + description: Edit map summary with specified map id. parameters: - description: JWT Token in: header @@ -602,13 +582,13 @@ paths: description: Bad Request schema: $ref: '#/definitions/models.Response' - summary: Edit map summary with specified map id. tags: - maps /profile: get: consumes: - application/json + description: Get profile page of session user. parameters: - description: JWT Token in: header @@ -635,12 +615,12 @@ paths: description: Unauthorized schema: $ref: '#/definitions/models.Response' - summary: Get profile page of session user. tags: - users post: consumes: - application/json + description: Update profile page of session user. parameters: - description: JWT Token in: header @@ -667,12 +647,12 @@ paths: description: Unauthorized schema: $ref: '#/definitions/models.Response' - summary: Update profile page of session user. tags: - users put: consumes: - application/json + description: Update country code of session user. parameters: - description: JWT Token in: header @@ -699,11 +679,32 @@ paths: description: Unauthorized schema: $ref: '#/definitions/models.Response' - summary: Update country code of session user. tags: - users + /rankings: + get: + description: Get rankings of every player. + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/models.Response' + - properties: + data: + $ref: '#/definitions/models.RankingsResponse' + type: object + "400": + description: Bad Request + schema: + $ref: '#/definitions/models.Response' + tags: + - rankings /search: get: + description: Get all user and map data matching to the query. parameters: - description: Search user or map name. in: query @@ -725,11 +726,11 @@ paths: description: Bad Request schema: $ref: '#/definitions/models.Response' - summary: Get all user and map data matching to the query. tags: - search /token: delete: + description: Deletes the token cookie from the user. produces: - application/json responses: @@ -746,10 +747,10 @@ paths: description: Not Found schema: $ref: '#/definitions/models.Response' - summary: Deletes the token cookie from the user. tags: - auth get: + description: Gets the token cookie value from the user. produces: - application/json responses: @@ -766,13 +767,13 @@ paths: description: Not Found schema: $ref: '#/definitions/models.Response' - summary: Gets the token cookie value from the user. tags: - auth /users/{id}: get: consumes: - application/json + description: Get profile page of another user. parameters: - description: User ID in: path @@ -799,7 +800,6 @@ paths: description: Not Found schema: $ref: '#/definitions/models.Response' - summary: Get profile page of another user. tags: - users swagger: "2.0" -- cgit v1.2.3