handlers

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AuthLoginAttemptsTotal counts login attempts by result.
	AuthLoginAttemptsTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "auth_login_attempts_total",
			Help: "Total number of login attempts.",
		},
		[]string{"result"},
	)

	// AuthTokenRefreshTotal counts token refresh attempts by result.
	AuthTokenRefreshTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "auth_token_refresh_total",
			Help: "Total number of token refresh attempts.",
		},
		[]string{"result"},
	)

	// Auth2FAAttemptsTotal counts 2FA verification attempts by result.
	Auth2FAAttemptsTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "auth_2fa_attempts_total",
			Help: "Total number of 2FA verification attempts.",
		},
		[]string{"result"},
	)
)

Functions

func RegisterCurrencyRoutes

func RegisterCurrencyRoutes(api *gin.RouterGroup, h *APIHandler)

RegisterCurrencyRoutes registers the currency status endpoint

func RegisterFlightUtilRoutes

func RegisterFlightUtilRoutes(api *gin.RouterGroup, h *APIHandler)

RegisterFlightUtilRoutes registers utility routes for flights

func RegisterReportsRoutes

func RegisterReportsRoutes(api *gin.RouterGroup, h *APIHandler, db *sql.DB)

RegisterReportsRoutes kept for backward compat; routes now via generated interface.

Types

type APIHandler

type APIHandler struct {
	// contains filtered or unexported fields
}

APIHandler implements the generated.ServerInterface from OpenAPI spec

func NewAPIHandler

func NewAPIHandler(
	authService *service.AuthService,
	licenseService *service.LicenseService,
	flightService *service.FlightService,
	credentialService *service.CredentialService,
	aircraftService *service.AircraftService,
	notificationService *service.NotificationService,
	twoFactorService *service.TwoFactorService,
	contactService *service.ContactService,
	classRatingService *service.ClassRatingService,
	currencyService *currency.Service,
	webauthnService *service.WebAuthnService,
	jwtManager *jwt.Manager,
	flightCrewRepo repository.FlightCrewRepository,
	adminEmail string,
) *APIHandler

NewAPIHandler creates a new unified API handler that implements the OpenAPI ServerInterface

func (*APIHandler) ChangePassword

func (h *APIHandler) ChangePassword(c *gin.Context)

ChangePassword implements POST /auth/change-password (POST /auth/change-password)

func (*APIHandler) CleanupTokens

func (h *APIHandler) CleanupTokens(c *gin.Context)

CleanupTokens implements POST /admin/maintenance/cleanup-tokens

func (*APIHandler) ConfirmImport

func (h *APIHandler) ConfirmImport(c *gin.Context)

ConfirmImport implements POST /imports/confirm

func (*APIHandler) CreateAircraft

func (h *APIHandler) CreateAircraft(c *gin.Context)

CreateAircraft implements POST /aircraft (POST /aircraft)

func (*APIHandler) CreateAnnouncement

func (h *APIHandler) CreateAnnouncement(c *gin.Context)

CreateAnnouncement implements POST /admin/announcements

func (*APIHandler) CreateClassRating

func (h *APIHandler) CreateClassRating(c *gin.Context, licenseId generated.LicenseId)

func (*APIHandler) CreateContact

func (h *APIHandler) CreateContact(c *gin.Context)

CreateContact handles POST /contacts

func (*APIHandler) CreateCredential

func (h *APIHandler) CreateCredential(c *gin.Context)

CreateCredential implements POST /credentials

func (*APIHandler) CreateFlight

func (h *APIHandler) CreateFlight(c *gin.Context)

CreateFlight implements POST /flights (POST /flights)

func (*APIHandler) CreateLicense

func (h *APIHandler) CreateLicense(c *gin.Context)

CreateLicense implements POST /licenses (POST /licenses)

func (*APIHandler) DeleteAircraft

func (h *APIHandler) DeleteAircraft(c *gin.Context, aircraftId generated.AircraftId)

DeleteAircraft implements DELETE /aircraft/{aircraftId} (DELETE /aircraft/{aircraftId})

func (*APIHandler) DeleteAllFlights

func (h *APIHandler) DeleteAllFlights(c *gin.Context)

