feat: complete testing, security, dynamic content, and devops overhaul
This commit is contained in:
1 parent
467532713c
commit
40ff169dc2
52 files changed
+3918
-104
No files matched your search
@@ -1,16 +1,25 @@
|
||||
import { Controller, Get, Patch, Put, Delete, Body, Param, UseGuards } from '@nestjs/common';
|
||||
import { Controller, Get, Patch, Put, Delete, Body, Param, UseGuards, HttpStatus } from '@nestjs/common';
|
||||
import { SettingsService } from './settings.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { ApiTags, ApiOperation, ApiBearerAuth, ApiResponse } from '@nestjs/swagger';
|
||||
import { ApiTags, ApiOperation, ApiBearerAuth, ApiResponse, ApiOkResponse, ApiUnauthorizedResponse } from '@nestjs/swagger';
|
||||
|
||||
@ApiTags('Settings')
|
||||
@ApiTags('Settings - تنظیمات متون پویا و واژهنامه علمی')
|
||||
@Controller('settings')
|
||||
export class SettingsController {
|
||||
constructor(private readonly settingsService: SettingsService) {}
|
||||
|
||||
@Get('ui-texts')
|
||||
@ApiOperation({ summary: 'دریافت تمامی متون رابط کاربری' })
|
||||
@ApiResponse({ status: 200, description: 'تمامی متون بازگردانده شدند' })
|
||||
@ApiOperation({ summary: 'دریافت تمامی متون و پیکربندیهای رابط کاربری' })
|
||||
@ApiOkResponse({
|
||||
description: 'یک آبجکت کلید-مقدار حاوی تمامی متون، شعارها و برچسبهای دکمهها',
|
||||
schema: {
|
||||
example: {
|
||||
hero_badge: "تخصص دارویی از آلمان",
|
||||
hero_title: "تخصص آلمانی در خدمت سلامت پتهای خانگی",
|
||||
hero_desc: "بیش از ۴۰ سال تجربه نوآورانه..."
|
||||
}
|
||||
}
|
||||
})
|
||||
getUiTexts() {
|
||||
return this.settingsService.getUiTexts();
|
||||
}
|
||||
@@ -18,15 +27,39 @@ export class SettingsController {
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Patch('ui-texts/:key')
|
||||
@ApiOperation({ summary: 'ویرایش متن یک کلید در رابط کاربری' })
|
||||
@ApiResponse({ status: 200, description: 'متن با موفقیت بهروزرسانی شد' })
|
||||
@ApiOperation({ summary: 'ویرایش متن یک کلید در رابط کاربری (نیازمند توکن)' })
|
||||
@ApiOkResponse({
|
||||
description: 'متن با موفقیت بهروزرسانی شد',
|
||||
schema: {
|
||||
example: {
|
||||
key: 'hero_badge',
|
||||
value: 'تخصص دارویی ممتاز از آلمان'
|
||||
}
|
||||
}
|
||||
})
|
||||
@ApiUnauthorizedResponse({
|
||||
description: 'عدم دسترسی به دلیل عدم احراز هویت',
|
||||
schema: { example: { success: false, message: 'Unauthorized', code: 'UNAUTHORIZED' } }
|
||||
})
|
||||
updateUiText(@Param('key') key: string, @Body('value') value: string) {
|
||||
return this.settingsService.updateUiText(key, value);
|
||||
}
|
||||
|
||||
@Get('scientific-terms')
|
||||
@ApiOperation({ summary: 'دریافت تمامی اصطلاحات علمی' })
|
||||
@ApiResponse({ status: 200, description: 'تمامی اصطلاحات علمی بازگردانده شدند' })
|
||||
@ApiOperation({ summary: 'دریافت تمامی اصطلاحات واژهنامه علمی' })
|
||||
@ApiOkResponse({
|
||||
description: 'لیست کامل اصطلاحات علمی به همراه تعاریف و شناسهها',
|
||||
schema: {
|
||||
example: [
|
||||
{
|
||||
key: 'green-mussel',
|
||||
term: 'صدف لبسبز (Perna Canaliculus)',
|
||||
definition: 'این صدف بومی سواحل بکر نیوزیلند است...',
|
||||
wikiId: 'general'
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
getScientificTerms() {
|
||||
return this.settingsService.getScientificTerms();
|
||||
}
|
||||
@@ -34,8 +67,22 @@ export class SettingsController {
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Put('scientific-terms/:key')
|
||||
@ApiOperation({ summary: 'ثبت یا ویرایش یک اصطلاح علمی' })
|
||||
@ApiResponse({ status: 200, description: 'اصطلاح علمی ثبت یا ویرایش شد' })
|
||||
@ApiOperation({ summary: 'ثبت یا ویرایش یک اصطلاح علمی (نیازمند توکن)' })
|
||||
@ApiOkResponse({
|
||||
description: 'اصطلاح علمی ثبت یا ویرایش شد',
|
||||
schema: {
|
||||
example: {
|
||||
key: 'green-mussel',
|
||||
term: 'صدف لبسبز اصل نیوزیلند',
|
||||
definition: 'این صدف بومی سواحل بکر نیوزیلند است...',
|
||||
wikiId: 'general'
|
||||
}
|
||||
}
|
||||
})
|
||||
@ApiUnauthorizedResponse({
|
||||
description: 'عدم دسترسی',
|
||||
schema: { example: { success: false, message: 'Unauthorized', code: 'UNAUTHORIZED' } }
|
||||
})
|
||||
upsertScientificTerm(@Param('key') key: string, @Body() data: any) {
|
||||
return this.settingsService.upsertScientificTerm(key, data);
|
||||
}
|
||||
@@ -43,8 +90,20 @@ export class SettingsController {
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Delete('scientific-terms/:key')
|
||||
@ApiOperation({ summary: 'حذف یک اصطلاح علمی' })
|
||||
@ApiResponse({ status: 200, description: 'اصطلاح علمی حذف شد' })
|
||||
@ApiOperation({ summary: 'حذف یک اصطلاح علمی (نیازمند توکن)' })
|
||||
@ApiOkResponse({
|
||||
description: 'اصطلاح علمی حذف شد',
|
||||
schema: {
|
||||
example: {
|
||||
success: true,
|
||||
message: 'Scientific term successfully deleted'
|
||||
}
|
||||
}
|
||||
})
|
||||
@ApiUnauthorizedResponse({
|
||||
description: 'عدم دسترسی',
|
||||
schema: { example: { success: false, message: 'Unauthorized', code: 'UNAUTHORIZED' } }
|
||||
})
|
||||
deleteScientificTerm(@Param('key') key: string) {
|
||||
return this.settingsService.deleteScientificTerm(key);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user