free-framework 4.6.2 → 4.6.5

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.
@@ -48,13 +48,6 @@ module.exports = function (name) {
48
48
  });
49
49
 
50
50
  // Wrap up
51
- console.log("\nšŸ“¦ Installing dependencies... (This may take a minute)");
52
- try {
53
- execSync("npm install", { cwd: targetDir, stdio: "inherit" });
54
- console.log("\nāœ… Enterprise Project Scaffolded Successfully!");
55
- console.log(`\nTo get started, run:\n cd ${name}\n free serve\n`);
56
- } catch (err) {
57
- console.log("\nāš ļø Scaffolding complete, but npm install failed. Please run 'npm install' manually.");
58
- console.log(`\nTo get started, run:\n cd ${name}\n npm install\n free serve\n`);
59
- }
51
+ console.log("\nāœ… Enterprise Project Scaffolded Successfully!");
52
+ console.log(`\nTo get started, run:\n cd ${name}\n npm install\n free serve\n`);
60
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-framework",
3
- "version": "4.6.2",
3
+ "version": "4.6.5",
4
4
  "description": "Professional Node.js engine for the .free language. Blazing-fast SSR, Islands Architecture, and built-in ORM.",
5
5
  "main": "index.js",
6
6
  "bin": {
package/runtime/server.js CHANGED
@@ -15,37 +15,53 @@ const { LRUCache } = require('lru-cache');
15
15
 
16
16
  class FreeServer {
17
17
  constructor() {
18
+ console.log(`[Free Engine] āš™ļø Runtime Core v4.6.5 initializing...`);
18
19
  this.app = new HyperExpress.Server();
19
20
  this.viewsPath = process.env.VIEWS_PATH || nodePath.join(process.cwd(), 'views');
20
21
  this.namedMiddlewares = {};
21
22
  this.errorViews = {};
22
23
  this.plugins = [];
23
24
 
24
- // Global Request Logger & Error Handler Initialization
25
+ // 1. Absolute Top Logger
26
+ this.app.use((req, res, next) => {
27
+ console.log(`[Free Engine] šŸ“„ [${new Date().toLocaleTimeString()}] Incoming: ${req.method} ${req.url}`);
28
+
29
+ // Track response
30
+ const start = Date.now();
31
+ res.on('finish', () => {
32
+ console.log(`[Free Engine] šŸ“¤ [${new Date().toLocaleTimeString()}] Sent: ${req.method} ${req.url} (${res.statusCode}) - ${Date.now() - start}ms`);
33
+ });
34
+
35
+ if (typeof next === 'function') {
36
+ return next();
37
+ }
38
+ });
39
+
40
+ // 2. Global Error Handler
25
41
  this.app.set_error_handler((req, res, error) => {
26
42
  console.error(`[Free Engine] šŸ”„ Global Uncaught Error:`, error);
27
43
  this.handleError(req, res, error);
28
44
  });
29
45
 
30
- this.app.use((req, res, next) => {
31
- console.log(`[Free Engine] šŸ“„ Request: ${req.method} ${req.url}`);
32
- if (next) next();
33
- });
34
-
35
- // Static Asset Serving Middleware
46
+ // 3. Static Asset Serving (Simplified & Safe)
36
47
  const publicPath = nodePath.join(process.cwd(), 'public');
37
48
  this.app.use((req, res, next) => {
38
- const lookupPath = req.path.startsWith('/') ? req.path.substring(1) : req.path;
39
- if (!lookupPath) return next ? next() : null;
49
+ if (req.path === '/' || !req.path.includes('.')) {
50
+ return typeof next === 'function' ? next() : null;
51
+ }
40
52
 
53
+ const lookupPath = req.path.startsWith('/') ? req.path.substring(1) : req.path;
41
54
  const fullPath = nodePath.join(publicPath, lookupPath);
55
+
42
56
  if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {
57
+ console.log(`[Free Engine] šŸ“„ Serving static: ${lookupPath}`);
43
58
  const ext = nodePath.extname(fullPath);
44
59
  const mimes = { '.js': 'application/javascript', '.css': 'text/css', '.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml' };
45
60
  res.type(mimes[ext] || 'text/plain');
46
61
  return res.send(fs.readFileSync(fullPath));
47
62
  }
48
- if (next) next();
63
+
64
+ if (typeof next === 'function') next();
49
65
  });
50
66
 
51
67
  this.app.get('/test-static', (req, res) => res.send('Static serving test'));
@@ -179,7 +195,8 @@ class FreeServer {
179
195
 
180
196
  start(port = 3000) {
181
197
  this.app.get('/health', (req, res) => res.send('OK'));
182
- this.app.listen(port).then(() => {
198
+ console.log(`[Free Engine] šŸ“” Binding to 127.0.0.1:${port}...`);
199
+ this.app.listen(port, '127.0.0.1').then(() => {
183
200
  const blueUnderline = "\x1b[34m\x1b[4m";
184
201
  const reset = "\x1b[0m";
185
202
  console.log(`⚔ Free Engine Ignite: ${blueUnderline}http://localhost:${port}${reset}`);