DeleteAllFlights implements DELETE /flights/delete-all

func (*APIHandler) DeleteAllUserData

func (h *APIHandler) DeleteAllUserData(c *gin.Context)

DeleteAllUserData implements DELETE /users/me/data

func (*APIHandler) DeleteAnnouncement

func (h *APIHandler) DeleteAnnouncement(c *gin.Context, announcementId openapi_types.UUID)

DeleteAnnouncement implements DELETE /admin/announcements/{announcementId}

func (*APIHandler) DeleteClassRating

func (h *APIHandler) DeleteClassRating(c *gin.Context, licenseId generated.LicenseId, ratingId openapi_types.UUID)

func (*APIHandler) DeleteContact

func (h *APIHandler) DeleteContact(c *gin.Context, contactId openapi_types.UUID)

DeleteContact handles DELETE /contacts/{contactId}

func (*APIHandler) DeleteCredential

func (h *APIHandler) DeleteCredential(c *gin.Context, credentialId generated.CredentialId)

DeleteCredential implements DELETE /credentials/{credentialId}

func (*APIHandler) DeleteCurrentUser

func (h *APIHandler) DeleteCurrentUser(c *gin.Context)

DeleteCurrentUser implements DELETE /users/me (DELETE /users/me)

func (*APIHandler) DeleteFlight

func (h *APIHandler) DeleteFlight(c *gin.Context, flightId generated.FlightId)

DeleteFlight implements DELETE /flights/{flightId} (DELETE /flights/{flightId})

func (*APIHandler) DeleteLicense

func (h *APIHandler) DeleteLicense(c *gin.Context, licenseId generated.LicenseId)

DeleteLicense implements DELETE /licenses/{licenseId} (DELETE /licenses/{licenseId})

func (*APIHandler) DeleteWebauthnCredential added in v1.2.0

func (h *APIHandler) DeleteWebauthnCredential(c *gin.Context, credentialId openapi_types.UUID)

DeleteWebauthnCredential implements DELETE /auth/webauthn/credentials/{credentialId}

func (*APIHandler) Disable2FA

func (h *APIHandler) Disable2FA(c *gin.Context)

Disable2FA implements POST /auth/2fa/disable

func (*APIHandler) DisableUser

func (h *APIHandler) DisableUser(c *gin.Context, userId openapi_types.UUID)

DisableUser implements POST /admin/users/{userId}/disable

func (*APIHandler) EnableUser

func (h *APIHandler) EnableUser(c *gin.Context, userId openapi_types.UUID)

EnableUser implements POST /admin/users/{userId}/enable

func (*APIHandler) ExportDataJSON

func (h *APIHandler) ExportDataJSON(c *gin.Context)

ExportDataJSON implements GET /exports/json

func (*APIHandler) ExportFlightsCSV

func (h *APIHandler) ExportFlightsCSV(c *gin.Context, params generated.ExportFlightsCSVParams)

ExportFlightsCSV implements GET /exports/csv

func (*APIHandler) ExportFlightsPDF

func (h *APIHandler) ExportFlightsPDF(c *gin.Context, params generated.ExportFlightsPDFParams)

ExportFlightsPDF implements GET /exports/pdf

func (*APIHandler) GetAdminConfig

func (h *APIHandler) GetAdminConfig(c *gin.Context)

GetAdminConfig implements GET /admin/config

func (*APIHandler) GetAdminStats

func (h *APIHandler) GetAdminStats(c *gin.Context)

GetAdminStats implements GET /admin/stats

func (*APIHandler) GetAircraft

func (h *APIHandler) GetAircraft(c *gin.Context, aircraftId generated.AircraftId)

GetAircraft implements GET /aircraft/{aircraftId} (GET /aircraft/{aircraftId})

func (*APIHandler) GetAirport

func (h *APIHandler) GetAirport(c *gin.Context, icaoCode string)

GetAirport implements GET /airports/{icaoCode}

func (*APIHandler) GetAirportStats

func (h *APIHandler) GetAirportStats(c *gin.Context)

GetAirportStats implements GET /reports/airport-stats

func (*APIHandler) GetAllCurrencyStatus

func (h *APIHandler) GetAllCurrencyStatus(c *gin.Context)

