odac 1.0.1 → 1.2.0

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.
Files changed (143) hide show
  1. package/.agent/rules/coding.md +27 -0
  2. package/.agent/rules/memory.md +33 -0
  3. package/.agent/rules/project.md +30 -0
  4. package/.agent/rules/workflow.md +16 -0
  5. package/.github/workflows/auto-pr-description.yml +3 -1
  6. package/.github/workflows/release.yml +42 -1
  7. package/.github/workflows/test-coverage.yml +6 -5
  8. package/.github/workflows/test-publish.yml +36 -0
  9. package/.husky/pre-commit +10 -0
  10. package/.husky/pre-push +13 -0
  11. package/.releaserc.js +3 -3
  12. package/CHANGELOG.md +184 -0
  13. package/README.md +53 -34
  14. package/bin/odac.js +181 -49
  15. package/client/odac.js +878 -995
  16. package/docs/backend/01-overview/03-development-server.md +39 -46
  17. package/docs/backend/02-structure/01-typical-project-layout.md +59 -25
  18. package/docs/backend/03-config/00-configuration-overview.md +15 -6
  19. package/docs/backend/03-config/01-database-connection.md +3 -3
  20. package/docs/backend/03-config/02-static-route-mapping-optional.md +1 -1
  21. package/docs/backend/03-config/03-request-timeout.md +1 -1
  22. package/docs/backend/03-config/04-environment-variables.md +4 -4
  23. package/docs/backend/03-config/05-early-hints.md +2 -2
  24. package/docs/backend/04-routing/02-controller-less-view-routes.md +9 -3
  25. package/docs/backend/04-routing/03-api-and-data-routes.md +18 -0
  26. package/docs/backend/04-routing/07-cron-jobs.md +17 -1
  27. package/docs/backend/04-routing/09-websocket.md +29 -0
  28. package/docs/backend/05-controllers/01-how-to-build-a-controller.md +48 -3
  29. package/docs/backend/05-controllers/02-your-trusty-odac-assistant.md +2 -0
  30. package/docs/backend/05-controllers/03-controller-classes.md +61 -55
  31. package/docs/backend/05-forms/01-custom-forms.md +103 -95
  32. package/docs/backend/05-forms/02-automatic-database-insert.md +21 -21
  33. package/docs/backend/06-request-and-response/01-the-request-object-what-is-the-user-asking-for.md +17 -0
  34. package/docs/backend/07-views/02-rendering-a-view.md +1 -1
  35. package/docs/backend/07-views/03-variables.md +5 -5
  36. package/docs/backend/07-views/04-request-data.md +1 -1
  37. package/docs/backend/07-views/08-backend-javascript.md +1 -1
  38. package/docs/backend/07-views/10-styling-and-tailwind.md +93 -0
  39. package/docs/backend/08-database/01-getting-started.md +100 -0
  40. package/docs/backend/08-database/02-basics.md +136 -0
  41. package/docs/backend/08-database/03-advanced.md +84 -0
  42. package/docs/backend/08-database/04-migrations.md +48 -0
  43. package/docs/backend/09-validation/01-the-validator-service.md +1 -0
  44. package/docs/backend/10-authentication/03-register.md +9 -2
  45. package/docs/backend/10-authentication/04-odac-register-forms.md +48 -48
  46. package/docs/backend/10-authentication/05-session-management.md +16 -2
  47. package/docs/backend/10-authentication/06-odac-login-forms.md +50 -50
  48. package/docs/backend/10-authentication/07-magic-links.md +134 -0
  49. package/docs/backend/11-mail/01-the-mail-service.md +118 -28
  50. package/docs/backend/12-streaming/01-streaming-overview.md +2 -2
  51. package/docs/backend/13-utilities/01-odac-var.md +7 -7
  52. package/docs/backend/13-utilities/02-ipc.md +73 -0
  53. package/docs/frontend/01-overview/01-introduction.md +5 -1
  54. package/docs/frontend/02-ajax-navigation/01-quick-start.md +1 -1
  55. package/docs/index.json +21 -125
  56. package/eslint.config.mjs +5 -47
  57. package/jest.config.js +1 -1
  58. package/package.json +16 -7
  59. package/src/Auth.js +414 -121
  60. package/src/Config.js +12 -7
  61. package/src/Database.js +188 -0
  62. package/src/Env.js +3 -1
  63. package/src/Ipc.js +337 -0
  64. package/src/Lang.js +9 -2
  65. package/src/Mail.js +408 -37
  66. package/src/Odac.js +105 -40
  67. package/src/Request.js +71 -49
  68. package/src/Route/Cron.js +62 -18
  69. package/src/Route/Internal.js +215 -12
  70. package/src/Route/Middleware.js +7 -2
  71. package/src/Route.js +372 -109
  72. package/src/Server.js +118 -12
  73. package/src/Storage.js +169 -0
  74. package/src/Token.js +6 -4
  75. package/src/Validator.js +95 -3
  76. package/src/Var.js +22 -6
  77. package/src/View/EarlyHints.js +43 -33
  78. package/src/View/Form.js +210 -28
  79. package/src/View.js +108 -7
  80. package/src/WebSocket.js +18 -3
  81. package/template/odac.json +5 -0
  82. package/template/package.json +3 -1
  83. package/template/route/www.js +12 -10
  84. package/template/view/content/home.html +3 -3
  85. package/template/view/head/main.html +2 -2
  86. package/test/Client.test.js +168 -0
  87. package/test/Config.test.js +112 -0
  88. package/test/Lang.test.js +92 -0
  89. package/test/Odac.test.js +86 -0
  90. package/test/{framework/middleware.test.js → Route/Middleware.test.js} +2 -2
  91. package/test/{framework/Route.test.js → Route.test.js} +1 -1
  92. package/test/{framework/View → View}/EarlyHints.test.js +1 -1
  93. package/test/{framework/WebSocket.test.js → WebSocket.test.js} +2 -2
  94. package/test/scripts/check-coverage.js +4 -4
  95. package/docs/backend/08-database/01-database-connection.md +0 -99
  96. package/docs/backend/08-database/02-using-mysql.md +0 -322
  97. package/src/Mysql.js +0 -575
  98. package/template/config.json +0 -5
  99. package/test/cli/Cli.test.js +0 -36
  100. package/test/core/Candy.test.js +0 -234
  101. package/test/core/Commands.test.js +0 -538
  102. package/test/core/Config.test.js +0 -1432
  103. package/test/core/Lang.test.js +0 -250
  104. package/test/core/Process.test.js +0 -156
  105. package/test/server/Api.test.js +0 -647
  106. package/test/server/DNS.test.js +0 -2050
  107. package/test/server/DNS.test.js.bak +0 -2084
  108. package/test/server/Hub.test.js +0 -497
  109. package/test/server/Log.test.js +0 -73
  110. package/test/server/Mail.account.test_.js +0 -460
  111. package/test/server/Mail.init.test_.js +0 -411
  112. package/test/server/Mail.test_.js +0 -1340
  113. package/test/server/SSL.test_.js +0 -1491
  114. package/test/server/Server.test.js +0 -765
  115. package/test/server/Service.test_.js +0 -1127
  116. package/test/server/Subdomain.test.js +0 -440
  117. package/test/server/Web/Firewall.test.js +0 -175
  118. package/test/server/Web/Proxy.test.js +0 -397
  119. package/test/server/Web.test.js +0 -1494
  120. package/test/server/__mocks__/acme-client.js +0 -17
  121. package/test/server/__mocks__/bcrypt.js +0 -50
  122. package/test/server/__mocks__/child_process.js +0 -389
  123. package/test/server/__mocks__/crypto.js +0 -432
  124. package/test/server/__mocks__/fs.js +0 -450
  125. package/test/server/__mocks__/globalOdac.js +0 -227
  126. package/test/server/__mocks__/http.js +0 -575
  127. package/test/server/__mocks__/https.js +0 -272
  128. package/test/server/__mocks__/index.js +0 -249
  129. package/test/server/__mocks__/mail/server.js +0 -100
  130. package/test/server/__mocks__/mail/smtp.js +0 -31
  131. package/test/server/__mocks__/mailparser.js +0 -81
  132. package/test/server/__mocks__/net.js +0 -369
  133. package/test/server/__mocks__/node-forge.js +0 -328
  134. package/test/server/__mocks__/os.js +0 -320
  135. package/test/server/__mocks__/path.js +0 -291
  136. package/test/server/__mocks__/selfsigned.js +0 -8
  137. package/test/server/__mocks__/server/src/mail/server.js +0 -100
  138. package/test/server/__mocks__/server/src/mail/smtp.js +0 -31
  139. package/test/server/__mocks__/smtp-server.js +0 -106
  140. package/test/server/__mocks__/sqlite3.js +0 -394
  141. package/test/server/__mocks__/testFactories.js +0 -299
  142. package/test/server/__mocks__/testHelpers.js +0 -363
  143. package/test/server/__mocks__/tls.js +0 -229
