var fs = require('fs');
module.exports = {
  '/api/log/start/:userID': {
    options: {
      userID: { required: true, description: 'ID of user', type: Number }
    },
    method: 'POST',
    summary: 'Get list of new cards',
    fn: async function(args) {
      fs.writeFile('./public/log/'+args.userID+'.jsons', JSON.stringify({
          type: 'START', date: +new Date(), data: args.body})+'\n', {'flag':'a'},
        function(err) {
          console.log(err);
        });

      return true;
    }
  },
  '/api/log/step/:userID': {
    options: {
      userID: { required: true, description: 'ID of user', type: Number }
    },
    method: 'POST',
    summary: 'Get list of new cards',
    fn: async function(args) {
      fs.writeFile('./public/log/'+args.userID+'.jsons', JSON.stringify({
          type: 'ANSWER', date: +new Date(), data: args.body})+'\n', {'flag':'a'},
        function(err) {
          console.log(err);
        });

      return true;
    }
  }
};