import * as express from 'express' ; import { RestDefault } from './default' ; import { RestTodo } from './todo' ; export class Rest { router : express . Router ; constructor ( ) { this . router = express . Router ( ) ; this . config ( ) ; } private config ( ) { this . todo ( ) ; this . default ( ) ; } private todo ( ) { let restTodo = new RestTodo ( ) ; this . router . get ( '/todo' , ( request , response ) => restTodo . list ( request , response ) ) ; this . router . post ( '/todo' , ( request , response ) => restTodo . create ( request , response ) ) ; this . router . get ( '/todo/:todo' , ( request , response ) => restTodo . find ( request , response ) ) ; this . router . put ( '/todo/:todo' , ( request , response ) => restTodo . update ( request , response ) ) ; this . router . delete ( '/todo/:todo' , ( request , response ) => restTodo . remove ( request , response ) ) ; } private default ( ) { let restDefault = new RestDefault ( ) ; this . router . get ( '*' , ( request , response ) => restDefault . request ( request , response ) ) ; } }