@@ -0,0 +1,27 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # Coding Standards & Best Practices
6
+
7
+ ## 1. Testing Strategy
8
+ - **Rule:** No feature is complete without tests.
9
+ - **Goal:** Maintain stability and prevent regressions.
10
+ - **Action:** Write unit tests for logic and integration tests for API endpoints.
11
+
12
+ ## 2. Dependency Management
13
+ - **Philosophy:** "Less is more."
14
+ - **Rule:** Avoid external dependencies unless absolutely necessary.
15
+ - **Preference:** Prioritize native Node.js modules (`fs`, `http`, `crypto`, etc.) to reduce bundle size and security attack surface.
16
+
17
+ ## 3. Error Handling
18
+ - **Rule:** Fail loudly and clearly.
19
+ - **Practice:** Use custom Error classes where possible.
20
+ - **Message:** Error messages should guide the developer on how to fix the issue, not just say "Error".
21
+
22
+ ## 4. Modern JavaScript
23
+ - **Standard:** Use ES6+ features (Async/Await, Arrow functions, Destructuring).
24
+ - **Modules:** Strict adherence to ES Modules (import/export).
25
+
26
+ ## 5. Route & Session Logic
27
+ - **Session Initialization:** `Odac.Request.setSession()` MUST be called before any logic that attempts to access `Odac.Request.session()`. This includes global middleware or form processing logic in `Route.js` that runs before the specific controller is resolved.
@@ -0,0 +1,33 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # Project Memory & Rules
6
+
7
+ ## Configuration & Environment
8
+ - **Debug Mode Logic:** The `debug` configuration in `src/Config.js` defaults to `process.env.NODE_ENV !== 'production'`. This ensures that `odac dev` (undefined NODE_ENV) enables debug/hot-reload, while `odac start` (NODE_ENV=production) disables it to use caching.
9
+ - **Logging Strategy:**
10
+ - **Development (`debug: true`):** Enable verbose logging, hot-reloading notifications, and detailed stack traces for easier debugging.
11
+ - **Production (`debug: false`):** Minimize logging to essential operational events (Start/Stop) and Fatal Errors only. Avoid `console.log` for per-request information to preserve performance and disk space. Sensitive error details must not be exposed to the user.
12
+
13
+ ## Development Standards & Integrity
14
+ - **NO QUICK/LAZY FIXES:** Explicitly prohibited.
15
+ - Never implement truncated solutions (e.g., `substring(0, 32)` on a hash) or temporary workarounds just to make code run.
16
+ - Always implement the mathematically and architecturally correct "Enterprise-Grade" solution (e.g., using raw `Buffer` for crypto keys instead of hex strings).
17
+ - If a proper solution requires refactoring, do the refactoring. Do not patch holes.
18
+ - **Prioritize Correctness over Speed:** It is better to verify documentation or think for a minute than to output a sub-par patch.
19
+
20
+ ## Code Quality & Modern Standards
21
+ - **No Legacy Syntax:**
22
+ - **Strictly Prohibited:** The use of `var` is forbidden. Use `const` (preferred) or `let` (only if mutation is needed).
23
+ - **Variable Scope:** Ensure variables are block-scoped to prevent leakage.
24
+ - **Anti-Spaghetti Code:**
25
+ - **Fail-Fast Pattern:** Avoid deeply nested `if/else` logic. Use early returns (`return`, `break`, `continue`) to handle negative cases immediately.
26
+ - **Promise Handling:** Resolve Promises upfront (e.g., `Promise.all` or strict `await` before loops) rather than mixing `await` inside deep logic or mutating input objects.
27
+ - **Strict Equality:** Always use strict equality checks (`===`) instead of loose ones.
28
+ - **Loop Optimization:** Use labeled loops (`label: for`) for efficient control flow in nested structures. Eliminate intermediate "flag" variables (`isMatch`, `found`) by using direct `return` or `continue label`.
29
+ - **Direct Returns:** Return a value as soon as it is determined. Avoid assigning to a temporary variable (e.g. `matchedUser`) and breaking the loop, unless post-loop processing is strictly necessary.
30
+ - **Async State Safety:** When an async function depends on mutable class state (like `pendingMiddlewares`), capture that state into a local `const` *synchronously* before triggering any async operations. This prevents race conditions where the state changes before the async task consumes it.
31
+
32
+ ## Dependency Management
33
+ - **Prefer Native Fetch:** Use the native `fetch` API for network requests in both Node.js (18+) and browser environments to reduce dependencies and bundle size.
@@ -0,0 +1,30 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # Project Context & Design Philosophy
6
+
7
+ ## Project Identity
8
+ - **Type:** Node.js Framework
9
+ - **Goal:** To provide a robust, enterprise-ready backbone for web applications.
10
+
11
+ ## Core Priorities (The "Big 3")
12
+ 1. **Enterprise-Level Security:**
13
+ - Security is not an afterthought; it is foundational.
14
+ - Default to secure settings.
15
+ - Validate all inputs.
16
+ - Sanitize outputs.
17
+ - Use established cryptographic standards.
18
+ 2. **Zero-Config:**
19
+ - The framework should work "out of the box" with sensible defaults.
20
+ - Configuration should be optional, not mandatory for getting started.
21
+ - "Convention over Configuration" is key.
22
+ 3. **High Performance:**
23
+ - Code must be optimized for throughput and low latency.
24
+ - Avoid unnecessary overhead.
25
+ - Profile and benchmark critical paths.
26
+ - Memory management is crucial.
27
+
28
+ ## Interaction Guidelines for AI
29
+ - Always assume the user wants the most efficient and secure solution unless specified otherwise.
30
+ - When suggesting architecture, prioritize scalability and maintainability.
@@ -0,0 +1,16 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # Development Workflow Rules
6
+
7
+ ## 1. Quality Assurance (Linting)
8
+ - **Rule:** **ALWAYS** runs lint checks after writing or modifying code.
9
+ - **Action:** Execute the project's linting command (e.g., `npm run lint` or `eslint .`) to verify code compliance.
10
+ - **Strictness:** Do not mark a task as complete if lint errors persist. Fix them immediately.
11
+
12
+ ## 2. Documentation Hygiene
13
+ - **Rule:** Documentation must be kept in sync with code changes.
14
+ - **Trigger:** Adding a new feature, modifying an API, or changing configuration behavior.
15
+ - **Action:** Update the relevant `.md` files (README, API docs, etc.) or JSDoc comments.
16
+ - **Goal:** Ensure that the documentation is never stale and accurately reflects the current state of the codebase.
@@ -35,6 +35,8 @@ jobs:
35
35
 