GetAllCurrencyStatus returns currency status for all class ratings across all licenses

func (*APIHandler) GetAnnouncements

func (h *APIHandler) GetAnnouncements(c *gin.Context)

GetAnnouncements implements GET /announcements Returns active system announcements + auto-generated user hints

func (*APIHandler) GetContact

func (h *APIHandler) GetContact(c *gin.Context, contactId openapi_types.UUID)

GetContact handles GET /contacts/{contactId}

func (*APIHandler) GetCredential

func (h *APIHandler) GetCredential(c *gin.Context, credentialId generated.CredentialId)

GetCredential implements GET /credentials/{credentialId}

func (*APIHandler) GetCurrentUser

func (h *APIHandler) GetCurrentUser(c *gin.Context)

GetCurrentUser implements GET /users/me (GET /users/me)

func (*APIHandler) GetFlight

func (h *APIHandler) GetFlight(c *gin.Context, flightId generated.FlightId)

GetFlight implements GET /flights/{flightId} (GET /flights/{flightId})

func (*APIHandler) GetFlightRoutes

func (h *APIHandler) GetFlightRoutes(c *gin.Context)

GetFlightRoutes implements GET /reports/routes

func (*APIHandler) GetFlightTrends

func (h *APIHandler) GetFlightTrends(c *gin.Context, params generated.GetFlightTrendsParams)

GetFlightTrends implements GET /reports/trends

func (*APIHandler) GetImport

func (h *APIHandler) GetImport(c *gin.Context, importId generated.ImportId)

GetImport implements GET /imports/{importId}

func (*APIHandler) GetLicense

func (h *APIHandler) GetLicense(c *gin.Context, licenseId generated.LicenseId)

GetLicense implements GET /licenses/{licenseId} (GET /licenses/{licenseId})

func (*APIHandler) GetLicenseCurrency

func (h *APIHandler) GetLicenseCurrency(c *gin.Context, licenseId generated.LicenseId)

GetLicenseCurrency implements GET /licenses/{licenseId}/currency (GET /licenses/{licenseId}/currency)

func (*APIHandler) GetLicenseStatistics

func (h *APIHandler) GetLicenseStatistics(c *gin.Context, licenseId generated.LicenseId, params generated.GetLicenseStatisticsParams)

GetLicenseStatistics implements GET /licenses/{licenseId}/statistics (GET /licenses/{licenseId}/statistics)

func (*APIHandler) GetMyStatistics

func (h *APIHandler) GetMyStatistics(c *gin.Context, params generated.GetMyStatisticsParams)

GetMyStatistics implements GET /users/me/statistics

func (*APIHandler) GetNotificationHistory

func (h *APIHandler) GetNotificationHistory(c *gin.Context, params generated.GetNotificationHistoryParams)

GetNotificationHistory implements GET /users/me/notifications/history

func (*APIHandler) GetNotificationPreferences

func (h *APIHandler) GetNotificationPreferences(c *gin.Context)

GetNotificationPreferences implements GET /users/me/notifications

func (*APIHandler) GetStatsByClass

func (h *APIHandler) GetStatsByClass(c *gin.Context, params generated.GetStatsByClassParams)

GetStatsByClass implements GET /reports/stats-by-class

func (*APIHandler) ListAdminAuditLog

func (h *APIHandler) ListAdminAuditLog(c *gin.Context, params generated.ListAdminAuditLogParams)

ListAdminAuditLog implements GET /admin/audit-log

func (*APIHandler) ListAdminUsers

func (h *APIHandler) ListAdminUsers(c *gin.Context, params generated.ListAdminUsersParams)

ListAdminUsers implements GET /admin/users

func (*APIHandler) ListAircraft

func (h *APIHandler) ListAircraft(c *gin.Context, params generated.ListAircraftParams)

ListAircraft implements GET /aircraft (GET /aircraft)

func (*APIHandler) ListClassRatings

func (h *APIHandler) ListClassRatings(c *gin.Context, licenseId generated.LicenseId)

func (*APIHandler) ListContacts

func (h *APIHandler) ListContacts(c *gin.Context)

ListContacts handles GET /contacts

