odac 0.9.0 → 1.0.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 (208) hide show
  1. package/.github/workflows/auto-pr-description.yml +0 -2
  2. package/.github/workflows/codeql.yml +46 -0
  3. package/.github/workflows/release.yml +13 -6
  4. package/.github/workflows/test-coverage.yml +10 -9
  5. package/.releaserc.js +9 -6
  6. package/CHANGELOG.md +62 -150
  7. package/CODE_OF_CONDUCT.md +1 -1
  8. package/CONTRIBUTING.md +8 -8
  9. package/LICENSE +21 -661
  10. package/README.md +12 -12
  11. package/SECURITY.md +4 -4
  12. package/bin/odac.js +101 -0
  13. package/{framework/web/candy.js → client/odac.js} +310 -44
  14. package/docs/backend/01-overview/{01-whats-in-the-candy-box.md → 01-whats-in-the-odac-box.md} +4 -2
  15. package/docs/backend/01-overview/02-super-handy-helper-functions.md +29 -1
  16. package/docs/backend/01-overview/03-development-server.md +11 -11
  17. package/docs/backend/02-structure/01-typical-project-layout.md +4 -4
  18. package/docs/backend/03-config/00-configuration-overview.md +6 -6
  19. package/docs/backend/03-config/01-database-connection.md +1 -1
  20. package/docs/backend/03-config/02-static-route-mapping-optional.md +4 -4
  21. package/docs/backend/03-config/04-environment-variables.md +20 -20
  22. package/docs/backend/03-config/05-early-hints.md +4 -4
  23. package/docs/backend/04-routing/01-basic-page-routes.md +4 -4
  24. package/docs/backend/04-routing/02-controller-less-view-routes.md +5 -5
  25. package/docs/backend/04-routing/03-api-and-data-routes.md +3 -3
  26. package/docs/backend/04-routing/04-authentication-aware-routes.md +5 -5
  27. package/docs/backend/04-routing/05-advanced-routing.md +3 -3
  28. package/docs/backend/04-routing/06-error-pages.md +17 -17
  29. package/docs/backend/04-routing/07-cron-jobs.md +13 -13
  30. package/docs/backend/04-routing/08-middleware.md +214 -0
  31. package/docs/backend/04-routing/09-websocket-auth-middleware.md +292 -0
  32. package/docs/backend/04-routing/09-websocket-examples.md +381 -0
  33. package/docs/backend/04-routing/09-websocket-quick-reference.md +211 -0
  34. package/docs/backend/04-routing/09-websocket.md +298 -0
  35. package/docs/backend/05-controllers/01-how-to-build-a-controller.md +3 -3
  36. package/docs/backend/05-controllers/02-your-trusty-odac-assistant.md +41 -0
  37. package/docs/backend/05-controllers/03-controller-classes.md +19 -19
  38. package/docs/backend/05-forms/01-custom-forms.md +114 -114
  39. package/docs/backend/05-forms/02-automatic-database-insert.md +82 -82
  40. package/docs/backend/06-request-and-response/01-the-request-object-what-is-the-user-asking-for.md +26 -26
  41. package/docs/backend/06-request-and-response/02-sending-a-response-replying-to-the-user.md +10 -10
  42. package/docs/backend/07-views/01-the-view-directory.md +1 -1
  43. package/docs/backend/07-views/02-rendering-a-view.md +22 -22
  44. package/docs/backend/07-views/03-template-syntax.md +52 -52
  45. package/docs/backend/07-views/03-variables.md +84 -84
  46. package/docs/backend/07-views/04-request-data.md +57 -57
  47. package/docs/backend/07-views/05-conditionals.md +78 -78
  48. package/docs/backend/07-views/06-loops.md +114 -114
  49. package/docs/backend/07-views/07-translations.md +66 -66
  50. package/docs/backend/07-views/08-backend-javascript.md +103 -103
  51. package/docs/backend/07-views/09-comments.md +71 -71
  52. package/docs/backend/08-database/01-database-connection.md +8 -8
  53. package/docs/backend/08-database/02-using-mysql.md +49 -49
  54. package/docs/backend/09-validation/01-the-validator-service.md +38 -38
  55. package/docs/backend/10-authentication/01-user-logins-with-authjs.md +15 -15
  56. package/docs/backend/10-authentication/02-foiling-villains-with-csrf-protection.md +10 -10
  57. package/docs/backend/10-authentication/03-register.md +12 -12
  58. package/docs/backend/10-authentication/{04-candy-register-forms.md → 04-odac-register-forms.md} +141 -141
  59. package/docs/backend/10-authentication/05-session-management.md +10 -10
  60. package/docs/backend/10-authentication/{06-candy-login-forms.md → 06-odac-login-forms.md} +125 -125
  61. package/docs/backend/11-mail/01-the-mail-service.md +5 -5
  62. package/docs/backend/12-streaming/01-streaming-overview.md +96 -54
  63. package/docs/backend/13-utilities/{01-candy-var.md → 01-odac-var.md} +109 -109
  64. package/docs/frontend/01-overview/01-introduction.md +30 -30
  65. package/docs/frontend/02-ajax-navigation/01-quick-start.md +45 -45
  66. package/docs/frontend/02-ajax-navigation/02-configuration.md +14 -14
  67. package/docs/frontend/02-ajax-navigation/03-advanced-usage.md +36 -36
  68. package/docs/frontend/03-forms/01-form-handling.md +32 -32
  69. package/docs/frontend/04-api-requests/01-get-post.md +33 -33
  70. package/docs/frontend/05-streaming/01-client-streaming.md +15 -15
  71. package/docs/frontend/06-websocket/00-overview.md +76 -0
  72. package/docs/frontend/06-websocket/01-websocket-client.md +139 -0
  73. package/docs/frontend/06-websocket/02-shared-websocket.md +149 -0
  74. package/docs/index.json +49 -11
  75. package/eslint.config.mjs +6 -6
  76. package/{framework/index.js → index.js} +1 -1
  77. package/package.json +14 -39
  78. package/{framework/src → src}/Auth.js +59 -59
  79. package/{framework/src → src}/Config.js +3 -3
  80. package/{framework/src → src}/Lang.js +7 -7
  81. package/{framework/src → src}/Mail.js +5 -5
  82. package/{framework/src → src}/Mysql.js +42 -42
  83. package/src/Odac.js +112 -0
  84. package/{framework/src → src}/Request.js +38 -36
  85. package/{framework/src → src}/Route/Internal.js +116 -116
  86. package/src/Route/Middleware.js +75 -0
  87. package/src/Route.js +621 -0
  88. package/src/Server.js +22 -0
  89. package/{framework/src → src}/Stream.js +11 -3
  90. package/{framework/src → src}/Validator.js +21 -21
  91. package/{framework/src → src}/Var.js +5 -5
  92. package/{framework/src → src}/View/EarlyHints.js +1 -1
  93. package/{framework/src → src}/View/Form.js +69 -69
  94. package/{framework/src → src}/View.js +78 -81
  95. package/src/WebSocket.js +403 -0
  96. package/template/config.json +5 -0
  97. package/{web → template}/controller/page/about.js +6 -6
  98. package/{web → template}/controller/page/index.js +9 -9
  99. package/{web → template}/package.json +4 -5
  100. package/{web → template}/public/assets/css/style.css +4 -4
  101. package/{web → template}/public/assets/js/app.js +6 -6
  102. package/{web → template}/route/www.js +6 -6
  103. package/{web → template}/skeleton/main.html +1 -1
  104. package/{web → template}/view/content/about.html +5 -5
  105. package/{web → template}/view/content/home.html +12 -12
  106. package/template/view/footer/main.html +11 -0
  107. package/{web → template}/view/head/main.html +1 -1
  108. package/{web → template}/view/header/main.html +2 -2
  109. package/test/core/Candy.test.js +58 -58
  110. package/test/core/Commands.test.js +7 -7
  111. package/test/core/Config.test.js +82 -85
  112. package/test/core/Lang.test.js +2 -2
  113. package/test/core/Process.test.js +6 -6
  114. package/test/framework/Route.test.js +56 -37
  115. package/test/framework/View/EarlyHints.test.js +2 -2
  116. package/test/framework/WebSocket.test.js +100 -0
  117. package/test/framework/middleware.test.js +85 -0
  118. package/test/server/Api.test.js +31 -31
  119. package/test/server/DNS.test.js +11 -11
  120. package/test/server/Hub.test.js +497 -0
  121. package/test/server/Mail.account.test_.js +3 -3
  122. package/test/server/Mail.init.test_.js +10 -10
  123. package/test/server/Mail.test_.js +20 -20
  124. package/test/server/SSL.test_.js +54 -54
  125. package/test/server/Server.test.js +39 -39
  126. package/test/server/Service.test_.js +7 -7
  127. package/test/server/Subdomain.test.js +7 -7
  128. package/test/server/Web/Firewall.test.js +87 -87
  129. package/test/server/Web/Proxy.test.js +397 -0
  130. package/test/server/{Web.test_.js → Web.test.js} +137 -205
  131. package/test/server/__mocks__/fs.js +2 -2
  132. package/test/server/__mocks__/{globalCandy.js → globalOdac.js} +5 -5
  133. package/test/server/__mocks__/index.js +6 -6
  134. package/test/server/__mocks__/testFactories.js +1 -1
  135. package/test/server/__mocks__/testHelpers.js +7 -7
  136. package/.husky/pre-commit +0 -2
  137. package/.kiro/steering/code-style.md +0 -56
  138. package/.kiro/steering/product.md +0 -20
  139. package/.kiro/steering/structure.md +0 -77
  140. package/.kiro/steering/tech.md +0 -87
  141. package/AGENTS.md +0 -84
  142. package/bin/candy +0 -10
  143. package/bin/candypack +0 -10
  144. package/cli/index.js +0 -3
  145. package/cli/src/Cli.js +0 -348
  146. package/cli/src/Connector.js +0 -93
  147. package/cli/src/Monitor.js +0 -416
  148. package/core/Candy.js +0 -87
  149. package/core/Commands.js +0 -239
  150. package/core/Config.js +0 -1094
  151. package/core/Lang.js +0 -52
  152. package/core/Log.js +0 -43
  153. package/core/Process.js +0 -26
  154. package/docs/backend/05-controllers/02-your-trusty-candy-assistant.md +0 -20
  155. package/docs/server/01-installation/01-quick-install.md +0 -19
  156. package/docs/server/01-installation/02-manual-installation-via-npm.md +0 -9
  157. package/docs/server/02-get-started/01-core-concepts.md +0 -7
  158. package/docs/server/02-get-started/02-basic-commands.md +0 -57
  159. package/docs/server/02-get-started/03-cli-reference.md +0 -276
  160. package/docs/server/02-get-started/04-cli-quick-reference.md +0 -102
  161. package/docs/server/03-service/01-start-a-new-service.md +0 -57
  162. package/docs/server/03-service/02-delete-a-service.md +0 -48
  163. package/docs/server/04-web/01-create-a-website.md +0 -36
  164. package/docs/server/04-web/02-list-websites.md +0 -9
  165. package/docs/server/04-web/03-delete-a-website.md +0 -29
  166. package/docs/server/05-subdomain/01-create-a-subdomain.md +0 -32
  167. package/docs/server/05-subdomain/02-list-subdomains.md +0 -33
  168. package/docs/server/05-subdomain/03-delete-a-subdomain.md +0 -41
  169. package/docs/server/06-ssl/01-renew-an-ssl-certificate.md +0 -34
  170. package/docs/server/07-mail/01-create-a-mail-account.md +0 -23
  171. package/docs/server/07-mail/02-delete-a-mail-account.md +0 -20
  172. package/docs/server/07-mail/03-list-mail-accounts.md +0 -20
  173. package/docs/server/07-mail/04-change-account-password.md +0 -23
  174. package/framework/src/Candy.js +0 -81
  175. package/framework/src/Route.js +0 -455
  176. package/framework/src/Server.js +0 -15
  177. package/locale/de-DE.json +0 -80
  178. package/locale/en-US.json +0 -79
  179. package/locale/es-ES.json +0 -80
  180. package/locale/fr-FR.json +0 -80
  181. package/locale/pt-BR.json +0 -80
  182. package/locale/ru-RU.json +0 -80
  183. package/locale/tr-TR.json +0 -85
  184. package/locale/zh-CN.json +0 -80
  185. package/server/index.js +0 -5
  186. package/server/src/Api.js +0 -88
  187. package/server/src/DNS.js +0 -940
  188. package/server/src/Hub.js +0 -535
  189. package/server/src/Mail.js +0 -571
  190. package/server/src/SSL.js +0 -180
  191. package/server/src/Server.js +0 -27
  192. package/server/src/Service.js +0 -248
  193. package/server/src/Subdomain.js +0 -64
  194. package/server/src/Web/Firewall.js +0 -170
  195. package/server/src/Web/Proxy.js +0 -134
  196. package/server/src/Web.js +0 -451
  197. package/server/src/mail/imap.js +0 -1091
  198. package/server/src/mail/server.js +0 -32
  199. package/server/src/mail/smtp.js +0 -786
  200. package/test/server/Client.test.js +0 -338
  201. package/test/server/__mocks__/http-proxy.js +0 -105
  202. package/watchdog/index.js +0 -3
  203. package/watchdog/src/Watchdog.js +0 -156
  204. package/web/config.json +0 -5
  205. package/web/view/footer/main.html +0 -11
  206. /package/{framework/src → src}/Env.js +0 -0
  207. /package/{framework/src → src}/Route/Cron.js +0 -0
  208. /package/{framework/src → src}/Token.js +0 -0