36
36
  - name: Update PR Title and Body
37
37
  uses: actions/github-script@v7
38
+ env:
39
+ PR_BODY: ${{ steps.generate_body.outputs.body }}
38
40
  with:
39
41
  github-token: ${{ secrets.GITHUB_TOKEN }}
40
42
  script: |
@@ -43,5 +45,5 @@ jobs:
43
45
  repo: context.repo.repo,
44
46
  pull_number: context.issue.number,
45
47
  title: 'Sync `dev` to `main`',
46
- body: `${{ steps.generate_body.outputs.body }}`
48
+ body: process.env.PR_BODY
47
49
  });
@@ -7,6 +7,7 @@ on:
7
7
  paths-ignore:
8
8
  - 'CHANGELOG.md'
9
9
  - 'package.json'
10
+ - '.github/workflows/test-publish.yml'
10
11
  workflow_dispatch:
11
12
 
12
13
  jobs:
@@ -27,9 +28,12 @@ jobs:
27
28
  - name: Setup Node.js
28
29
  uses: actions/setup-node@v4
29
30
  with:
30
- node-version: '22'
31
+ node-version: '24'
31
32
  registry-url: 'https://registry.npmjs.org'
32
33
 
34
+ - name: Update npm
35
+ run: npm install -g npm@latest
36
+
33
37
  - name: Install dependencies