func (*APIHandler) ListCredentials

func (h *APIHandler) ListCredentials(c *gin.Context)

ListCredentials implements GET /credentials

func (*APIHandler) ListFlights

func (h *APIHandler) ListFlights(c *gin.Context, params generated.ListFlightsParams)

ListFlights implements GET /flights (GET /flights)

func (*APIHandler) ListImports

func (h *APIHandler) ListImports(c *gin.Context, params generated.ListImportsParams)

ListImports implements GET /imports

func (*APIHandler) ListLicenses

func (h *APIHandler) ListLicenses(c *gin.Context)

ListLicenses implements GET /licenses (GET /licenses)

func (*APIHandler) ListWebauthnCredentials added in v1.2.0

func (h *APIHandler) ListWebauthnCredentials(c *gin.Context)

ListWebauthnCredentials implements GET /auth/webauthn/credentials

func (*APIHandler) Login2FA

func (h *APIHandler) Login2FA(c *gin.Context)

Login2FA implements POST /auth/2fa/login

func (*APIHandler) LoginUser

func (h *APIHandler) LoginUser(c *gin.Context)

LoginUser implements POST /auth/login (POST /auth/login)

func (*APIHandler) PreviewImport

func (h *APIHandler) PreviewImport(c *gin.Context)

PreviewImport implements POST /imports/preview

func (*APIHandler) RecalculateFlights

func (h *APIHandler) RecalculateFlights(c *gin.Context)

RecalculateFlights recalculates all auto-computed fields for every flight

func (*APIHandler) RefreshToken

func (h *APIHandler) RefreshToken(c *gin.Context)

RefreshToken implements POST /auth/refresh (POST /auth/refresh)

func (*APIHandler) RegisterUser

func (h *APIHandler) RegisterUser(c *gin.Context)

RegisterUser implements POST /auth/register (POST /auth/register)

func (*APIHandler) RequestPasswordReset added in v1.1.0

func (h *APIHandler) RequestPasswordReset(c *gin.Context)

RequestPasswordReset implements POST /auth/password-reset-request (POST /auth/password-reset-request)

func (*APIHandler) ResetPassword added in v1.1.0

func (h *APIHandler) ResetPassword(c *gin.Context)

ResetPassword implements POST /auth/password-reset (POST /auth/password-reset)

func (*APIHandler) ResetUser2fa

func (h *APIHandler) ResetUser2fa(c *gin.Context, userId openapi_types.UUID)

ResetUser2fa implements POST /admin/users/{userId}/reset-2fa

func (*APIHandler) SearchAirports

func (h *APIHandler) SearchAirports(c *gin.Context, params generated.SearchAirportsParams)

SearchAirports implements GET /airports/search

func (*APIHandler) SearchContacts

func (h *APIHandler) SearchContacts(c *gin.Context, params generated.SearchContactsParams)

SearchContacts handles GET /contacts/search

func (*APIHandler) SetCORSOrigins

func (h *APIHandler) SetCORSOrigins(origins []string)

SetCORSOrigins stores the configured CORS origins for the config endpoint

func (*APIHandler) SetDB

func (h *APIHandler) SetDB(db *sql.DB)

SetDB stores the database reference for direct queries in map handlers

func (*APIHandler) SetEmailSender

func (h *APIHandler) SetEmailSender(sender *email.Sender)

SetEmailSender stores the email sender for admin SMTP test

func (*APIHandler) SetStartedAt

func (h *APIHandler) SetStartedAt(t time.Time)

SetStartedAt records the server start time for uptime calculation

func (*APIHandler) Setup2FA

func (h *APIHandler) Setup2FA(c *gin.Context)

Setup2FA implements POST /auth/2fa/setup

func (*APIHandler) SmtpTest

func (h *APIHandler) SmtpTest(c *gin.Context)

SmtpTest implements POST /admin/maintenance/smtp-test

func (*APIHandler) TriggerNotifications

func (h *APIHandler) TriggerNotifications(c *gin.Context)

TriggerNotifications implements POST /admin/maintenance/trigger-notifications

func (*APIHandler) UnlockUser

func (h *APIHandler) UnlockUser(c *gin.Context, userId openapi_types.UUID)

