chore(workspace): eradicate all tsc errors and eslint warnings across frontend, admin, and backend
Deploy Canina / deploy (push) Failing after 29s

This commit is contained in:
parsa committed 2026-08-07 07:39:26 +03:30
1 parent 4659a7b1de
commit 9f11d8fb2d
98 files changed
+1272 -1009

No files matched your search

+23 -12
View File
@@ -1,23 +1,31 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { PrismaService } from '../prisma/prisma.service';
export class BlogQuery {
page?: number | string;
limit?: number | string;
search?: string;
}
@Injectable()
export class BlogsService {
constructor(private prisma: PrismaService) {}
async getBlogs(query: any) {
const { page = 1, limit = 10, search = '' } = query;
const skip = (Number(page) - 1) * Number(limit);
async getBlogs(query: BlogQuery = {}) {
const page = Number(query.page) || 1;
const limit = Number(query.limit) || 10;
const skip = (page - 1) * limit;
const where = search
? { title: { contains: search, mode: 'insensitive' as any } }
const where: Prisma.BlogWhereInput = query.search
? { title: { contains: query.search, mode: 'insensitive' } }
: {};
const [data, total] = await Promise.all([
this.prisma.blog.findMany({
where,
skip,
take: Number(limit),
take: limit,
orderBy: { createdAt: 'desc' },
include: { author: { select: { firstName: true, lastName: true } } },
}),
@@ -28,20 +36,23 @@ export class BlogsService {
data,
meta: {
total,
page: Number(page),
limit: Number(limit),
lastPage: Math.ceil(total / Number(limit)),
page,
limit,
lastPage: Math.ceil(total / limit),
},
};
}
async createBlog(data: any, authorId: string) {
async createBlog(
data: Prisma.BlogCreateWithoutAuthorInput,
authorId: string,
) {
return this.prisma.blog.create({
data: { ...data, authorId },
data: { ...data, author: { connect: { id: authorId } } },
});
}
async updateBlog(id: string, data: any) {
async updateBlog(id: string, data: Prisma.BlogUpdateInput) {
const blog = await this.prisma.blog.findUnique({ where: { id } });
if (!blog) throw new NotFoundException('Blog not found');
return this.prisma.blog.update({ where: { id }, data });