mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat: better endpoint descriptions (#20439)
This commit is contained in:
parent
d5a01c0310
commit
749f999f2a
34 changed files with 1918 additions and 428 deletions
|
|
@ -10,7 +10,7 @@ import { Reflector } from '@nestjs/core';
|
|||
import { ApiBearerAuth, ApiCookieAuth, ApiExtension, ApiOkResponse, ApiQuery, ApiSecurity } from '@nestjs/swagger';
|
||||
import { Request } from 'express';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { ImmichQuery, MetadataKey, Permission } from 'src/enum';
|
||||
import { ApiCustomExtension, ImmichQuery, MetadataKey, Permission } from 'src/enum';
|
||||
import { LoggingRepository } from 'src/repositories/logging.repository';
|
||||
import { AuthService, LoginDetails } from 'src/services/auth.service';
|
||||
import { UAParser } from 'ua-parser-js';
|
||||
|
|
@ -19,16 +19,20 @@ type AdminRoute = { admin?: true };
|
|||
type SharedLinkRoute = { sharedLink?: true };
|
||||
type AuthenticatedOptions = { permission?: Permission } & (AdminRoute | SharedLinkRoute);
|
||||
|
||||
export const Authenticated = (options?: AuthenticatedOptions): MethodDecorator => {
|
||||
export const Authenticated = (options: AuthenticatedOptions = {}): MethodDecorator => {
|
||||
const decorators: MethodDecorator[] = [
|
||||
ApiBearerAuth(),
|
||||
ApiCookieAuth(),
|
||||
ApiSecurity(MetadataKey.ApiKeySecurity),
|
||||
SetMetadata(MetadataKey.AuthRoute, options || {}),
|
||||
SetMetadata(MetadataKey.AuthRoute, options),
|
||||
];
|
||||
|
||||
if ((options as AdminRoute).admin) {
|
||||
decorators.push(ApiExtension(ApiCustomExtension.AdminOnly, true));
|
||||
}
|
||||
|
||||
if (options?.permission) {
|
||||
decorators.push(ApiExtension('x-immich-permission', options.permission));
|
||||
decorators.push(ApiExtension(ApiCustomExtension.Permission, options.permission ?? Permission.All));
|
||||
}
|
||||
|
||||
if ((options as SharedLinkRoute)?.sharedLink) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue