update models
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
export interface Object {
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface CreateObjectDto {
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
}
|
||||
// All fields optional for partial updates
|
||||
export type UpdateObjectDto = Partial<CreateObjectDto>;
|
||||
13
src/models/User.ts
Normal file
13
src/models/User.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export interface User {
|
||||
id: number;
|
||||
name: string;
|
||||
email: string;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface CreateUserDto {
|
||||
name: string;
|
||||
email: string;
|
||||
}
|
||||
// optional fields - for partial updates
|
||||
export type UpdateUserDto = Partial<CreateUserDto>;
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
Object as StoredObject,
|
||||
CreateObjectDto,
|
||||
UpdateObjectDto,
|
||||
} from '../models/Object';
|
||||
} from '../models/User';
|
||||
|
||||
// In-memory store — replace with DB client in a real app
|
||||
const store: StoredObject[] = [];
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import { CreateObjectDto, UpdateObjectDto, Object } from '../models/Object';
|
||||
import { CreateObjectDto, UpdateObjectDto, Object } from '../models/User';
|
||||
import { AppError } from '../middleware/errorHandler';
|
||||
|
||||
export const Service = {
|
||||
|
||||
getAll(): Object[] {
|
||||
//return userRepository.findAll();
|
||||
return objectRepository.findAll();
|
||||
},
|
||||
|
||||
getById(id: number): Object {
|
||||
/*const user = userRepository.findById(id);
|
||||
if (!user) throw new AppError(404, `User ${id} not found`);
|
||||
*/
|
||||
const object = objectRepository.findById(id);
|
||||
if (!object) throw new AppError(404, `User ${id} not found`);
|
||||
return object;
|
||||
|
||||
},
|
||||
create(dto: CreateObjectDto): Object {
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user