forked from falun/Eventful-API-test-page
-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
85 lines (69 loc) · 2.45 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const inquirer = require('inquirer');
//connection available to all
const connection = require('./connection');
const app = {};
app.startQuestion = (closeConnectionCallback) => {
inquirer.prompt({
type: 'list',
message: 'What action would you like to do?',
choices: [
'Complete a sentence',
'Create a new user',
'Find one event of a particular type in San Francisco next week',
'Mark an existing user to attend an event in database',
'See all events that a particular user is going to',
'See all the users that are going to a particular event',
'Exit'
],
name:'action',
}).then((res) => {
const continueCallback = () => app.startQuestion(closeConnectionCallback);
if (res.action === 'Complete a sentence') app.completeSentence(continueCallback);
if (res.action === 'Create a new user') app.createNewUser(continueCallback);
if (res.action === 'Find one event of a particular type in San Francisco next week') app.searchEventful(continueCallback);
if (res.action === 'Mark an existing user to attend an event in database') app.matchUserWithEvent(continueCallback);
if (res.action === 'See all events that a particular user is going to') app.seeEventsOfOneUser(continueCallback);
if (res.action === 'See all the users that are going to a particular event') app.seeUsersOfOneEvent(continueCallback);
if (res.action === 'Exit') {
closeConnectionCallback();
return;
}
})
}
app.completeSentence = (continueCallback) => {
//YOUR WORK HERE
console.log('Please write code for this function');
//End of your work
continueCallback();
}
app.createNewUser = (continueCallback) => {
//YOUR WORK HERE
console.log('Please write code for this function');
//End of your work
continueCallback();
}
app.searchEventful = (continueCallback) => {
//YOUR WORK HERE
console.log('Please write code for this function');
//End of your work
continueCallback();
}
app.matchUserWithEvent = (continueCallback) => {
//YOUR WORK HERE
console.log('Please write code for this function');
//End of your work
continueCallback();
}
app.seeEventsOfOneUser = (continueCallback) => {
//YOUR WORK HERE
console.log('Please write code for this function');
//End of your work
continueCallback();
}
app.seeUsersOfOneEvent = (continueCallback) => {
//YOUR WORK HERE
console.log('Please write code for this function');
//End of your work
continueCallback();
}
module.exports = app;