34
38
  run: npm install
35
39
 
@@ -37,3 +41,40 @@ jobs:
37
41
  env:
38
42
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39
43
  run: npx semantic-release
44
+
45
+ - name: Publish to npm
46
+ run: npm publish --provenance --access public
47
+
48
+ - name: Get version
49
+ id: version
50
+ run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
51
+
52
+ - name: Checkout Actions
53
+ if: steps.version.outputs.version != ''
54
+ uses: actions/checkout@v4
55
+ with:
56
+ repository: odac-run/actions
57
+ token: ${{ secrets.GH_PAT }}
58
+ path: .github/odac-actions
59
+
60
+ - name: Generate Release Notes
61
+ id: ai_notes
62
+ if: steps.version.outputs.version != ''
63
+ uses: ./.github/odac-actions/actions/release-notes
64
+ with:
65
+ github-token: ${{ secrets.GITHUB_TOKEN }}
66
+ michelangelo: ${{ secrets.MICHELANGELO }}
67
+ timeout-minutes: 15
68
+ continue-on-error: true
69
+
70
+ - name: Cleanup Actions
71
+ if: always()
72
+ run: rm -rf .github/odac-actions
73
+ - name: Update Release
74
+ uses: softprops/action-gh-release@v1
75
+ if: steps.ai_notes.outcome == 'success' && steps.version.outputs.version != ''
76
+ with:
77
+ tag_name: v${{ steps.version.outputs.version }}
78
+ body_path: RELEASE_NOTE.md
79
+ draft: false
80
+ prerelease: false
@@ -20,7 +20,7 @@ jobs:
20
20
 
21
21
  strategy:
22
22
  matrix:
23
- node-version: 22.x
23
+ node-version: [18.x, 24.x]
24
24
 
25
25
  steps:
26
26
  - name: Checkout code
@@ -41,19 +41,20 @@ jobs:
41
41
  run: npm test
42
42
 
43
43
  - name: Upload coverage reports
44
- if: matrix.node-version == '22.x'
45
- uses: codecov/codecov-action@v3
44
+ if: matrix.node-version == '18.x'
45
+ uses: codecov/codecov-action@v4
46
46
  with:
47
47
  files: ./coverage/lcov.info
48
48
  flags: unittests
49
49
  name: codecov-umbrella
50
50
  fail_ci_if_error: false
51
+ token: ${{ secrets.CODECOV_TOKEN }}
51
52
 
52
53
  - name: Coverage Summary
53
- if: matrix.node-version == '22.x'
54
+ if: matrix.node-version == '18.x'
54
55
  run: |
55
56
  echo "## Test Coverage Summary" >> $GITHUB_STEP_SUMMARY
56
57
  echo "" >> $GITHUB_STEP_SUMMARY
57
58
  echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
58
- npx nyc report --reporter=text-summary >> $GITHUB_STEP_SUMMARY || echo "Coverage report not available" >> $GITHUB_STEP_SUMMARY
59
+ npx nyc report --reporter=text-summary --temp-directory=coverage >> $GITHUB_STEP_SUMMARY || echo "Coverage report not available" >> $GITHUB_STEP_SUMMARY
59
60
  echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
