Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions cmds/request/wow/achievement.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@ const logger = require('../../../lib/logger');

const request = yargs
.command({
command: 'achievement',
command: 'achievement <id>',
describe: 'Fetch a World of Warcraft achievement',
builder: yargs => {
return yargs
.options({
id: {
alias: 'i',
describe: 'The [id] of the {achievement}',
demand: true,
},
});
},
handler: argv => logger('wow', 'achievement', argv),
}).argv;
Expand Down
14 changes: 1 addition & 13 deletions cmds/request/wow/character.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,11 @@ const logger = require('../../../lib/logger');

const character = yargs
.command({
command: 'character',
command: 'character <origin> <realm> <name>',
describe: 'Fetch a World of Warcraft character',
builder: yargs => {
return yargs
.options({
realm: {
alias: 'r',
describe: 'The [realm] of the {character}',
type: 'string',
demand: true,
},
name: {
alias: 'n',
describe: 'The [name] of the {character}',
type: 'string',
demand: true,
},
fields: {
alias: 'f',
describe: 'A list of one or more [fields] belonging to the {character}',
Expand Down
14 changes: 1 addition & 13 deletions cmds/request/wow/guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,11 @@ const logger = require('../../../lib/logger');

const guild = yargs
.command({
command: 'guild',
command: 'guild <origin> <realm> <name>',
describe: 'Fetch a World of Warcraft guild',
builder: yargs => {
return yargs
.options({
realm: {
alias: 'r',
describe: 'The [realm] of the {guild}',
type: 'string',
demand: true,
},
name: {
alias: 'n',
describe: 'The name of the guild',
type: 'string',
demand: true,
},
fields: {
alias: 'f',
describe: 'A list of one or more [fields] belonging to the {guild}',
Expand Down
9 changes: 7 additions & 2 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const db = require('./db');

module.exports = (command, resource, obj) => {
const args = argv[command](resource, obj);
function display (request) {
console.log(request.response);
}


return db.models.RecentRequest.findOne({
where: { command, resource, args: JSON.stringify(args) },
Expand All @@ -17,7 +21,7 @@ module.exports = (command, resource, obj) => {
})
.then(request => {
if (request) {
return console.log(request.get()); // TODO log with winston.info
return display(request);
}

async.waterfall([
Expand All @@ -42,7 +46,8 @@ module.exports = (command, resource, obj) => {
return console.log(err); // TODO log with winston.error
}

return console.log(result.get()); // TODO log with winston.info
return display(result.get());
// return console.log(result.get()); // TODO log with winston.info
});
})
.catch(err => {
Expand Down