'use strict';

import compose from 'koa-compose';
import Router from 'koa-router';

import {testFN, testFN2, testFN3} from './api/product.controller';
import * as product from './api/product.controller';

import { validateCreate } from './api/product.validate.create';


export default function router() {


  const router = new Router({
    prefix: ''
  });


  router

    .get('/api/test',               testFN)
    .get('/api/test2',              testFN2,          testFN3)

    .get('/api/products',           product.find)
    .get('/api/products/:id',       product.findOne)
    .post('/api/products',          validateCreate,   product.create)
    .put('/api/products/:id',       product.update)
    .delete('/api/products/:id',    product.remove);


  return compose([
    router.routes(),
    router.allowedMethods()
  ]);
}
