-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
72 lines (65 loc) · 2.08 KB
/
server.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
require("module-alias/register");
const figlet = require("figlet");
const os = require("os");
const app = require("@config/app");
const chalk = require("@config/console");
const clearTerminal = () => {
if (process.platform === "win32") {
process.stdout.write("\033c");
} else {
process.stdout.write("\x1Bc");
}
};
const showRemoteIP = () => {
const networkInterfaces = os.networkInterfaces();
for (const interfaceName in networkInterfaces) {
const interfaceInfo = networkInterfaces[interfaceName];
for (const alias of interfaceInfo) {
if (alias.family === "IPv4" && !alias.internal) {
console.log(
`\t- Network:\t${chalk.green(
"http://" + alias.address + ":" + app.env.SERVER_PORT
)}`
);
}
}
}
};
app.server.listen(app.env.SERVER_PORT, () => {
clearTerminal();
console.log(
chalk.yellow(
figlet.textSync(app.env.SERVER_NAME, { horizontalLayout: "full" })
)
);
console.log(
chalk.yellow(
`${app.env.SERVER_NAME.toUpperCase()} SERVER RUNNING IN ${app.env.SERVER_ENV.toUpperCase()} ENVIRONMENT`
)
);
console.log(
`\t\n\t- Local:\t${chalk.green(
app.env.SERVER_BASE + ":" + app.env.SERVER_PORT
)}`
);
showRemoteIP();
// console.log(`\nRoutes: `);
// app._router.stack.forEach(function (r) {
// if (r.route && r.route.path) {
// console.log(
// "~",
// chalk.underline(
// r.route.stack[0].method.toUpperCase() == "POST" ? chalk.yellow(r.route.stack[0].method.toUpperCase()) :
// r.route.stack[0].method.toUpperCase() == "GET" ? chalk.green(r.route.stack[0].method.toUpperCase()) :
// r.route.stack[0].method.toUpperCase() == "PATCH" ? chalk.magenta(r.route.stack[0].method.toUpperCase()) :
// r.route.stack[0].method.toUpperCase() == "PUT" ? chalk.blue(r.route.stack[0].method.toUpperCase()) :
// r.route.stack[0].method.toUpperCase() == "DELETE" ? chalk.red(r.route.stack[0].method.toUpperCase()) :
// chalk.cyan(r.route.stack[0].method.toUpperCase())
// ),
// chalk.underline(r.route.path)
// );
// }
// });
console.log(`\nServer Logs:`);
app.logger.info(`[System] App has started.`);
});