@@ -12,10 +12,10 @@ const resetFileSystem = () => {
12
12
  mockDirectories.clear()
13
13
 
14
14
  // Add some default directories
15
- mockDirectories.add('/var/candypack')
15
+ mockDirectories.add('/var/odac')
16
16
  mockDirectories.add('/etc/ssl/private')
17
17
  mockDirectories.add('/etc/ssl/certs')
18
- mockDirectories.add('/home/user/.candypack')
18
+ mockDirectories.add('/home/user/.odac')
19
19
  }
20
20
 
21
21
  // Initialize with default state
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Comprehensive mock for the global Candy object used in server tests
2
+ * Comprehensive mock for the global Odac object used in server tests
3
3
  * Provides mocked implementations of core(), server(), cli(), and watchdog() methods
4
4
  */
5
5
 
6
- class MockCandyPack {
6
+ class MockOdac {
7
7
  constructor() {
8
8
  this._registry = new Map()
9
9
  this._singletons = new Map()
@@ -215,13 +215,13 @@ class MockCandyPack {
215
215
  }
216
216
 
217
217
  // Create the global mock instance
218
- const mockCandy = new MockCandyPack()
218
+ const mockOdac = new MockOdac()
219
219
 
220
220
  // Mock the global __ function
221
221
  const mockLangGet = jest.fn(key => key)
222
222
 
223
223
  module.exports = {
224
- mockCandy,
224
+ mockOdac,
225
225
  mockLangGet,
226
- MockCandyPack
226
+ MockOdac
227
227
  }
@@ -14,7 +14,7 @@ const os = require('./os')
14
14
  const path = require('./path')
15
15
 
16
16
  // Import test utilities
17
- const {mockCandy, mockLangGet, MockCandyPack} = require('./globalCandy')
17
+ const {mockCandy, mockLangGet, MockOdac} = require('./globalCandy')
18
18
  const testFactories = require('./testFactories')
19
19
  const testHelpers = require('./testHelpers')
20
20
 
@@ -34,11 +34,11 @@ const setupNodeMocks = () => {
34
34
  }
35
35
 
36
36
  /**
37
- * Setup global mocks (Candy and __ function)
37
+ * Setup global mocks (Odac and __ function)
38
38
  * Call this in beforeEach to set up global mocks
39
39
  */
40
40
  const setupGlobalMocks = () => {
41
- global.Candy = mockCandy
41
+ global.Odac = mockCandy
42
42
  global.__ = mockLangGet
43
43
 
44
44
  // Clear all previous mock calls
@@ -66,7 +66,7 @@ const cleanupAllMocks = () => {
66
66
  path.__resetMocks()
67
67
 
68
68
  // Reset global references
69
- delete global.Candy
69
+ delete global.Odac
70
70
  delete global.__
71
71
  }
72
72
 
@@ -93,7 +93,7 @@ const createTestEnvironment = () => {
93
93
 
94
94
  // Global mocks
95
95
  global: {
96
- Candy: mockCandy,
96
+ Odac: mockCandy,
97
97
  __: mockLangGet
98
98
  },
99
99
 
@@ -233,7 +233,7 @@ module.exports = {
233
233
  // Global mocks
234
234
  mockCandy,
235
235
  mockLangGet,
236
- MockCandyPack,
236
+ MockOdac,
237
237
 
238
238
  // Test utilities
239
239
  testFactories,
@@ -9,7 +9,7 @@
9
9
  const createMockWebsiteConfig = (domain = 'example.com', overrides = {}) => {
10
10
  return {
11
11
  domain,
12
- path: `/var/candypack/${domain}`,
12
+ path: `/var/odac/${domain}`,
13
13
  subdomain: ['www'],
14
14
  cert: {
15
15
  ssl: {
@@ -3,21 +3,21 @@
3
3
  * Provides helper functions to reduce boilerplate in server tests
4
4
  */
5
5
 
6
- const {mockCandy, mockLangGet} = require('./globalCandy')
6
+ const {mockOdac, mockLangGet} = require('./globalOdac')
7
7
 
8
8
  /**
9
- * Sets up the global Candy mock and __ function for tests
9
+ * Sets up the global Odac mock and __ function for tests
10
10
  * Should be called in beforeEach or beforeAll
11
11
  */
12
12
  const setupGlobalMocks = () => {
13
- // Set up global Candy mock
14
- global.Candy = mockCandy
13
+ // Set up global Odac mock
14
+ global.Odac = mockOdac
15
15
 
16
16
  // Set up global __ function mock
17
17
  global.__ = mockLangGet
18
18
 
19
19
  // Clear all previous mock calls
20
- mockCandy.clearMocks()
20
+ mockOdac.clearMocks()
21
21
  mockLangGet.mockClear()
22
22
  }
23
23
 
@@ -26,11 +26,11 @@ const setupGlobalMocks = () => {
26
26
  * Should be called in afterEach or afterAll
27
27
  */
28
28
  const cleanupGlobalMocks = () => {
29
- mockCandy.resetMocks()
29
+ mockOdac.resetMocks()
30
30
  mockLangGet.mockClear()
31
31
 
32
32
  // Reset global references
33
- delete global.Candy
33
+ delete global.Odac
34
34
  delete global.__
35
35
  }
36
36
 
package/.husky/pre-commit DELETED
@@ -1,2 +0,0 @@
1
- npx lint-staged
2
- node test/scripts/check-coverage.js
@@ -1,56 +0,0 @@
1
- ---
2
- inclusion: always
3
- ---
4
-
5
- # Code Style Guidelines
6
-
7
- ## Comments
8
-
9
- - **Language**: All code comments MUST be written in English
10
- - **Minimalism**: Avoid unnecessary comments - write self-documenting code instead
11
- - **When to comment**: Only add comments when the code's intent is not immediately clear from the code itself
12
- - **What not to comment**:
13
- - Obvious operations (e.g., `// Set variable` before `x = 5`)
14
- - Code that explains itself through clear naming
15
- - Redundant descriptions of what the code does
16
-
17
- ## Examples
18
-
19
- ### Bad (unnecessary comments):
20
- ```javascript
21
- // Get user email
22
- const email = user.email
23
-
24
- // Loop through items
25
- for (const item of items) {
26
- // Process item
27
- processItem(item)
28
- }
29
- ```
30
-
31
- ### Good (self-documenting):
32
- ```javascript
33
- const email = user.email
34
-
35
- for (const item of items) {
36
- processItem(item)
37
- }
38
- ```
39
-
40
- ### Good (necessary comment):
41
- ```javascript
42
- // ACME protocol requires 30-second delay between retries
43
- await sleep(30000)
44
-
45
- // Workaround for MySQL connection pool bug in v2.3.0
46
- if (connection.threadId === null) {
47
- connection = await reconnect()
48
- }
49
- ```
50
-
51
- ## General Principles
52
-
53
- - Let the code speak for itself through clear variable and function names
54
- - Use comments sparingly to explain "why" not "what"
55
- - Keep comments concise and to the point
56
- - Update or remove comments when code changes
@@ -1,20 +0,0 @@
1
- # CandyPack Product Overview
2
-
3
- CandyPack is a next-generation server and framework toolkit that combines hosting infrastructure with a web development framework. It's designed as a lightweight, zero-config solution for building and deploying modern web applications.
4
-
5
- ## Core Components
6
-
7
- - **Server**: Full-featured hosting platform with DNS, SSL, mail server (IMAP/SMTP), and multi-domain support
8
- - **Backend**: Web application framework with routing, authentication, CSRF protection, and internationalization
9
- - **Frontend**: Client-side framework (candy.js) with AJAX navigation, form handling, and API requests
10
- - **CLI**: Command-line interface for server management and deployment
11
- - **Watchdog**: Process monitoring and management system
12
-
13
- ## Key Philosophy
14
-
15
- - **Developer-first**: Zero-config approach, focus on code rather than infrastructure
16
- - **Performance-oriented**: Lightweight and optimized for speed
17
- - **Security-focused**: Built-in CSRF protection, SSL automation, secure defaults
18
- - **Global-ready**: Multi-language support and internationalization built-in
19
-
20
- The project follows AGPL-3.0 licensing and targets Node.js 18+ environments.
@@ -1,77 +0,0 @@
1
- # Project Structure & Architecture
2
-
3
- ## Directory Organization
4
-
5
- ```
6
- ├── bin/ # Executable binaries (candy, candypack)
7
- ├── cli/ # Command-line interface
8
- │ └── src/ # CLI implementation (Cli.js, Connector.js, Monitor.js)
9
- ├── core/ # Core dependency injection system
10
- ├── framework/ # Web framework implementation
11
- │ ├── src/ # Framework modules (Auth, Route, Server, etc.)
12
- │ └── web/ # Client-side JavaScript (candy.js)
13
- ├── server/ # Server infrastructure
14
- │ └── src/ # Server modules (DNS, SSL, Mail, Web, etc.)
15
- ├── watchdog/ # Process monitoring system
16
- ├── web/ # Template website (copied when creating new sites)
17
- │ ├── controller/ # Template controllers
18
- │ ├── package.json # Template package.json with {{domain}} placeholders
19
- │ └── config.json # Template configuration
20
- ├── docs/ # Documentation (backend, frontend & server)
21
- │ ├── index.json # Documentation navigation structure
22
- │ ├── backend/ # Backend documentation files
23
- │ ├── frontend/ # Frontend documentation files
24
- │ └── server/ # Server documentation files
25
- ├── locale/ # Internationalization files
26
- └── test/ # Jest test files
27
- ```
28
-
29
- ## Architecture Patterns
30
-
31
- ### Dependency Injection (Core)
32
-
33
- - **Global Candy**: Singleton registry pattern via `global.Candy`
34
- - **Module Loading**: Dynamic require with `core()`, `cli()`, `server()`, `watchdog()` methods
35
- - **Singleton Management**: Automatic instantiation and caching
36
-
37
- ### Framework Pattern
38
-
39
- - **Request Lifecycle**: Each request gets a fresh Candy instance with req/res context
40
- - **Controller Pattern**: Simple function exports in `controller/` directories
41
- - **Helper Functions**: Global shortcuts (`__()`, `abort()`, `return()`, etc.)
42
-
43
- ### File Naming Conventions
44
-
45
- - **PascalCase**: Class files and main modules (e.g., `Candy.js`, `Server.js`)
46
- - **camelCase**: Utility functions and instances
47
- - **lowercase**: Entry points (`index.js`)
48
-
49
- ### Module Structure
50
-
51
- - Each module can have an optional `init()` method for setup
52
- - Framework modules receive Candy instance for request context
53
- - Server modules are typically singletons for infrastructure
54
-
55
- ### Web Template System
56
-
57
- - **Template Directory**: `web/` serves as the template for new websites
58
- - **Automatic Copying**: When creating a new site, entire `web/` directory is copied
59
- - **Template Variables**: Files can contain placeholders like `{{domain}}` and `{{domain_original}}`
60
- - **Post-Processing**: After copying, template variables are replaced with actual values
61
- - **Template Files**:
62
- - `package.json` - Contains domain placeholders for name and description
63
- - `config.json` - Basic routing configuration
64
- - `controller/` - Example controller implementations
65
-
66
- ### Documentation System
67
-
68
- - **Index File**: `docs/index.json` contains the navigation structure for all documentation
69
- - **Adding New Docs**: When creating new documentation files, they MUST be added to `docs/index.json`
70
- - **Language**: All documentation content must be written in English
71
- - **Structure**: Documentation is organized into THREE sections only:
72
- - `docs/server/` - Server infrastructure documentation (CLI, DNS, SSL, Mail)
73
- - `docs/backend/` - Backend framework documentation (Controllers, Routing, Auth, Database)
74
- - `docs/frontend/` - Frontend documentation (candy.js, AJAX navigation, Forms)
75
- - **IMPORTANT**: There is NO `docs/framework/` directory - backend docs go in `docs/backend/`
76
- - **File Organization**: Each section has folders with numbered prefixes (01-overview, 02-structure, etc.)
77
- - **Navigation**: The index.json file defines the title and hierarchy shown in documentation site
@@ -1,87 +0,0 @@
1
- # Technology Stack & Build System
2
-
3
- ## Tech Stack
4
-
5
- - **Runtime**: Node.js 18+ (required)
6
- - **Language**: JavaScript (ES6+, CommonJS modules)
7
- - **Database**: MySQL2, SQLite3 support
8
- - **Security**: bcrypt, node-forge, ACME client for SSL
9
- - **Mail**: Built-in SMTP/IMAP server with DKIM signing
10
- - **Proxy**: HTTP proxy for multi-domain hosting
11
- - **DNS**: Native DNS server implementation
12
-
13
- ## Code Quality Tools
14
-
15
- - **Linting**: ESLint with Prettier integration
16
- - **Testing**: Jest with coverage reporting (no threshold enforcement)
17
- - **Git Hooks**: Husky with pre-commit linting and test execution
18
- - **Release**: Semantic Release with conventional commits
19
- - **Test Check**: Automatic test execution on commit for changed files (pass/fail only)
20
-
21
- ## Common Commands
22
-
23
- ```bash
24
- # Development
25
- npm run lint # Run ESLint
26
- npm run lint:fix # Fix linting issues automatically
27
- npm test # Run Jest tests with coverage
28
- npm run test:watch # Run tests in watch mode
29
-
30
- # Release
31
- npm run release # Semantic release (automated)
32
-
33
- # Installation
34
- curl -sL https://candypack.dev/install | bash # Quick install
35
- npm install -g candypack # Manual install
36
-
37
- # Git Hooks & CI/CD
38
- # Pre-commit automatically runs:
39
- # 1. lint-staged (ESLint + Prettier on staged files)
40
- # 2. Test execution for changed core/ and server/ files (test/scripts/check-coverage.js)
41
- # Note: Coverage is tracked but doesn't block commits - focus is on test pass/fail
42
-
43
- # GitHub Actions (on PR to main/dev):
44
- # 1. Runs all tests with coverage
45
- # 2. Runs linter
46
- # 3. Tests on Node.js 18.x and 22.x
47
- # 4. Uploads coverage to Codecov
48
- # 5. Comments PR with coverage report
49
- ```
50
-
51
- ## Code Style
52
-
53
- - **Prettier Config**: No semicolons, single quotes, 140 char width, 2-space tabs
54
- - **ESLint**: Separate configs for server/framework/web/browser contexts
55
- - **Globals**: `Candy` and `__` are global variables across the codebase
56
- - **Module System**: CommonJS (`require`/`module.exports`) for server-side code
57
-
58
- ## Logging Standards
59
-
60
- ### Server & Core Modules
61
- - **Log Class**: Use `Candy.core('Log', false).init('ModuleName')` for all logging in `server/` and `core/` directories
62
- - **Usage Pattern**:
63
-
64
- ```javascript
65
- const {log, error} = Candy.core('Log', false).init('ModuleName')
66
-
67
- log('Info message')
68
- log('Message with %s placeholder', 'value')
69
- error('Error message', errorObject)
70
- ```
71
-
72
- - **CLI Mode**: Logs are automatically suppressed in CLI mode to avoid breaking the interface
73
- - **Location**: Log class is in `core/Log.js` (also available via `server/src/Log.js` for backward compatibility)
74
-
75
- ### Framework Modules
76
- - **Console Logging**: Use `console.log()` and `console.error()` directly in `framework/` directory
77
- - **Reason**: Framework runs in user's application context where Log class may not be available
78
- - **Usage Pattern**:
79
-
80
- ```javascript
81
- console.log('[ModuleName] Info message')
82
- console.error('[ModuleName] Error:', error.message)
83
- ```
84
-
85
- ### General Rule
86
- - **Server/Core**: Always use Log class (never `console.log`)
87
- - **Framework**: Always use `console.log` (Log class not guaranteed to be available)
package/AGENTS.md DELETED
@@ -1,84 +0,0 @@
1
- # AGENTS Guidelines for This Repository
2
-
3
- This document provides a comprehensive guide for developers working on the CandyPack source code. It covers the project's architecture, class system, directory structure, and usage patterns.
4
-
5
- ## 1. Project Overview
6
-
7
- CandyPack is a toolkit for building and deploying web applications, consisting of two main parts:
8
- 1. **A Core System**: A background service that manages servers (web, mail, etc.), process monitoring, and provides a command-line interface (CLI).
9
- 2. **A Web Framework**: A lightweight framework for building the actual web applications that are served by the core system.
10
-
11
- ## 2. Core Architecture (`core/Candy.js`)
12
-
13
- The heart of the core system is a service container implemented in `core/Candy.js`. This module creates a global singleton object named `Candy`.
14
-
15
- ### Service Container
16
-
17
- The `Candy` object acts as a service locator and dependency injection container. It can dynamically load and cache modules (services) from different parts of the application.
18
-
19
- - **Registration and Resolution**: Modules are registered with a key and can be resolved (retrieved) using that key. The container handles the instantiation of classes and can cache them as singletons.
20
- - **Module Loaders**: It has dedicated methods for loading modules from specific directories:
21
- - `Candy.core(name)`: Loads a module from the `core/` directory.
22
- - `Candy.cli(name)`: Loads a module from the `cli/src/` directory.
23
- - `Candy.server(name)`: Loads a module from the `server/src/` directory.
24
- - `Candy.watchdog(name)`: Loads a module from the `watchdog/src` directory.
25
-
26
- **Example Usage:**
27
- To access the application's configuration manager (defined in `core/Config.js`), you would use:
28
- ```javascript
29
- const config = Candy.core('Config');
30
- ```
31
-
32
- ## 3. Web Framework Architecture (`framework/src/Candy.js`)
33
-
34
- The web framework provides the tools to build a website or API. Its main entry point is `framework/src/Candy.js`. Unlike the core `Candy` object, the framework creates a **request-specific instance** for every incoming HTTP request.
35
-
36
- ### Request-Specific Context
37
-
38
- When a web request hits the server, the framework's `instance()` method is called to create a `_candy` object. This object is a "context" that holds all the necessary components for handling that specific request.
39
-
40
- This context object includes:
41
- - `Request`: An object representing the incoming HTTP request.
42
- - `View`: A view renderer for HTML pages.
43
- - `Auth`: An authentication manager.
44
- - `Token`: A CSRF token handler.
45
- - `Lang`: An internationalization (i18n) helper.
46
- - `Mysql`: A database connection handler.
47
-
48
- It also attaches numerous helper functions to the context object for convenience within a controller, such as:
49
- - `return(data)`: Ends the request and sends data back to the client.
50
- - `direct(url)`: Redirects the client to a new URL.
51
- - `cookie(key, value)`: Sets a cookie.
52
- - `validator()`: Creates a new input validator.
53
-
54
- This context object is passed to the controller function that handles the route.
55
-
56
- ## 4. Directory Structure Guide
57
-
58
- - `bin/`: Executable scripts for the CLI (`candy`, `candypack`).
59
- - `cli/`: Source code for the CLI. The main logic is in `cli/src/Cli.js`.
60
- - `core/`: Core application logic and shared modules (e.g., `Config.js`, `Commands.js`).
61
- - `framework/`: The source code for the web framework.
62
- - `server/`: Low-level server implementations (HTTP, Mail, DNS, SSL).
63
- - `web/`: **This is a template for a user's website.** When a new site is created with CandyPack, this directory is copied to serve as the starting point.
64
- - `web/index.js`: The entry point for a web application. It initializes the framework.
65
- - `web/route/`: Contains route definition files.
66
- - `web/controller/`: Contains controller files.
67
- - `web/view/`: (Assumed) Would contain HTML templates for the `View` engine.
68
- - `web/config.json`: Application-specific configuration.
69
- - `test/`: Project test files.
70
- - `watchdog/`: A process monitor that ensures the main CandyPack server stays running.
71
-
72
- ## 5. Using the CLI (`bin/candy`)
73
-
74
- The `candy` command is the main tool for managing the CandyPack server.
75
-
76
- - `candy`: Shows the server status (online/offline, uptime, etc.) and lists available commands.
77
- - `candy start`: (Inferred) Starts the CandyPack server daemon.
78
- - `candy stop`: (Inferred) Stops the server.
79
- - `candy restart`: (Inferred) Restarts the server.
80
- - `candy monitor`: Opens an interactive terminal UI to monitor the status of all hosted websites and services.
81
- - `candy debug`: Opens an interactive UI to view live logs from different core modules.
82
- - `candy help <command>`: Shows detailed help for a specific command.
83
-
84
- The commands are defined in `core/Commands.js` and implemented in various modules, primarily `cli/src/Cli.js`.
package/bin/candy DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- let args = process.argv
4
- if(process.argv[0].includes('node')) args = process.argv.slice(1)
5
- if (args[1] === 'framework') {
6
- require('../framework/index.js')
7
- return
8
- }
9
-
10
- require('../cli/index.js')
package/bin/candypack DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- let args = process.argv
4
- if(process.argv[0].includes('node')) args = process.argv.slice(1)
5
- if (args[1] === 'framework') {
6
- require('../framework/index.js')
7
- return
8
- }
9
-
10
- require(args.includes('watchdog') ? '../watchdog/index.js' : '../cli/index.js')
package/cli/index.js DELETED
@@ -1,3 +0,0 @@
1
- require('../core/Candy.js')
2
-
3
- Candy.cli('Cli')