refactor: Standardize type naming conventions and file casing for course and category types.
This commit is contained in:
parent
6bbbde062a
commit
057f640272
6 changed files with 7 additions and 26 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { Get, Body, Post, Route, Tags, SuccessResponse, Response, Delete, Controller, Security, Request, Put, Path } from 'tsoa';
|
||||
import { ValidationError } from '../middleware/errorHandler';
|
||||
import { CategoryService } from '../services/categories.service';
|
||||
import { createCategory, createCategoryResponse, deleteCategoryResponse, updateCategory, updateCategoryResponse, listCategoriesResponse } from '../types/Categories.type';
|
||||
import { createCategory, createCategoryResponse, deleteCategoryResponse, updateCategory, updateCategoryResponse, ListCategoriesResponse } from '../types/categories.type';
|
||||
|
||||
@Route('api/categories')
|
||||
@Tags('Categories')
|
||||
|
|
@ -11,7 +11,7 @@ export class CategoriesController {
|
|||
@Get()
|
||||
@SuccessResponse('200', 'Categories fetched successfully')
|
||||
@Response('401', 'Invalid or expired token')
|
||||
public async listCategories(): Promise<listCategoriesResponse> {
|
||||
public async listCategories(): Promise<ListCategoriesResponse> {
|
||||
return await this.categoryService.listCategories();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Get, Body, Post, Route, Tags, SuccessResponse, Response, Delete, Controller, Security, Request, Put, Path } from 'tsoa';
|
||||
import { ValidationError } from '../middleware/errorHandler';
|
||||
import { listCourseResponse } from '../types/Courses.types';
|
||||
import { listCourseResponse } from '../types/courses.types';
|
||||
import { CoursesService } from '../services/courses.service';
|
||||
|
||||
@Route('api/courses')
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ import { Prisma } from '@prisma/client';
|
|||
import { config } from '../config';
|
||||
import { logger } from '../config/logger';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { createCategory, createCategoryResponse, deleteCategoryResponse, updateCategory, updateCategoryResponse, listCategoriesResponse, Category } from '../types/Categories.type';
|
||||
import { createCategory, createCategoryResponse, deleteCategoryResponse, updateCategory, updateCategoryResponse, ListCategoriesResponse, Category } from '../types/categories.type';
|
||||
import { UnauthorizedError, ValidationError, ForbiddenError } from '../middleware/errorHandler';
|
||||
|
||||
export class CategoryService {
|
||||
async listCategories(): Promise<listCategoriesResponse> {
|
||||
async listCategories(): Promise<ListCategoriesResponse> {
|
||||
try {
|
||||
const categories = await prisma.category.findMany();
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { prisma } from '../config/database';
|
|||
import { Prisma } from '@prisma/client';
|
||||
import { config } from '../config';
|
||||
import { logger } from '../config/logger';
|
||||
import { listCourseResponse, getCourseResponse } from '../types/Courses.types';
|
||||
import { listCourseResponse, getCourseResponse } from '../types/courses.types';
|
||||
import { UnauthorizedError, ValidationError, ForbiddenError } from '../middleware/errorHandler';
|
||||
|
||||
export class CoursesService {
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
import { Course, Prisma } from '@prisma/client';
|
||||
|
||||
// Use Prisma's CourseCreateInput for creating courses
|
||||
|
||||
// Response type uses Prisma's Course model
|
||||
|
||||
|
||||
export interface listCourseResponse {
|
||||
code: number;
|
||||
message: string;
|
||||
data: Course[];
|
||||
total: number | null;
|
||||
}
|
||||
|
||||
export interface getCourseResponse {
|
||||
code: number;
|
||||
message: string;
|
||||
data: Course | null;
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ export interface Category {
|
|||
updated_at: Date | null;
|
||||
}
|
||||
|
||||
export interface listCategoriesResponse {
|
||||
export interface ListCategoriesResponse {
|
||||
code: number;
|
||||
message: string;
|
||||
data: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue