Read Me
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
import { Controller, IController, Post, Get, Autowired } from "odi";
import { TodoService } from "./todo.service";
import { TodoDTO } from "./todo.dto";
@Controller()
export class TodoController extends IController {
@Autowired()
todoService: TodoService;
@Get index() {
return `Hello, ${this.request.ip}`;
}
@Post async save(toDo: TodoDTO) {
await this.todoService.save(toDo);
}
@Get async '/:id' (id: string) {
const todo = await this.todoService.find(id);
if(!todo)
throw NotFound;
return todo;
}
}