@@ -0,0 +1,36 @@
1
+ name: Test Publish Authentication
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ permissions:
7
+ contents: read
8
+ id-token: write
9
+
10
+ jobs:
11
+ test-publish:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Setup Node.js
18
+ uses: actions/setup-node@v4
19
+ with:
20
+ node-version: '24'
21
+
22
+ - name: Update npm
23
+ run: npm install -g npm@latest
24
+
25
+ - name: Install dependencies
26
+ run: npm ci
27
+
28
+ - name: Debug Environment
29
+ run: |
30
+ npm --version
31
+ node --version
32
+ npm config list
33
+ ls -la .npmrc || echo "No local .npmrc"
34
+
35
+ - name: Test Publish (Real Attempt)
36
+ run: npm publish --provenance --access public --registry https://registry.npmjs.org/
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ echo "🔍 Running Pre-commit Hooks..."
5
+
6
+ # Run linting and formatting on staged files
7
+ npx lint-staged
8
+
9
+ # Run tests for changed files to ensure no regressions
10
+ node test/scripts/check-coverage.js
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ # Prevent pushing code with High/Critical vulnerabilities
5
+ echo "🛡️ Running Security Gate (npm audit)..."
6
+
7
+ npm audit --audit-level=high
8
+
9
+ if [ $? -ne 0 ]; then
10
+ echo "❌ Security Check Failed! High vulnerabilities detected."
11
+ echo "Run 'npm audit fix' or add overrides before pushing."
12
+ exit 1
13
+ fi
package/.releaserc.js CHANGED
@@ -122,16 +122,16 @@ Powered by [⚡ ODAC](https://odac.run)
122
122
  [
123
123
  '@semantic-release/npm',
124
124
  {
125
- provenance: true
125
+ npmPublish: false
126
126
  }
127
127
  ],
128
128
  [
129
129
  '@semantic-release/git',
130
130
  {
131
131
  assets: ['package.json', 'CHANGELOG.md'],
132
- message: '⚡ ODAC v${nextRelease.version} Released'
132
+ message: '⚡ ODAC.JS v${nextRelease.version} Released'
133
133
  }
134
134
  ],
135
135
  '@semantic-release/github'
136
136
  ]
