다음으로 src/api/posts/index.js 파일을 수정하세요.

    src/api/posts/index.js

    import Router from 'koa-router';
    import * as postsCtrl from './posts.ctrl';
    
    const posts = new Router();
    
    posts.get('/', postsCtrl.list);
    posts.post('/', postsCtrl.write);
    posts.get('/:id', postsCtrl.read);
    posts.delete('/:id', postsCtrl.remove);
    posts.put('/:id', postsCtrl.replace);
    posts.patch('/:id', postsCtrl.update);
    
    export default posts;

     

    여기까지 코드를 작성하고 저장하면 서버에서 오류가 발생할 것입니다. 이 오류는 파일 두 개를 더 수정하면 해결되니 걱정하지 마세요.

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.