mirror of
https://github.com/immich-app/immich.git
synced 2025-12-25 17:24:58 +03:00
feat: endpoint versioning (#23858)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put } from '@nestjs/common';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Endpoint, HistoryBuilder } from 'src/decorators';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { SessionCreateDto, SessionCreateResponseDto, SessionResponseDto, SessionUpdateDto } from 'src/dtos/session.dto';
|
||||
import { ApiTag, Permission } from 'src/enum';
|
||||
@@ -14,9 +15,10 @@ export class SessionController {
|
||||
|
||||
@Post()
|
||||
@Authenticated({ permission: Permission.SessionCreate })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Create a session',
|
||||
description: 'Create a session as a child to the current session. This endpoint is used for casting.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
createSession(@Auth() auth: AuthDto, @Body() dto: SessionCreateDto): Promise<SessionCreateResponseDto> {
|
||||
return this.service.create(auth, dto);
|
||||
@@ -24,9 +26,10 @@ export class SessionController {
|
||||
|
||||
@Get()
|
||||
@Authenticated({ permission: Permission.SessionRead })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Retrieve sessions',
|
||||
description: 'Retrieve a list of sessions for the user.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
getSessions(@Auth() auth: AuthDto): Promise<SessionResponseDto[]> {
|
||||
return this.service.getAll(auth);
|
||||
@@ -35,9 +38,10 @@ export class SessionController {
|
||||
@Delete()
|
||||
@Authenticated({ permission: Permission.SessionDelete })
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Delete all sessions',
|
||||
description: 'Delete all sessions for the user. This will not delete the current session.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
deleteAllSessions(@Auth() auth: AuthDto): Promise<void> {
|
||||
return this.service.deleteAll(auth);
|
||||
@@ -45,9 +49,10 @@ export class SessionController {
|
||||
|
||||
@Put(':id')
|
||||
@Authenticated({ permission: Permission.SessionUpdate })
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Update a session',
|
||||
description: 'Update a specific session identified by id.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
updateSession(
|
||||
@Auth() auth: AuthDto,
|
||||
@@ -60,9 +65,10 @@ export class SessionController {
|
||||
@Delete(':id')
|
||||
@Authenticated({ permission: Permission.SessionDelete })
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Delete a session',
|
||||
description: 'Delete a specific session by id.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
deleteSession(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||
return this.service.delete(auth, id);
|
||||
@@ -71,9 +77,10 @@ export class SessionController {
|
||||
@Post(':id/lock')
|
||||
@Authenticated({ permission: Permission.SessionLock })
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@ApiOperation({
|
||||
@Endpoint({
|
||||
summary: 'Lock a session',
|
||||
description: 'Lock a specific session by id.',
|
||||
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
||||
})
|
||||
lockSession(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||
return this.service.lock(auth, id);
|
||||
|
||||
Reference in New Issue
Block a user