feat: add /api/meta endpoint

This commit is contained in:
Derrick Hammer 2024-03-26 00:46:11 -04:00
parent 73247a86fd
commit 1185a2a56e
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 30 additions and 0 deletions

View File

@ -350,6 +350,13 @@ func (a AccountAPI) updatePassword(c jape.Context) {
}
func (a AccountAPI) meta(c jape.Context) {
c.Encode(&MetaResponse{
Domain: a.config.Config().Core.Domain,
})
}
func (a *AccountAPI) Routes() (*httprouter.Router, error) {
loginAuthMw2fa := authMiddleware(middleware.AuthMiddlewareOptions{
Identity: a.identity,
@ -394,6 +401,7 @@ func (a *AccountAPI) Routes() (*httprouter.Router, error) {
"GET /api/auth/otp/generate": middleware.ApplyMiddlewares(a.otpGenerate, authMw, middleware.ProxyMiddleware),
"GET /api/account": middleware.ApplyMiddlewares(a.accountInfo, authMw, middleware.ProxyMiddleware),
"GET /api/upload-limit": middleware.ApplyMiddlewares(a.uploadLimit, middleware.ProxyMiddleware),
"GET /api/meta": middleware.ApplyMiddlewares(a.meta, middleware.ProxyMiddleware),
})
getHandler := func(c jape.Context) {

View File

@ -66,3 +66,7 @@ type UpdatePasswordRequest struct {
CurrentPassword string `json:"current_password"`
NewPassword string `json:"new_password"`
}
type MetaResponse struct {
Domain string `json:"domain"`
}

View File

@ -182,6 +182,17 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/UploadLimitResponse'
/api/meta:
get:
summary: Get metadata about the portal
responses:
'200':
description: Metadata retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/MetaResponse'
components:
schemas:
@ -317,3 +328,10 @@ components:
type: number
required:
- limit
MetaResponse:
type: object
required:
- domain
properties:
domain:
type: string