implement JWT tokens, regenerate docs and sqlc

This commit is contained in:
zardzul
2026-03-14 18:46:48 +01:00
parent 131aee8638
commit d5e608feeb
18 changed files with 441 additions and 82 deletions
+74
View File
@@ -89,6 +89,57 @@ const docTemplate = `{
}
}
},
"/users/login": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Log in with email and password",
"parameters": [
{
"description": "Login payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.LoginRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.LoginResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/users/{id}": {
"get": {
"produces": [
@@ -170,6 +221,29 @@ const docTemplate = `{
}
}
},
"handlers.LoginRequest": {
"type": "object",
"required": [
"password",
"user_mail"
],
"properties": {
"password": {
"type": "string"
},
"user_mail": {
"type": "string"
}
}
},
"handlers.LoginResponse": {
"type": "object",
"properties": {
"token": {
"type": "string"
}
}
},
"handlers.UsernameResponse": {
"type": "object",
"properties": {
+74
View File
@@ -82,6 +82,57 @@
}
}
},
"/users/login": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Log in with email and password",
"parameters": [
{
"description": "Login payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.LoginRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.LoginResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/users/{id}": {
"get": {
"produces": [
@@ -163,6 +214,29 @@
}
}
},
"handlers.LoginRequest": {
"type": "object",
"required": [
"password",
"user_mail"
],
"properties": {
"password": {
"type": "string"
},
"user_mail": {
"type": "string"
}
}
},
"handlers.LoginResponse": {
"type": "object",
"properties": {
"token": {
"type": "string"
}
}
},
"handlers.UsernameResponse": {
"type": "object",
"properties": {
+48
View File
@@ -26,6 +26,21 @@ definitions:
error:
type: string
type: object
handlers.LoginRequest:
properties:
password:
type: string
user_mail:
type: string
required:
- password
- user_mail
type: object
handlers.LoginResponse:
properties:
token:
type: string
type: object
handlers.UsernameResponse:
properties:
user_name:
@@ -111,4 +126,37 @@ paths:
summary: Create a user
tags:
- user
/users/login:
post:
consumes:
- application/json
parameters:
- description: Login payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/handlers.LoginRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handlers.LoginResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/handlers.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/handlers.ErrorResponse'
summary: Log in with email and password
tags:
- user
swagger: "2.0"