feat(server): add endpoint to get supported media types on the server (#3284)

* feat(server): add endpoint to get supported media types on the server

* api generation

* remove xmp format

* change dto

* openapi

* dev
This commit is contained in:
Alex
2023-07-15 20:24:46 -05:00
committed by GitHub
parent d5b96c0257
commit c254a04aec
16 changed files with 506 additions and 2 deletions

View File

@@ -3040,6 +3040,27 @@
]
}
},
"/server-info/media-types": {
"get": {
"operationId": "getSupportedMediaTypes",
"parameters": [],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ServerMediaTypesResponseDto"
}
}
}
}
},
"tags": [
"Server Info"
]
}
},
"/server-info/ping": {
"get": {
"operationId": "pingServer",
@@ -6118,6 +6139,34 @@
"diskAvailable"
]
},
"ServerMediaTypesResponseDto": {
"type": "object",
"properties": {
"video": {
"type": "array",
"items": {
"type": "string"
}
},
"image": {
"type": "array",
"items": {
"type": "string"
}
},
"sidecar": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"video",
"image",
"sidecar"
]
},
"ServerPingResponse": {
"type": "object",
"properties": {

View File

@@ -25,3 +25,9 @@ export class ServerStatsResponseDto {
})
usageByUser: UsageByUserDto[] = [];
}
export class ServerMediaTypesResponseDto {
video!: string[];
image!: string[];
sidecar!: string[];
}

View File

@@ -1,9 +1,15 @@
import { Inject, Injectable } from '@nestjs/common';
import { serverVersion } from '../domain.constant';
import { mimeTypes, serverVersion } from '../domain.constant';
import { asHumanReadable } from '../domain.util';
import { IStorageRepository, StorageCore, StorageFolder } from '../storage';
import { IUserRepository, UserStatsQueryResponse } from '../user';
import { ServerInfoResponseDto, ServerPingResponse, ServerStatsResponseDto, UsageByUserDto } from './response-dto';
import {
ServerInfoResponseDto,
ServerMediaTypesResponseDto,
ServerPingResponse,
ServerStatsResponseDto,
UsageByUserDto,
} from './response-dto';
@Injectable()
export class ServerInfoService {
@@ -60,4 +66,12 @@ export class ServerInfoService {
return serverStats;
}
getSupportedMediaTypes(): ServerMediaTypesResponseDto {
return {
video: [...Object.keys(mimeTypes.video)],
image: [...Object.keys(mimeTypes.image)],
sidecar: [...Object.keys(mimeTypes.sidecar)],
};
}
}

View File

@@ -1,6 +1,7 @@
import {
ServerInfoResponseDto,
ServerInfoService,
ServerMediaTypesResponseDto,
ServerPingResponse,
ServerStatsResponseDto,
ServerVersionReponseDto,
@@ -39,4 +40,10 @@ export class ServerInfoController {
getStats(): Promise<ServerStatsResponseDto> {
return this.service.getStats();
}
@PublicRoute()
@Get('/media-types')
getSupportedMediaTypes(): ServerMediaTypesResponseDto {
return this.service.getSupportedMediaTypes();
}
}