137
- }
137
+ }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,187 @@
1
+ ### agent
2
+
3
+ - Clarify logging strategies for development and production environments
4
+
5
+ ### deps
6
+
7
+ - update `tar` override version and add `@semantic-release/npm` override.
8
+
9
+ ### ⚙️ Engine Tuning
10
+
11
+ - add JSDoc and default parameter to `Auth.user` method for improved clarity and robustness.
12
+ - enable method chaining for cron job condition definitions
13
+ - Enhance cryptographic security by using CSPRNG for token generation, SHA-256 for encryption key derivation, and adding clarifying configuration comments.
14
+ - Improve authentication logic by adopting fail-fast patterns, upfront promise resolution, and optimized loop control, aligning with new code quality guidelines.
15
+ - Improve view file reading by using `fsPromises.open` for better resource management and atomic operations.
16
+ - Migrate route and middleware loading to asynchronous file system operations for improved performance.
17
+ - Remove redundant `fs.existsSync` checks before `fs.mkdirSync` and add `EEXIST` handling for `fs.writeFileSync`.
18
+ - remove unused nodeCrypto import from Config.test.js
19
+ - rename config.json to odac.json for brand consistency
20
+ - Streamline default CSS file creation using `fs.writeFileSync` 'wx' flag.
21
+ - Use raw Buffer for encryption key hashing, aligning with enterprise-grade development standards.
22
+
23
+ ### ⚡️ Performance Upgrades
24
+
25
+ - Implement enterprise-grade HTTP server performance configurations
26
+ - Optimize file serving by eliminating redundant `fs.stat` calls and deriving content length directly from the read file.
27
+ - **route:** implementation of async I/O and metadata caching for static assets
28
+ - **view:** switch to async I/O and implement aggressive production caching
29
+
30
+ ### ✨ What's New
31
+
32
+ - add built-in tailwindcss v4 support with zero-config
33
+ - Enhance cron job scheduling with new `.at()` and `.raw()` methods, update cron documentation.
34
+ - Enhance Tailwind CSS watcher to prioritize local CLI over npx for improved reliability and adjust shell option accordingly.
35
+ - **framework:** add Odac.session() helper and update docs
36
+ - implement Class-Based Controllers support and update docs
37
+ - Implement conditional environment variable loading, configure server workers based on debug mode
38
+ - Replaced bcrypt with native Node.js crypto.scrypt for hashing, removed bcrypt and axios dependencies, and updated related validation checks.
39
+ - support multiple Tailwind CSS entry points in build and dev processes.
40
+
41
+ ### 📚 Documentation
42
+
43
+ - add documentation for multiple CSS file support
44
+ - add project structure overview to README
45
+ - Add Tailwind CSS v4 integration to README features list
46
+ - Introduce architectural and cluster safety notes to Token, Ipc, and Storage modules.
47
+
48
+ ### 🛠️ Fixes & Improvements
49
+
50
+ - Add null safety checks for `odac.Request` and its `header` method when determining the default language.
51
+ - add options support to authenticated routes (GET/POST)
52
+ - Conditionally initialize Odac request-dependent components and provide a dedicated Odac instance with cleanup to cron jobs.
53
+ - Enhance server port configuration to prioritize command-line arguments and environment variables
54
+ - Initialize session in Route.js during form processing to ensure proper session availability before access, aligning with new coding standards.
55
+ - **package:** resolve high severity npm vulnerabilities
56
+ - Prevent form token expiration errors by dynamically generating forms at runtime.
57
+ - Prevent middleware race conditions by synchronously capturing state and improve Tailwind CSS watcher robustness with auto-restart.
58
+ - Refine error message styling in form validation
59
+ - Replace insecure token generation with cryptographically secure random bytes for `token_x` and `token_y`.
60
+ - **session:** change cookie SameSite policy to Lax for OAuth support
61
+
62
+
63
+
64
+ ---
65
+
66
+ Powered by [⚡ ODAC](https://odac.run)
67
+
68
+ ### Fix
69
+
70
+ - Resolve WebSocket handshake error by echoing subprotocol header
71
+
72
+ ### Refactor
73
+
74
+ - Unified WebSocket architecture and fixed race conditions
75
+
76
+ ### deps
77
+
78
+ - update mysql2 dependency to ^3.16.0
79
+
80
+ ### ⚙️ Engine Tuning
81
+
82
+ - Add type checks for page assignments and a null check for the `authPage` method's `authFile` parameter.
83
+ - extract and trim validation rule names for clearer inverse rule processing.
84
+ - extract HTML stripping logic into a private helper method and apply it to text content generation.
85
+ - migrate custom `odac:field` tag to `odac:input` with updated parsing logic and regex patterns.
86
+ - migrate session locking from in-memory object to `Odac.Storage` for persistence.
87
+ - Move form message clearing logic to the beginning of form submission.
88
+ - move middleware execution to occur after URL parameter processing.
89
+ - pass PR body to github-script action via environment variable
90
+ - Remove duplicate data-error-email attribute assignment.
91
+ - rename `requestMagicLink` method to `magic` in Auth and update its usages and documentation
92
+ - Rename authentication token and session cookie keys from 'candy' to 'odac'.
93
+ - rename internal `Odac` class to `_odac`
94
+ - Rename Mysql to Database and implement connection pooling
95
+ - Update default magic link table name from 'magic_links' to 'odac_magic'.
96
+ - Use `crypto.randomBytes` for client and session ID generation instead of MD5 hashing.
97
+ - use `node:crypto.randomBytes` for generating unique IDs instead of `Date.now()` and `Math.random()`
98
+ - use file descriptor for mail template reading to ensure resource closure
99
+
100
+ ### ✨ What's New
101
+
102
+ - add `_odac/form` POST route with CSRF token validation
103
+ - Add `!disposable` validation rule to block temporary email providers by fetching and caching a daily updated blocklist.
104
+ - Add console error for missing controller files
105
+ - Add custom template rendering engine with caching to Mail service and enhance magic link email options.
106
+ - Add magic link rate limiting, expired link cleanup, and open redirect protection for magic link redirects.
107
+ - add passwordless auto-registration for magic links, improve URL query decoding, and disable token validation for the magic link verification route.
108
+ - Add request language property from Accept-Language header, defaulting to 'en'.
109
+ - Add session cooldown for magic link requests and return explicit errors for rate limits, updating documentation.
110
+ - Allow direct page route definition when a file is provided.
111
+ - Allow specifying and using a redirect URL for magic link authentication.
112
+ - emit 'ping' event when receiving a WebSocket PING frame
113
+ - Enable passing variables directly in view configuration objects for page routes and update documentation.
114
+ - Enable sending plain text and raw HTML emails without templates in the mail service.
115
+ - HTML Mail delivery via direct ODAC Mail Server
116
+ - Ignore database table not found errors when looking up users by email.
117
+ - Implement and document auto-clearing of form inputs on successful submission, controllable via a `clear` attribute.
118
+ - Implement backend-to-frontend data sharing via `Odac.share` and…
119
+ - implement built-in IPC system with Memory and Redis drivers
120
+ - Implement dynamic session garbage collection with simple and batch cleaning modes based on session count.
121
+ - Implement graceful shutdown for primary and worker processes in the cluster.
122
+ - Implement magic login functionality
123
+ - Implement magic login functionality with new routes, internal handlers, and form processing, while removing a generic form route.
124
+ - Implement passwordless signup by auto-registering new users during magic link verification and adding `node:crypto` for random password generation.
125
+ - Implement server actions for forms, allowing `Controller.method` as the action and dispatching internally via a generic endpoint.
126
+ - introduce `Odac.DB.nanoid()` helper, centralize its implementation, and update authentication ID generation strategy documentation.
127
+ - Introduce Nano IDs for primary keys and cookie identifiers, streamlining user insertion logic.
128
+ - introduce service classes in a dedicated directory with naming collision handling and refine route authentication logic.
129
+ - Introduce Storage module to encapsulate LMDB operations and session garbage collection.
130
+ - Migrate session management from in-memory to LMDB, enable server clustering, and add session garbage collection.
131
+ - Modernize db layer with magic api and migrations
132
+ - Modernize db layer with magic api and migrations
133
+ - Render form success and error messages as HTML using a new `textToHtml` utility.
134
+ - Return generic success message for user not found when auto-register is enabled to prevent enumeration.
135
+ - Server Clustering & Persistent Session Management
136
+ - support string-based WebSocket controller paths and update documentation
137
+ - Update route loading to execute function-exported route definitions with Odac.
138
+ - Update session private key hashing algorithm from MD5 to SHA256.
139
+
140
+ ### 📚 Documentation
141
+
142
+ - Add magic links documentation.
143
+ - Fix typo in controller classes documentation
144
+ - overhaul README to detail new Node.js framework features, advanced capabilities, updated quick start instructions, and license.
145
+ - remove redundant html code block tag
146
+ - remove server documentation index.
147
+ - Replace old database connection and MySQL guides with new getting started, query basics, advanced queries, and migrations documentation.
148
+ - Standardize framework name capitalization from Odac to ODAC across documentation.
149
+ - Update database interaction examples from `Odac.Mysql` to `Odac.DB`.
150
+ - update database query examples to include `.select()` and variable assignments.
151
+
152
+ ### 🛠️ Fixes & Improvements
153
+
154
+ - Add error handling for cache file access to ensure validation update proceeds.
155
+ - Add explicit response termination for middleware and redirects, and pass page file path to request.
156
+ - Adjust session key counting range
157
+ - Consume all magic link tokens for an email instead of just the used one to prevent reuse.
158
+ - Correct `odac` special variable path resolution by removing `/src` instead of `/framework/src`.
159
+ - Enable `MiddlewareChain` to automatically use auth handlers when created via `Route.auth.use`.
160
+ - Ensure all HTML tags are recursively stripped when converting HTML to plain text.
161
+ - Ignore `data:` and `vbscript:` pseudo-protocols when processing anchor hrefs.
162
+ - Implement form token rotation on successful form submission without redirect and update client-side form with the new token.
163
+ - Initialize cron interval only in the primary cluster process.
164
+ - Introduce `setSession` method for client ID initialization and optimize internal session and cookie storage.
165
+ - log errors when ensuring the magic link table exists instead of ignoring them
166
+ - Log Odac Auth errors when ensuring token table exists instead of ignoring them.
167
+ - Prevent navigation to `data:` and `vbscript:` URLs.
168
+ - re-register form submit handler when its `data-odac-form` attribute changes to ensure correct event capture.
169
+ - recursively strip nested script and style tags when sanitizing HTML
170
+ - Relax sameSite cookie policy to Lax and refactor redirect handling.
171
+ - remove all socket listeners when closing or disconnecting the WebSocket.
172
+ - Remove early exit from token hash check loop to mitigate timing attacks.
173
+ - return non-function default connection properties directly instead of attempting to bind them
174
+ - return registration error on unique check failure.
175
+ - Robustly extract multipart boundary from request body.
176
+ - serve static files via `createReadStream` and pipe streamable content to response.
177
+ - Validate error route cache handler is a function in Request abort method.
178
+
179
+
180
+
181
+ ---
182
+
183
+ Powered by [⚡ ODAC](https://odac.run)
184
+
1
185
  ### 🛠️ Fixes & Improvements
2
186
 
3
187
  - Simplify project initialization by removing directory emptiness validation and extraneous comments.
package/README.md CHANGED
@@ -1,57 +1,76 @@
1
- <p align="center">
2
- <img src="https://odac.run/assets/img/github/header.png?v=1" alt="Odac Header">
3
- </p>
4
1
 
5
- # ⚡ Odac
2
+ # ⚡ ODAC.JS
6
3
 
7
- **Odac** is a lightweight yet powerful server + framework toolkit for building and deploying modern web apps with ease with built-in automation and a developer-first philosophy.
4
+ **ODAC** is a lightweight, high-performance Node.js framework designed to build modern, scalable web applications with ease. It allows developers to focus on building features rather than configuring boilerplate, offering a complete toolkit for web development.
8
5
 
9
6
  ## ✨ Key Features
10
7
 
11
- ### Core Server Features
12
-
13
- * **Blazing Fast & Ultra Light:** Optimized for performance, Odac is significantly lighter and faster than traditional server solutions, ensuring maximum performance with minimal resource usage.
14
- * 🚀 **Zero-Config Hosting:** Leave the complex server configurations to Odac and focus solely on your code. Get your web applications up and running in minutes.
15
- * 🌐 **One Server, Many Domains:** Easily host and manage multiple websites on a single Odac instance, each with its own domain and resources.
16
- * 🔒 **SSL in Seconds:** Secure all your websites in seconds with free, auto-renewing SSL certificates.
17
- * 📬 **Native Mail Server:** A full-featured, built-in mail server (IMAP/SMTP) that allows you to create and manage email accounts for your domains without needing an external service.
18
- * ⚙️ **Process & CLI Monitor:** Keep your applications running smoothly with the integrated process manager and monitor your server from anywhere with the powerful command-line tool.
19
-
20
- ### Integrated Web Framework
21
-
22
- * 🔗 **Custom URLs & Infinite Pages:** Easily create clean, custom URLs and an unlimited number of pages thanks to the powerful routing and skeleton system.
23
- * ✨ **No-Code AJAX:** Automatically enable AJAX for form submissions and page transitions without writing any custom JavaScript, providing your users with a seamless single-page application (SPA) experience.
24
- * 🛡️ **Safe Requests:** Automatically secure all your endpoints against common vulnerabilities like CSRF with built-in token verification for POST and GET requests.
25
- * 🔐 **Auth Made Easy:** Implement user authentication in minutes with built-in session management, password hashing, and ready-to-use login/register forms.
26
- * 🌍 **Global Ready:** Reach a worldwide audience with built-in, automatic multi-language support. The framework simplifies internationalization (i18n).
27
- * **Built-in Cron Jobs:** Schedule and automate recurring tasks with the integrated cron system, perfect for background jobs, data cleanup, and scheduled operations.
8
+ * 🚀 **Developer Friendly:** Simple setup and intuitive API design let you start building immediately.
9
+ * 🎨 **Built-in Tailwind CSS:** Zero-config integration with Tailwind CSS v4. Automatic compilation and optimization out of the box.
10
+ * 🔗 **Powerful Routing:** Create clean, custom URLs and manage infinite pages with a flexible routing system.
11
+ * **Seamless SPA Experience:** Automatic AJAX handling for forms and page transitions eliminates the need for complex client-side code.
12
+ * 🛡️ **Built-in Security:** Automatic CSRF protection and secure default headers keep your application safe.
13
+ * 🔐 **Authentication:** Ready-to-use session management, password hashing, and authentication helpers.
14
+ * 🗄️ **Database Agnostic:** Integrated support for major databases (PostgreSQL, MySQL, SQLite) and Redis via Knex.js.
15
+ * 🌍 **i18n Support:** Native multi-language support to help you reach a global audience.
16
+ * ⏰ **Task Scheduling:** Built-in Cron job system for handling background tasks and recurring operations.
17
+ * ⚡ **Zero-Config Early Hints:** Intelligent HTTP 103 implementation that requires **no setup**. ODAC automatically analyzes your views and serves assets instantly, drastically improving load times without a single line of code.
18
+
19
+ ## 🛠️ Advanced Capabilities
20
+
21
+ ### Cluster-Ready IPC
22
+ Built for scale from day one, ODAC includes a powerful Inter-Process Communication (IPC) system.
23
+ * **Unified API:** Use the same `get`, `set`, `publish`, and `subscribe` methods regardless of the underlying driver.
24
+ * **Zero-Config Clustering:** The default `memory` driver automatically syncs data between Node.js cluster workers without external dependencies.
25
+ * **Redis Support:** Switch to the `redis` driver with a single config change to scale horizontally across multiple servers.
26
+
27
+ ### 🔌 Native WebSocket Support
28
+ Real-time features are a first-class citizen in ODAC.
29
+ * **Integrated Server:** No need for third-party libraries; ODAC features a lightweight, native WebSocket implementation.
30
+ * **Room System:** Easily manage user groups with built-in `join`, `leave`, and `broadcast` to room functionality.
31
+ * **Route Integration:** define WebSocket endpoints directly in your router alongside HTTP routes.
32
+
33
+ ### 🎨 Powerful Templating
34
+ ODAC's view engine combines the power of JavaScript with intuitive HTML tags.
35
+ * **Logic Tags:** Use `<odac:if>`, `<odac:for>`, and `<odac:else>` for clean control flow.
36
+ * **Async Support:** Fully asynchronous rendering allows fetching data directly within your views using `await`.
37
+ * **Safety:** Automatic escaping prevents XSS while allowing raw HTML output when explicitly requested.
28
38
 
29
39
  ## 🚀 Quick Start
30
40
 
31
- > 🔥 **Install with a single command. Works on Linux, macOS, and Windows.**
41
+ Get your new ODAC project up and running in seconds using our CLI.
32
42
 
33
- #### Linux & macOS
43
+ ### Create a new project
34
44
 
35
45
  ```bash
36
- curl -sL https://odac.run/install | sudo bash
46
+ npx odac init my-app
37
47
  ```
38
48
 
39
- #### Windows (PowerShell)
49
+ ### Start development
40
50
 
41
- ```powershell
42
- irm https://odac.run/install | iex
51
+ ```bash
52
+ cd my-app
53
+ npm run dev
43
54
  ```
44
55
 
45
- This command:
56
+ ## 📂 Project Structure
46
57
 
47
- - Installs Node.js (v18+) if missing
48
- - Installs Odac globally via npm
49
- - Prepares your system for development or deployment
58
+ ```
59
+ project/
60
+ ├── class/ # Business logic classes
61
+ ├── controller/ # HTTP request handlers
62
+ ├── middleware/ # Route middlewares
63
+ ├── public/ # Static assets
64
+ ├── route/ # Route definitions
65
+ ├── view/ # HTML templates
66
+ ├── .env # Environment variables
67
+ └── odac.json # App configuration
68
+ ```
50
69
 
51
70
  ## 📚 Documentation
52
71
 
53
- For more detailed information and API reference, please check out our [official documentation website](https://docs.odac.run).
72
+ For detailed guides, API references, and examples, visit our [official documentation](https://docs.odac.run).
54
73
 
55
74
  ## 📄 License
56
75
 
57
- This project is licensed under the AGPL-3.0 License. See the [LICENSE](LICENSE) file for details.
76
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.