-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* KYC save data * KYC save his data * Module to check KYC field * Module to check KYC field * Add Waiting List module * Module for waiting * fix tests * Finished Waiting list * Finished contact form * Finish module for blog --------- Co-authored-by: Abhishek Shandilya <[email protected]>
- Loading branch information
1 parent
fd1b50f
commit 4e59310
Showing
10 changed files
with
9,731 additions
and
13,268 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,41 @@ | ||
import { | ||
Body, | ||
Controller, | ||
Get, | ||
Param, | ||
Post | ||
} from '@nestjs/common'; | ||
import { ApiOperation, ApiTags } from '@nestjs/swagger'; | ||
import { _403, _404, _409 } from '../../common/constants/errors'; | ||
import { Public } from 'src/common/decorators/public.decorator'; | ||
import { CreateBlogDto } from './dto/blog.dto'; | ||
import { BlogService } from './blog.service'; | ||
import slugify from 'slugify'; | ||
|
||
@ApiTags('Blogs') | ||
@Controller('blogs') | ||
export class BlogController { | ||
constructor(private readonly blogService: BlogService) { } | ||
|
||
@Post() | ||
@Public() | ||
@ApiOperation({ summary: 'Save new blog information' }) | ||
async add(@Body() blogDto: CreateBlogDto) { | ||
return await this.blogService.add(blogDto); | ||
} | ||
|
||
@Get() | ||
@Public() | ||
@ApiOperation({ summary: 'Get all blog saved' }) | ||
async getAll() { | ||
return await this.blogService.getAll(); | ||
} | ||
|
||
@Get(':slug') | ||
@Public() | ||
@ApiOperation({ summary: 'Get details for this one' }) | ||
async getBySlug(@Param('slug') slug: string) { | ||
return await this.blogService.getBlogDetailsWithComments(slug); | ||
} | ||
|
||
} |
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,15 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { Blog } from './entities/blog.entity'; | ||
import { BlogController } from './blog.controller'; | ||
import { BlogService } from './blog.service'; | ||
|
||
@Module({ | ||
imports: [ | ||
TypeOrmModule.forFeature([Blog]), | ||
], | ||
controllers: [BlogController], | ||
providers: [BlogService], | ||
exports: [BlogService], | ||
}) | ||
export class BlogModule { } |
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,51 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Not, Repository } from 'typeorm'; | ||
import { _404 } from '../../common/constants/errors'; | ||
import { MailService } from '../mail/mail.service'; | ||
import { Blog } from './entities/blog.entity'; | ||
import { CreateBlogDto } from './dto/blog.dto'; | ||
import Slugify from 'slugify'; | ||
import slugify from 'slugify'; | ||
|
||
@Injectable() | ||
export class BlogService { | ||
constructor( | ||
@InjectRepository(Blog) | ||
private blogRepository: Repository<Blog>, | ||
|
||
) { } | ||
|
||
async add(blog: CreateBlogDto): Promise<Blog> { | ||
|
||
const newBlog = this.blogRepository.create({ | ||
title: blog.title, | ||
slug: slugify(blog.title, { lower: true }), | ||
content: blog.content, | ||
quote: blog.quote, | ||
tags: blog.tags, | ||
cover: blog.cover | ||
}); | ||
|
||
return this.blogRepository.save(newBlog); | ||
|
||
} | ||
|
||
async getAll(): Promise<Blog[]> { | ||
return await this.blogRepository.find() | ||
} | ||
|
||
async getBlogDetailsWithComments(slug: string): Promise<any> { | ||
const blog = await this.blogRepository.findOne({ where: { slug }, relations: ['comments'] }); | ||
|
||
const last = await this.blogRepository.find({ | ||
where: { slug: Not(slug) }, | ||
take: 3, // Récupère les trois derniers blogs | ||
order: { | ||
createdAt: 'DESC', // Trie par date de création décroissante | ||
}, | ||
}); | ||
|
||
return { blog, last } | ||
} | ||
} |
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,27 @@ | ||
import { | ||
IsArray, | ||
IsNotEmpty, | ||
IsString | ||
} from 'class-validator'; | ||
|
||
export class CreateBlogDto { | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
title: string; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
cover: string; | ||
|
||
@IsString() | ||
quote?: string; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
content: string; | ||
|
||
@IsArray() | ||
@IsString({ each: true }) | ||
tags?: 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,30 @@ | ||
import { Comment } from 'src/modules/comment/entities/comment.entity'; | ||
import { BaseEntity } from '../../../db/base-entity'; | ||
import { Entity, Column, ManyToMany, JoinTable } from 'typeorm'; | ||
|
||
@Entity() | ||
export class Blog extends BaseEntity { | ||
|
||
@Column({ nullable: false }) | ||
title: string; | ||
|
||
@Column({ nullable: false, unique: true }) | ||
slug: string; | ||
|
||
@Column({ nullable: true }) | ||
cover: string; | ||
|
||
@Column({ nullable: true }) | ||
quote?: string; | ||
|
||
@Column({ nullable: false }) | ||
content: string; | ||
|
||
@Column('text', { array: true, default: '{}' }) | ||
tags?: string[]; | ||
|
||
@ManyToMany(() => Comment, comment => comment.blog) | ||
@JoinTable() | ||
comments?: Comment[]; | ||
|
||
} |
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,19 @@ | ||
import { Blog } from 'src/modules/blog/entities/blog.entity'; | ||
import { BaseEntity } from '../../../db/base-entity'; | ||
import { Entity, Column, ManyToOne } from 'typeorm'; | ||
|
||
@Entity() | ||
export class Comment extends BaseEntity { | ||
|
||
@Column({ nullable: false }) | ||
fullname: string; | ||
|
||
@Column({ nullable: true }) | ||
email?: string; | ||
|
||
@Column({ nullable: false }) | ||
comment: string; | ||
|
||
@ManyToOne(() => Blog, blog => blog.comments) | ||
blog: Blog; | ||
} |
Oops, something went wrong.