-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: added quote endpoint specification * refactor: scroll behavior * feat: added boilerplate for module * feat: add endpoint for creating quote * feat: added get random quote * feat: added get all quote * feat: added update/delete endpoint for quotes * docs: updated workspae * docs: added quote in doc webiste * chore(release): 1.10.0
- Loading branch information
Showing
26 changed files
with
888 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Quote | ||
|
||
Coming soon... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { IsOptional, IsString } from 'class-validator'; | ||
import { QuoteExpectionKeys } from 'src/enums'; | ||
import { PaginationQueryDto } from 'src/shared'; | ||
|
||
export class AllQuoteDto extends PaginationQueryDto { | ||
@IsOptional() | ||
@IsString({ message: QuoteExpectionKeys.AuthorNameShouldBeString }) | ||
author: string; | ||
|
||
@IsOptional() | ||
@IsString({ message: QuoteExpectionKeys.QuoteKeywordShouldBeString }) | ||
keywords: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './quote.dto'; | ||
export * from './all-quote.dto'; | ||
export * from './update-quote.dto'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { IsString } from 'class-validator'; | ||
import { QuoteExpectionKeys } from 'src/enums'; | ||
|
||
export class QuoteDto { | ||
@IsString({ message: QuoteExpectionKeys.AuthorNameShouldBeString }) | ||
author: string; | ||
|
||
@IsString({ message: QuoteExpectionKeys.QuoteShouldBeString }) | ||
quote: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { IsOptional, IsString } from 'class-validator'; | ||
import { QuoteExpectionKeys } from 'src/enums'; | ||
|
||
export class UpdateQuoteDto { | ||
@IsOptional() | ||
@IsString({ message: QuoteExpectionKeys.AuthorNameShouldBeString }) | ||
author: string; | ||
|
||
@IsOptional() | ||
@IsString({ message: QuoteExpectionKeys.QuoteShouldBeString }) | ||
quote: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './dtos'; | ||
export * from './quote.controller'; | ||
export * from './quote.module'; | ||
export * from './quote.service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { | ||
Body, | ||
Controller, | ||
Delete, | ||
Get, | ||
Param, | ||
Patch, | ||
Post, | ||
Query, | ||
UseGuards, | ||
} from '@nestjs/common'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
import { UserRole } from 'src/enums'; | ||
import { | ||
JwtGuard, | ||
MongooseValidatorService, | ||
Roles, | ||
RolesGuard, | ||
} from 'src/shared'; | ||
import { QuoteService } from './quote.service'; | ||
import { QuoteDto, AllQuoteDto, UpdateQuoteDto } from './dtos'; | ||
|
||
@ApiTags('quote') | ||
@Controller('quote') | ||
export class QuoteController { | ||
constructor( | ||
private quoteService: QuoteService, | ||
private readonly mongooseValidator: MongooseValidatorService, | ||
) {} | ||
|
||
@Get() | ||
getAllQuote(@Query() query: AllQuoteDto) { | ||
return this.quoteService.getAllQuote(query); | ||
} | ||
|
||
@Get('random') | ||
getRandomQuote() { | ||
return this.quoteService.getRandomQuote(); | ||
} | ||
|
||
@Post() | ||
@UseGuards(JwtGuard, RolesGuard) | ||
@Roles(UserRole.Admin) | ||
addQuote(@Body() body: QuoteDto) { | ||
return this.quoteService.addQuote(body); | ||
} | ||
|
||
@Patch('id/:id') | ||
@UseGuards(JwtGuard, RolesGuard) | ||
@Roles(UserRole.Admin) | ||
updateQuote(@Param('id') id: string, @Body() body: UpdateQuoteDto) { | ||
this.mongooseValidator.isValidObjectId(id); | ||
return this.quoteService.updateQuoteById(id, body); | ||
} | ||
|
||
@Delete('id/:id') | ||
@UseGuards(JwtGuard, RolesGuard) | ||
@Roles(UserRole.Admin) | ||
deleteQuote(@Param('id') id: string) { | ||
this.mongooseValidator.isValidObjectId(id); | ||
return this.quoteService.deleteQuoteById(id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { MongooseModule } from '@nestjs/mongoose'; | ||
import { ConfigModule } from '@nestjs/config'; | ||
import { JwtModule } from '@nestjs/jwt'; | ||
import { Quote, QuoteSchema, User, UserSchema } from 'src/schemas'; | ||
import { QuoteService } from './quote.service'; | ||
import { QuoteController } from './quote.controller'; | ||
import { ExceptionService, MongooseValidatorService } from 'src/shared'; | ||
|
||
@Module({ | ||
imports: [ | ||
ConfigModule.forRoot(), | ||
MongooseModule.forFeature([ | ||
{ name: Quote.name, schema: QuoteSchema }, | ||
{ name: User.name, schema: UserSchema }, | ||
]), | ||
JwtModule.register({ | ||
secret: `${process.env.JWT_SECRET}`, | ||
signOptions: { expiresIn: `${process.env.JWT_EXPIRES_IN || '1'}h` }, | ||
}), | ||
], | ||
providers: [QuoteService, ExceptionService, MongooseValidatorService], | ||
controllers: [QuoteController], | ||
}) | ||
export class QuoteModule {} |
Oops, something went wrong.