UnlockUser implements POST /admin/users/{userId}/unlock

func (*APIHandler) UpdateAircraft

func (h *APIHandler) UpdateAircraft(c *gin.Context, aircraftId generated.AircraftId)

UpdateAircraft implements PATCH /aircraft/{aircraftId} (PATCH /aircraft/{aircraftId})

func (*APIHandler) UpdateClassRating

func (h *APIHandler) UpdateClassRating(c *gin.Context, licenseId generated.LicenseId, ratingId openapi_types.UUID)

func (*APIHandler) UpdateContact

func (h *APIHandler) UpdateContact(c *gin.Context, contactId openapi_types.UUID)

UpdateContact handles PUT /contacts/{contactId}

func (*APIHandler) UpdateCredential

func (h *APIHandler) UpdateCredential(c *gin.Context, credentialId generated.CredentialId)

UpdateCredential implements PATCH /credentials/{credentialId}

func (*APIHandler) UpdateCurrentUser

func (h *APIHandler) UpdateCurrentUser(c *gin.Context)

UpdateCurrentUser implements PATCH /users/me (PATCH /users/me)

func (*APIHandler) UpdateFlight

func (h *APIHandler) UpdateFlight(c *gin.Context, flightId generated.FlightId)

UpdateFlight implements PUT /flights/{flightId} (PUT /flights/{flightId})

func (*APIHandler) UpdateLicense

func (h *APIHandler) UpdateLicense(c *gin.Context, licenseId generated.LicenseId)

UpdateLicense implements PATCH /licenses/{licenseId} (PATCH /licenses/{licenseId})

func (*APIHandler) UpdateNotificationPreferences

func (h *APIHandler) UpdateNotificationPreferences(c *gin.Context)

UpdateNotificationPreferences implements PATCH /users/me/notifications

func (*APIHandler) UploadImportFile

func (h *APIHandler) UploadImportFile(c *gin.Context)

UploadImportFile implements POST /imports/upload

func (*APIHandler) Verify2FA

func (h *APIHandler) Verify2FA(c *gin.Context)

Verify2FA implements POST /auth/2fa/verify

func (*APIHandler) WebauthnLoginOptions added in v1.2.0

func (h *APIHandler) WebauthnLoginOptions(c *gin.Context)

WebauthnLoginOptions implements POST /auth/webauthn/login/options

func (*APIHandler) WebauthnLoginVerify added in v1.2.0

func (h *APIHandler) WebauthnLoginVerify(c *gin.Context)

WebauthnLoginVerify implements POST /auth/webauthn/login/verify

func (*APIHandler) WebauthnRegisterOptions added in v1.2.0

func (h *APIHandler) WebauthnRegisterOptions(c *gin.Context)

WebauthnRegisterOptions implements POST /auth/webauthn/register/options

func (*APIHandler) WebauthnRegisterVerify added in v1.2.0

func (h *APIHandler) WebauthnRegisterVerify(c *gin.Context)

WebauthnRegisterVerify implements POST /auth/webauthn/register/verify

type AircraftBreakdown

type AircraftBreakdown struct {
	AircraftType string `json:"aircraftType"`
	TotalFlights int    `json:"totalFlights"`
	TotalMinutes int    `json:"totalMinutes"`
}

AircraftBreakdown represents flight statistics per aircraft type

type MonthlyTrend

type MonthlyTrend struct {
	Month         string `json:"month"`
	TotalFlights  int    `json:"totalFlights"`
	TotalMinutes  int    `json:"totalMinutes"`
	PICMinutes    int    `json:"picMinutes"`
	DualMinutes   int    `json:"dualMinutes"`
	NightMinutes  int    `json:"nightMinutes"`
	IFRMinutes    int    `json:"ifrMinutes"`
	LandingsDay   int    `json:"landingsDay"`
	LandingsNight int    `json:"landingsNight"`
}

MonthlyTrend represents flight statistics for a single month

type TrendsResponse

type TrendsResponse struct {
	Monthly        []MonthlyTrend      `json:"monthly"`
	ByAircraftType []AircraftBreakdown `json:"byAircraftType"`
}

TrendsResponse contains all reporting data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL