refactor: updated swagger;

feat: helper function in errors for checking postgres error types;
feat: sql query method for finding users by their email;
feat: registration begin/complete with checking existing username/email;
refactor: error handling in controller
This commit is contained in:
2025-07-03 04:33:25 +03:00
parent d08db300fc
commit 0a51727af8
12 changed files with 348 additions and 31 deletions

View File

@@ -11,7 +11,7 @@ const docTemplate = `{
"title": "{{.Title}}",
"contact": {},
"license": {
"name": "GPL 3.0"
"name": "GPL-3.0"
},
"version": "{{.Version}}"
},
@@ -139,7 +139,11 @@ const docTemplate = `{
}
}
],
"responses": {}
"responses": {
"200": {
"description": "desc"
}
}
}
},
"/auth/registrationComplete": {
@@ -154,7 +158,25 @@ const docTemplate = `{
"Auth"
],
"summary": "Confirm with code, finish creating the account",
"responses": {}
"parameters": [
{
"description": "desc",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.RegistrationCompleteRequest"
}
}
],
"responses": {
"200": {
"description": "desc",
"schema": {
"$ref": "#/definitions/models.RegistrationCompleteResponse"
}
}
}
}
},
"/profile": {
@@ -305,13 +327,16 @@ const docTemplate = `{
],
"properties": {
"password": {
"type": "string"
"type": "string",
"maxLength": 100
},
"totp": {
"type": "string"
},
"username": {
"type": "string"
"type": "string",
"maxLength": 20,
"minLength": 3
}
}
},
@@ -346,6 +371,46 @@ const docTemplate = `{
"minLength": 3
}
}
},
"models.RegistrationCompleteRequest": {
"type": "object",
"required": [
"name",
"username",
"verification_code"
],
"properties": {
"avatar_url": {
"type": "string",
"maxLength": 255
},
"birthday": {
"type": "string"
},
"name": {
"type": "string",
"maxLength": 75
},
"username": {
"type": "string",
"maxLength": 20,
"minLength": 3
},
"verification_code": {
"type": "string"
}
}
},
"models.RegistrationCompleteResponse": {
"type": "object",
"properties": {
"access_token": {
"type": "string"
},
"refresh_token": {
"type": "string"
}
}
}
},
"securityDefinitions": {