Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion apps/backend/src/story/story.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ export class StoryController {
@Param('anthologyId', ParseIntPipe) anthologyId: number,
@Param('storyId', ParseIntPipe) storyId: number,
): Promise<Story> {
return this.storyService.findOne(storyId);
const story = await this.storyService.findOne(storyId);

if (!story) {
throw new NotFoundException(`Story with ID ${storyId} not found`);
}

return story;
}

@Delete('/:storyId')
Expand All @@ -54,6 +60,23 @@ export class StoryController {
return this.storyService.remove(storyId);
}

@Delete('/library/anthology/story/:storyId')
@ApiOperation({ summary: 'Delete a story from a specific anthology' })
@ApiResponse({
status: 200,
description: 'Story deleted successfully',
})
@ApiResponse({
status: 404,
description: 'Story not found',
})
async removeStoryFromAnthology(
@Param('storyId', ParseIntPipe) storyId: number,
): Promise<{ message: string }> {
await this.storyService.remove(storyId);
return { message: 'Story deleted successfully' };
}

@Post('/library/anthology/:anthologyId/story')
@HttpCode(HttpStatus.CREATED)
@ApiOperation({ summary: 'Create a new story in a specific anthology' })
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "esnext",
"types": ["node"],
"emitDecoratorMetadata": true,
"target": "es2021"
"target": "es2021",
"strictPropertyInitialization": false
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
}
],
"compilerOptions": {
"esModuleInterop": true
"esModuleInterop": true,
"baseUrl": "."
}
}