first commit

This commit is contained in:
Beyhan Oğur
2026-04-26 21:48:15 +03:00
commit e6f3268c28
50 changed files with 4930 additions and 0 deletions

377
docs/swagger.yaml Normal file
View File

@@ -0,0 +1,377 @@
basePath: /
host: localhost:8080
info:
contact: {}
description: This is a sample image manipulation API using Fiber v3 and bimg.
title: Go Image Manipulation API
version: "1.0"
paths:
/admin/images:
get:
description: Returns a paginated list of all images across all users.
parameters:
- description: Page number (default 1)
in: query
name: page
type: integer
- description: Items per page (default 20, max 100)
in: query
name: limit
type: integer
- description: Filter by user ID
in: query
name: user_id
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
additionalProperties: true
type: object
"401":
description: Unauthorized
schema:
additionalProperties: true
type: object
"403":
description: Forbidden
schema:
additionalProperties: true
type: object
security:
- BearerAuth: []
summary: List all images (admin)
tags:
- Admin
/admin/users/{id}/api-token:
post:
consumes:
- multipart/form-data
description: Creates an API Token for a user (Admin ONLY).
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
- description: Expiration in days (0 or omit for never)
in: formData
name: expires_in_days
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
additionalProperties: true
type: object
"401":
description: Unauthorized
schema:
additionalProperties: true
type: object
"403":
description: Forbidden
schema:
additionalProperties: true
type: object
"404":
description: Not Found
schema:
additionalProperties: true
type: object
security:
- BearerAuth: []
summary: Create API Token
tags:
- Admin
/auth/login:
post:
consumes:
- multipart/form-data
description: Authenticate user and get JWT
parameters:
- description: Email address
in: formData
name: email
required: true
type: string
- description: Password
in: formData
name: password
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
additionalProperties: true
type: object
"400":
description: Bad Request
schema:
additionalProperties: true
type: object
summary: Login
tags:
- Auth
/auth/refresh:
post:
consumes:
- multipart/form-data
description: Get a new access token using a valid refresh token
parameters:
- description: Refresh token
in: formData
name: refresh_token
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
additionalProperties: true
type: object
"400":
description: Bad Request
schema:
additionalProperties: true
type: object
"401":
description: Unauthorized
schema:
additionalProperties: true
type: object
"500":
description: Internal Server Error
schema:
additionalProperties: true
type: object
summary: Refresh JWT
tags:
- Auth
/auth/register:
post:
consumes:
- multipart/form-data
description: Register a new user with email and password
parameters:
- description: Email address
in: formData
name: email
required: true
type: string
- description: Password (min 6 chars)
in: formData
name: password
required: true
type: string
produces:
- application/json
responses:
"201":
description: Created
schema:
additionalProperties: true
type: object
"400":
description: Bad Request
schema:
additionalProperties: true
type: object
summary: Register a new user
tags:
- Auth
/images:
get:
description: Returns a paginated list of images belonging to the authenticated
user.
parameters:
- description: Page number (default 1)
in: query
name: page
type: integer
- description: Items per page (default 20, max 100)
in: query
name: limit
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
additionalProperties: true
type: object
"401":
description: Unauthorized
schema:
additionalProperties: true
type: object
security:
- BearerAuth: []
summary: List images
tags:
- Images
post:
consumes:
- multipart/form-data
description: Uploads an image and registers it to the user.
parameters:
- description: Image file
in: formData
name: image
required: true
type: file
- description: Width
in: formData
name: w
type: integer
- description: Height
in: formData
name: h
type: integer
- description: Quality (1-100)
in: formData
name: q
type: integer
- description: Format (webp, avif, png, jpg)
in: formData
name: f
type: string
- description: Mode (e.g. cover)
in: formData
name: mode
type: string
produces:
- application/json
responses:
"201":
description: Created
schema:
additionalProperties: true
type: object
"400":
description: Bad Request
schema:
additionalProperties: true
type: object
"401":
description: Unauthorized
schema:
additionalProperties: true
type: object
security:
- BearerAuth: []
summary: Upload an image
tags:
- Images
/images/{id}:
get:
description: Returns a single image record owned by the authenticated user.
parameters:
- description: Image ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
additionalProperties: true
type: object
"401":
description: Unauthorized
schema:
additionalProperties: true
type: object
"404":
description: Not Found
schema:
additionalProperties: true
type: object
security:
- BearerAuth: []
summary: Get image by ID
tags:
- Images
/images/{id}/process:
get:
description: Processes an image (resize, crop, cover, format) using the generated
token.
parameters:
- description: Image ID
in: path
name: id
required: true
type: integer
- description: Global API Token
in: query
name: token
required: true
type: string
- description: Width
in: query
name: w
type: integer
- description: Height
in: query
name: h
type: integer
- description: Quality (1-100)
in: query
name: q
type: integer
- description: Format (webp, avif, png, jpg)
in: query
name: f
type: string
- description: Mode (e.g. cover)
in: query
name: mode
type: string
produces:
- image/jpeg
- image/png
- image/webp
- image/avif
responses:
"200":
description: OK
schema:
type: file
"401":
description: Unauthorized
schema:
additionalProperties: true
type: object
"404":
description: Not Found
schema:
additionalProperties: true
type: object
"500":
description: Internal Server Error
schema:
additionalProperties: true
type: object
summary: Process Image
tags:
- Images
securityDefinitions:
BearerAuth:
description: Type "Bearer <token>"
in: header
name: Authorization
type: apiKey
swagger: "2.0"