update models

This commit is contained in:
KS Jannette
2026-05-18 17:17:13 -04:00
parent fca4f6a5d6
commit 2a2d7c2638
4 changed files with 18 additions and 18 deletions

View File

@@ -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
View 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>;

View File

@@ -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[] = [];

View File

@@ -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 {
/*