Skip to content

Instantly share code, notes, and snippets.

@asror797
Created February 17, 2024 15:05
Show Gist options
  • Save asror797/efdfb67f66d825171a77550d80215304 to your computer and use it in GitHub Desktop.
Save asror797/efdfb67f66d825171a77550d80215304 to your computer and use it in GitHub Desktop.
TaskController manages HTTP requests for tasks, logging with APILogger
import { APILogger } from '../logger/api.logger';
import { TaskService } from '../service/task.service';
export class TaskController {
private taskService: TaskService;
private logger: APILogger;
constructor() {
this.taskService = new TaskService();
this.logger = new APILogger()
}
async getTasks() {
this.logger.info('Controller: getTasks', null)
return await this.taskService.getTasks();
}
async createTask(task) {
this.logger.info('Controller: createTask', task);
return await this.taskService.createTask(task);
}
async updateTask(task) {
this.logger.info('Controller: updateTask', task);
return await this.taskService.updateTask(task);
}
async deleteTask(taskId) {
this.logger.info('Controller: deleteTask', taskId);
return await this.taskService.deleteTask(taskId);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment