-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
64 lines (61 loc) · 1.63 KB
/
Copy pathserver.js
File metadata and controls
64 lines (61 loc) · 1.63 KB
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
// Import dependencies
const inquirer = require("inquirer");
// eslint-disable-next-line no-unused-vars
const cTable = require("console.table");
const figlet = require("figlet");
const role = require("./controller/roleController.js");
const employee = require("./controller/employeeController.js");
const db = require("./config/connection.js");
const department = require("./controller/departmentController.js");
const statistics = require("./controller/statisticsController.js");
// Main menu
const menu = async () => {
// Inquirer prompt presenting three options
await inquirer.prompt({
name: "menu",
type: "list",
message: "What would you like to do?",
choices: [
"Employee Management",
"Role Management",
"Department Management",
"Statistics",
"Exit",
],
}).then((answer) => {
// Depending on answer, direct user to appropriate controller
switch (answer.menu) {
case "Employee Management":
employee.menu();
break;
case "Role Management":
role.menu();
break;
case "Department Management":
department.menu();
break;
case "Statistics":
statistics.count();
break;
default:
console.log("Goodbye");
db.close();
break;
}
});
};
// Banner shown on program start that is automatically ran
figlet("Employee Tracker", async (err, data) => {
if (err) {
console.log("Something went wrong...");
console.dir(err);
return;
}
// Show the banner on the console
console.log(data);
console.log("\n");
// Run the main menu
await menu();
});
// Exports the main menu function
module.exports.menu = menu;