dinou 4.0.0 → 4.0.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
+ ## [4.0.1]
9
+
10
+ ### Fixed
11
+
12
+ - Starting sequence of the server (generate static pages on background).
13
+
8
14
  ## [4.0.0]
9
15
 
10
16
  ### šŸš€ Major Release
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # **Dinou**
2
2
 
3
+ [![Documentation](https://img.shields.io/badge/docs-dinou.dev-blue?style=flat-square)](https://dinou.dev)
4
+
3
5
  ### **Full-Stack React 19 Framework**
4
6
 
5
7
  ---
@@ -1314,7 +1316,7 @@ Netlify is currently incompatible because it does not support passing custom Nod
1314
1316
  Ensure your platform allows customization of the start command. Your start command should look like:
1315
1317
 
1316
1318
  ```bash
1317
- node --conditions react-server dist3/index.js
1319
+ node --conditions react-server ...
1318
1320
  ```
1319
1321
 
1320
1322
  _(Or use `npm start` if your package.json scripts are configured correctly)._
@@ -436,42 +436,14 @@ function getContextForServerFunctionEndpoint(req, res) {
436
436
 
437
437
  app.use(express.static(path.resolve(process.cwd(), outputFolder)));
438
438
 
439
- // app.use((req, res, next) => {
440
- // // Make sure NOT to return 200 if what is requested is a .js that doesn't exist
441
- // if (
442
- // req.path.endsWith(".js") ||
443
- // req.path.endsWith(".css") ||
444
- // req.path.endsWith(".png") ||
445
- // req.path.endsWith(".jpg") ||
446
- // req.path.endsWith(".svg") ||
447
- // req.path.endsWith(".webp") ||
448
- // req.path.endsWith(".ico") ||
449
- // req.path.endsWith(".json")
450
- // ) {
451
- // return res.status(404).send("Not found");
452
- // }
453
- // next();
454
- // // ... Dinou rendering ...
455
- // });
456
-
457
439
  let isReady = isDevelopment; // In dev we are always ready (or almost)
458
440
 
459
- // 1. "Blocking" Middleware (Put BEFORE your Dinou routes, but AFTER express.static)
460
- // Ideal order:
461
- // app.use(express.static(...));
462
- // app.use(404AssetsMiddlewareWeMadeBefore);
463
-
464
- app.use((req, res, next) => {
465
- // If we are in PROD and generateStatic hasn't finished yet...
466
- if (!isReady) {
467
- // Optional: Allow health-checks or assets if you want
468
- // if (req.path.endsWith('.js')) return next();
469
-
470
- // Return 503 (Service Unavailable)
471
- // Playwright understands that 503 means "Keep waiting"
472
- return res.status(503).send("Server warming up (generating static)...");
473
- }
474
- next();
441
+ app.get("/__DINOU_STATUS_PLAYWRIGHT__", (req, res) => {
442
+ res.json({
443
+ status: "ok",
444
+ isReady,
445
+ mode: isDevelopment ? "development" : "production",
446
+ });
475
447
  });
476
448
 
477
449
  app.get("/.well-known/appspecific/com.chrome.devtools.json", (req, res) => {
@@ -759,8 +731,8 @@ app.get(/^\/.*\/?$/, (req, res) => {
759
731
  if (
760
732
  !isDevelopment &&
761
733
  res.statusCode === 200 && // Only if success
762
- req.method === "GET" // Only GET requests
763
- /*Object.keys({ ...req.query }).length === 0*/ // No query params (avoid infinite duplicates)
734
+ req.method === "GET" && // Only GET requests
735
+ isReady
764
736
  ) {
765
737
  generatingISG(reqPath, dynamicState);
766
738
  }
@@ -983,70 +955,54 @@ const port = process.env.PORT || 3000;
983
955
 
984
956
  const http = require("http");
985
957
 
986
- // Wrap the entire startup in an async IIFE to use await cleanly
958
+ // ============================================================
959
+ // STARTUP SEQUENCE
960
+ // ============================================================
987
961
  (async () => {
988
962
  try {
989
- // ============================================================
990
- // PHASE 1: STATIC GENERATION (Build Time)
991
- // ============================================================
992
- // We do this BEFORE creating the server. This way, if generateStatic
993
- // performs aggressive memory cleanups, it doesn't kill the HTTP server.
994
- if (!isDevelopment) {
995
- console.log("šŸ—ļø [Startup] Starting static generation (SSG/ISR)...");
996
- try {
997
- await generateStatic();
998
- console.log("āœ… [Startup] Static generation finished successfully.");
999
- } catch (buildError) {
1000
- console.error("āŒ [Startup] Static generation failed:", buildError);
1001
- // Depending on your policy, you could exit (process.exit(1)) or continue
1002
- // If you decide to continue, the server will start but files might be missing.
1003
- process.exit(1);
1004
- }
1005
- } else {
1006
- console.log(
1007
- "āš™ļø [Startup] Running in Development Mode (Dynamic Rendering)"
1008
- );
1009
- }
1010
-
1011
- // ============================================================
1012
- // PHASE 2: SERVER CREATION
1013
- // ============================================================
1014
963
  console.log("šŸ‘‰ [Startup] Initializing HTTP Server...");
1015
-
1016
- // We pass 'app' to createServer. This decouples Express from the network.
1017
964
  const server = http.createServer(app);
1018
965
 
1019
- // ============================================================
1020
- // PHASE 3: ERROR HANDLING (Anti-Zombies)
1021
- // ============================================================
1022
- // This captures errors like EADDRINUSE before they silently crash the process
966
+ // 2. ERROR HANDLING (Anti-Zombies)
1023
967
  server.on("error", (error) => {
1024
968
  if (error.code === "EADDRINUSE") {
1025
969
  console.error(`\nāŒ FATAL ERROR: Port ${port} is already in use!`);
1026
- console.error(
1027
- ` Cause: A previous instance, a zombie test runner, or another app is holding the port.`
1028
- );
1029
- console.error(
1030
- ` Action: Run 'netstat -ano | findstr :${port}' (Win) or 'lsof -i :${port}' to find the PID and kill it.\n`
1031
- );
1032
970
  } else {
1033
971
  console.error("āŒ [Server Error]:", error);
1034
972
  }
1035
- process.exit(1); // Explicitly exit with error code
973
+ process.exit(1);
1036
974
  });
1037
975
 
1038
- // ============================================================
1039
- // PHASE 4: STARTUP (Listen)
1040
- // ============================================================
1041
- server.listen(port, () => {
1042
- isReady = true;
1043
- console.log(
1044
- `\nšŸš€ Dinou Server is ready and listening on http://localhost:${port}`
1045
- );
1046
- console.log(
1047
- ` Environment: ${isDevelopment ? "Development" : "Production"}\n`
1048
- );
976
+ await new Promise((resolve) => {
977
+ server.listen(port, () => {
978
+ console.log(
979
+ `\nšŸš€ Dinou Server is ready and listening on http://localhost:${port}`
980
+ );
981
+ console.log(
982
+ ` Environment: ${isDevelopment ? "Development" : "Production"}`
983
+ );
984
+ resolve();
985
+ });
1049
986
  });
987
+
988
+ if (!isDevelopment) {
989
+ console.log("šŸ—ļø [Background] Starting static generation (SSG)...");
990
+
991
+ generateStatic()
992
+ .then(() => {
993
+ console.log("āœ… [Background] Static generation finished.");
994
+ isReady = true;
995
+ })
996
+ .catch((err) => {
997
+ console.error(
998
+ "āŒ [Background] Static generation failed (App continues in Dynamic Mode):",
999
+ err
1000
+ );
1001
+ isReady = true;
1002
+ });
1003
+ } else {
1004
+ console.log("āš™ļø [Startup] Running in Development Mode");
1005
+ }
1050
1006
  } catch (error) {
1051
1007
  console.error("šŸ’„ [Fatal Startup Error]:", error);
1052
1008
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinou",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Modern Full-Stack React 19 framework with React Server Components, Server Functions, and Streaming SSR.",
5
5
  "main": "index.js",
6
6
  "bin": {