slicejs-web-framework 2.2.5 β 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/index.js +1 -77
- package/package.json +1 -1
package/api/index.js
CHANGED
|
@@ -22,8 +22,6 @@ const folderDeployed = 'src';
|
|
|
22
22
|
// Obtener puerto desde sliceConfig.json, con fallback a process.env.PORT
|
|
23
23
|
const PORT = sliceConfig.server?.port || process.env.PORT || 3001;
|
|
24
24
|
|
|
25
|
-
console.log(`π Starting Slice.js server in ${runMode} mode`);
|
|
26
|
-
console.log(`π Serving files from: /${folderDeployed}`);
|
|
27
25
|
|
|
28
26
|
app.use('/Slice/', express.static(path.join(__dirname, '..', 'node_modules', 'slicejs-web-framework', 'Slice')));
|
|
29
27
|
|
|
@@ -80,81 +78,7 @@ app.get('*', (req, res) => {
|
|
|
80
78
|
|
|
81
79
|
function startServer() {
|
|
82
80
|
server = app.listen(PORT, () => {
|
|
83
|
-
// Limpiar consola y mostrar banner de inicio
|
|
84
|
-
console.clear();
|
|
85
|
-
showWelcomeBanner();
|
|
86
|
-
|
|
87
|
-
// InformaciΓ³n del servidor
|
|
88
|
-
console.log(`β
Server running at ${'\x1b[36m'}http://localhost:${PORT}${'\x1b[0m'}`);
|
|
89
|
-
console.log(`π Mode: ${'\x1b[32m'}${runMode}${'\x1b[0m'} (serving from ${'\x1b[33m'}/${folderDeployed}${'\x1b[0m'})`);
|
|
90
|
-
console.log(`π ${'\x1b[32m'}Development mode${'\x1b[0m'}: Changes in /src are served instantly`);
|
|
91
|
-
console.log(`π Press ${'\x1b[31m'}Ctrl+C${'\x1b[0m'} to stop\n`);
|
|
92
81
|
});
|
|
93
|
-
|
|
94
|
-
// Mostrar menΓΊ interactivo despuΓ©s de un momento
|
|
95
|
-
setTimeout(showInteractiveMenu, 1500);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function showWelcomeBanner() {
|
|
99
|
-
const banner = `
|
|
100
|
-
${'\x1b[36m'}ββββββββββββββββββββββββββββββββββββββββββββββββββββ${'\x1b[0m'}
|
|
101
|
-
${'\x1b[36m'}β${'\x1b[0m'} ${'\x1b[1m'}π° SLICE.JS SERVER${'\x1b[0m'} ${'\x1b[36m'}β${'\x1b[0m'}
|
|
102
|
-
${'\x1b[36m'}β${'\x1b[0m'} ${'\x1b[90m'}Development Environment${'\x1b[0m'} ${'\x1b[36m'}β${'\x1b[0m'}
|
|
103
|
-
${'\x1b[36m'}ββββββββββββββββββββββββββββββββββββββββββββββββββββ${'\x1b[0m'}
|
|
104
|
-
`;
|
|
105
|
-
console.log(banner);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async function showInteractiveMenu() {
|
|
109
|
-
while (true) {
|
|
110
|
-
try {
|
|
111
|
-
console.log('\n' + '='.repeat(50));
|
|
112
|
-
|
|
113
|
-
const { action } = await inquirer.prompt([
|
|
114
|
-
{
|
|
115
|
-
type: 'list',
|
|
116
|
-
name: 'action',
|
|
117
|
-
message: 'ποΈ Server Control Menu',
|
|
118
|
-
choices: [
|
|
119
|
-
'π Server Status',
|
|
120
|
-
'π Open in Browser',
|
|
121
|
-
'π Restart Server',
|
|
122
|
-
'π Stop Server'
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
]);
|
|
126
|
-
|
|
127
|
-
if (action === 'π Server Status') {
|
|
128
|
-
console.log(`\nπ Server Status:`);
|
|
129
|
-
console.log(` π URL: http://localhost:${PORT}`);
|
|
130
|
-
console.log(` π Mode: ${runMode}`);
|
|
131
|
-
console.log(` π Serving: /${folderDeployed}`);
|
|
132
|
-
console.log(` β° Uptime: ${Math.floor(process.uptime())}s`);
|
|
133
|
-
} else if (action === 'π Open in Browser') {
|
|
134
|
-
const { default: open } = await import('open');
|
|
135
|
-
await open(`http://localhost:${PORT}`);
|
|
136
|
-
console.log('π Opening browser...');
|
|
137
|
-
} else if (action === 'π Stop Server') {
|
|
138
|
-
console.log('\nπ Stopping server...');
|
|
139
|
-
server.close(() => {
|
|
140
|
-
console.log('β
Server stopped successfully');
|
|
141
|
-
process.exit(0);
|
|
142
|
-
});
|
|
143
|
-
break;
|
|
144
|
-
} else if (action === 'π Restart Server') {
|
|
145
|
-
console.log('\nRestarting server...');
|
|
146
|
-
server.close(() => {
|
|
147
|
-
console.log('Server stopped. Restarting...');
|
|
148
|
-
startServer();
|
|
149
|
-
});
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
} catch (error) {
|
|
153
|
-
// Si hay error con inquirer, continuar sin menΓΊ
|
|
154
|
-
console.log('\nπ‘ Interactive menu not available - Press Ctrl+C to stop');
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
82
|
}
|
|
159
83
|
|
|
160
84
|
// Manejar cierre del proceso
|
|
@@ -171,4 +95,4 @@ process.on('SIGTERM', () => {
|
|
|
171
95
|
// Iniciar servidor
|
|
172
96
|
startServer();
|
|
173
97
|
|
|
174
|
-
export default app;
|
|
98
|
+
export default app;
|