-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (39 loc) · 1.03 KB
/
index.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
#!/usr/bin/env node
// Libs
import express from "express";
import chalk from "chalk";
// Components
import { getApp, showTree } from "./src/index.js";
// Helper
import { get_adapters } from "./src/util/network.js";
async function main() {
const START_TIME = Date.now();
const PORT = process.env.PORT || 3000;
const app = await getApp();
app.listen(PORT);
let addrs = get_adapters();
for(const each of addrs){
app.listen(PORT, each);
}
const END_TMIE = Date.now();
const TIME_ELAPSED = END_TMIE - START_TIME;
console.clear();
console.log(
chalk.italic.bgCyan.black(" (folder-routing) "),
chalk.cyan("v" + "0.2.0"),
chalk.gray("ready in"),
chalk.white(TIME_ELAPSED),
chalk.gray("ms"),
"\n",
);
console.group();
console.log("Local \t" + chalk.green(`http://localhost:${PORT}/`));
// check for network adpaters
for(const each of addrs){
console.log("Network \t" + chalk.green(`http://${each}:${PORT}/`));
}
console.log(chalk.italic.gray("API is hosted locally."));
console.groupEnd();
showTree();
}
main();