radix-cms 0.1.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 (59) hide show
  1. package/.env.example +17 -0
  2. package/CHANGELOG.md +10 -0
  3. package/CONTRIBUTING.md +40 -0
  4. package/LICENSE +197 -0
  5. package/NOTICE +3 -0
  6. package/README.md +126 -56
  7. package/SECURITY.md +22 -0
  8. package/dist/app.js +80 -0
  9. package/dist/config/db.js +66 -0
  10. package/dist/init/dbInit.js +132 -0
  11. package/dist/init/dbInit2.js +234 -0
  12. package/dist/middleware/auth.js +48 -0
  13. package/dist/plugins/my-seo-plugin/index.js +29 -0
  14. package/dist/routes/admin.js +808 -0
  15. package/dist/routes/index.js +218 -0
  16. package/dist/sql/radix.sql +118 -0
  17. package/dist/types/plugin.js +10 -0
  18. package/dist/utils/PluginManager.js +112 -0
  19. package/dist/utils/settings.js +80 -0
  20. package/dist/utils/themeScanner.js +33 -0
  21. package/dist/utils/versionCheck.js +74 -0
  22. package/docs/CMS_CODE_GUIDE.md +372 -0
  23. package/docs/CMS_USER_GUIDE.md +344 -0
  24. package/docs/Publishing Guidelines.txt +14 -0
  25. package/package.json +62 -6
  26. package/public/css/admin.css +178 -0
  27. package/public/css/fallback.css +53 -0
  28. package/public/hello.html +1 -0
  29. package/views/admin/create-page.ejs +82 -0
  30. package/views/admin/dashboard.ejs +44 -0
  31. package/views/admin/edit-page.ejs +87 -0
  32. package/views/admin/edit-user.ejs +45 -0
  33. package/views/admin/login.ejs +39 -0
  34. package/views/admin/media.ejs +79 -0
  35. package/views/admin/pages.ejs +82 -0
  36. package/views/admin/partials/footer.ejs +4 -0
  37. package/views/admin/partials/header.ejs +57 -0
  38. package/views/admin/settings.ejs +91 -0
  39. package/views/admin/setup-admin.ejs +69 -0
  40. package/views/admin/setup-db.ejs +112 -0
  41. package/views/admin/themes.ejs +24 -0
  42. package/views/admin/updates.ejs +79 -0
  43. package/views/admin/users.ejs +107 -0
  44. package/views/defaults/404.ejs +20 -0
  45. package/views/defaults/500.ejs +20 -0
  46. package/views/layouts/admin-layout.ejs +18 -0
  47. package/views/pages/gallery.ejs +5 -0
  48. package/views/pages/hello.ejs +4 -0
  49. package/views/pages/services.ejs +3 -0
  50. package/views/themes/default/assets/css/style.css +199 -0
  51. package/views/themes/default/assets/js/main.js +8 -0
  52. package/views/themes/default/index.ejs +55 -0
  53. package/views/themes/landing/assets/css/style.css +6 -0
  54. package/views/themes/landing/assets/js/main.js +8 -0
  55. package/views/themes/landing/index.ejs +26 -0
  56. package/views/themes/test/default.ejs +0 -0
  57. package/views/themes/test/full-width.ejs +0 -0
  58. package/views/themes/test/landing-page.ejs +0 -0
  59. package/index.js +0 -15
package/.env.example ADDED
@@ -0,0 +1,17 @@
1
+ APP_NAME=Radix
2
+ APP_VERSION=1.0.0
3
+ SITE_URL=localhost
4
+ SITE_PORT=3000
5
+ DB_HOST=
6
+ DB_USER=
7
+ DB_PASSWORD=
8
+ DB_NAME=
9
+ MAIL_HOST=
10
+ MAIL_PORT=
11
+ MAIL_SECURE=
12
+ MAIL_USER=
13
+ MAIL_PASS=
14
+ THEME=default
15
+ SESSION_SECRET=
16
+ STATUS=live
17
+ TINYMCEAPI=
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to Radix CMS are documented here.
4
+
5
+ ## [1.0.0] - 2026-09-07
6
+
7
+ ### Added
8
+
9
+ - Initial public release of Radix CMS.
10
+ - GNU GPL v3.0-or-later licensing and source-file SPDX identifiers.
@@ -0,0 +1,40 @@
1
+ # Contributing to Radix CMS
2
+
3
+ Thank you for your interest in contributing to Radix CMS.
4
+
5
+ ## Before contributing
6
+
7
+ - Review the [README](README.md) for setup and project requirements.
8
+ - Review the [GNU GPL v3.0-or-later license](LICENSE).
9
+ - Do not include credentials, API keys, uploaded files, or other private data in
10
+ issues, pull requests, or commits.
11
+
12
+ ## Development
13
+
14
+ Install dependencies and run the development server:
15
+
16
+ ```powershell
17
+ npm install
18
+ npm run dev
19
+ ```
20
+
21
+ Before submitting a change, build the project and confirm that it completes
22
+ successfully:
23
+
24
+ ```powershell
25
+ npm run build
26
+ ```
27
+
28
+ ## Reporting issues
29
+
30
+ For support requests, please use [the support request form](https://ultraspark.net/request-support/)
31
+ or email [support@ultraspark.net](mailto:support@ultraspark.net).
32
+
33
+ When reporting a bug, include the Radix CMS version, Node.js version, database
34
+ engine/version, reproduction steps, and relevant logs. Remove secrets before
35
+ sharing logs.
36
+
37
+ ## Pull requests
38
+
39
+ Describe the problem and solution, keep changes focused, and mention the
40
+ validation you performed.
package/LICENSE ADDED
@@ -0,0 +1,197 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Freedoms.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated in this License. Sublicensing is not allowed;
177
+ section 10 makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any law fulfilling obligations under article 11 of the
183
+ WIPO copyright treaty adopted on 20 December 1996, or similar laws
184
+ prohibiting or restricting circumvention of such measures.
185
+
186
+ When you convey a covered work, you waive any legal power to forbid
187
+ circumvention of technological measures to the extent such circumvention
188
+ is effected by exercising rights under this License with respect to
189
+ the covered work, and you disclaim any intention to limit operation or
190
+ modification of the work as a means of enforcing, against the work's
191
+ users, your or third parties' legal rights to forbid circumvention of
192
+ technological measures.
193
+
194
+ 4. Conveying Verbatim Copies.
195
+
196
+ You may convey verbatim copies of the Program's source code as you
197
+ receive it, in any medium, provided that you conspicuously and
package/NOTICE ADDED
@@ -0,0 +1,3 @@
1
+ RadixCMS
2
+ Copyright (C) 2026 Ultra Spark Software
3
+ This project is open-source software licensed under the GNU General Public License v3.0.
package/README.md CHANGED
@@ -1,108 +1,178 @@
1
- \# Radix CMS
1
+ # Radix CMS
2
2
 
3
+ Radix CMS is a Node.js and TypeScript content management system for building
4
+ custom websites and web applications. It provides a public site, an
5
+ administration panel, database-backed pages, users and roles, media uploads,
6
+ themes, and site settings.
3
7
 
8
+ ## Features
4
9
 
5
- Basic CMS for building custom web applications.
10
+ - Public pages rendered with Express and EJS
11
+ - Admin dashboard at `/admin`
12
+ - MySQL/MariaDB database storage
13
+ - Page drafts, publishing, archiving, and access roles
14
+ - User roles: Registered, Editor, Manager, and Administrator
15
+ - Media uploads
16
+ - EJS themes and static pages
17
+ - Email and site settings
18
+ - Update checking from the admin panel
6
19
 
20
+ ## Requirements
7
21
 
22
+ - Node.js 18 or newer
23
+ - npm
24
+ - MySQL 8+ or MariaDB
8
25
 
9
- \## Status: Under Active Development 🚧
10
-
11
-
12
-
13
- \*\*Please Note:\*\* This version (`v0.1.0`) is an initial development release and acts as a placeholder to reserve the namespace. A fully working, feature-rich version of the CMS will be uploaded soon.
14
-
15
-
16
-
17
- \---
18
-
19
-
20
-
21
- \## Installation
26
+ ## Installation
22
27
 
28
+ Clone or download the project, then install its dependencies:
23
29
 
30
+ ```powershell
31
+ npm install
32
+ ```
24
33
 
25
- Once published, you can install the package via npm:
34
+ Create a local environment file from the example:
26
35
 
36
+ ```powershell
37
+ Copy-Item .env.example .env
38
+ ```
27
39
 
40
+ On macOS or Linux:
28
41
 
29
42
  ```bash
30
-
31
- npm install radix-cms
32
-
43
+ cp .env.example .env
33
44
  ```
34
45
 
35
- \*(Note: Replace `radix-cms` with your final unique or scoped package name if it changes).\*
36
-
37
-
38
-
39
- \---
46
+ Edit `.env` with your database credentials and a strong session secret. Do not
47
+ commit `.env` or share it publicly.
40
48
 
49
+ Start the development server:
41
50
 
51
+ ```bash
52
+ npm run dev
53
+ ```
42
54
 
43
- \## Usage (v0.1.0 Placeholder)
44
-
45
-
46
-
47
- The current version exports a basic HTTP server function to verify your initialization. You can import and launch the server within your project.
48
-
49
-
50
-
51
- \### Example
52
-
53
-
54
-
55
- Create an `app.js` file in your project and add the following code:
56
-
57
-
55
+ Open the public site at <http://localhost:3000/> and the administration panel
56
+ at <http://localhost:3000/admin>.
58
57
 
59
- ```javascript
58
+ ## First-time setup
60
59
 
61
- const { startCMS } = require('radix-cms');
60
+ If the database settings are incomplete or the database is unavailable, Radix
61
+ redirects to <http://localhost:3000/admin/install>.
62
62
 
63
+ The installer:
63
64
 
65
+ 1. Tests the MySQL/MariaDB connection.
66
+ 2. Saves the database settings to `.env`.
67
+ 3. Creates the database schema and default content.
68
+ 4. Creates the first Administrator account.
69
+ 5. Redirects to the admin login page.
64
70
 
65
- // Start the CMS server with optional custom configuration
71
+ Use the credentials created during setup to sign in at `/admin/login`.
66
72
 
67
- startCMS({
73
+ ## Configuration
68
74
 
69
- &#x20; hostname: '127.0.0.1',
75
+ The main environment variables are:
70
76
 
71
- &#x20; port: 3000
77
+ | Variable | Purpose | Default |
78
+ | --- | --- | --- |
79
+ | `APP_NAME` | Application name shown by the site | `Radix` |
80
+ | `APP_VERSION` | Application version | `0.12.0` |
81
+ | `SITE_URL` | Site URL used by the application | `localhost` |
82
+ | `SITE_PORT` | HTTP port | `3000` |
83
+ | `DB_HOST` | MySQL/MariaDB host | `127.0.0.1` |
84
+ | `DB_PORT` | MySQL/MariaDB port | `3306` |
85
+ | `DB_USER` | Database user | - |
86
+ | `DB_PASSWORD` | Database password | - |
87
+ | `DB_NAME` | Database name | `radix` |
88
+ | `SESSION_SECRET` | Secret used to sign sessions | — |
89
+ | `THEME` | Active theme name | `default` |
90
+ | `STATUS` | Site status setting | `live` |
91
+ | `MAIL_HOST` | SMTP server host | - |
92
+ | `MAIL_PORT` | SMTP server port | - |
93
+ | `MAIL_SECURE` | Whether SMTP uses TLS | - |
94
+ | `MAIL_USER` | SMTP username | - |
95
+ | `MAIL_PASS` | SMTP password | - |
96
+ | `TINYMCEAPI` | Optional TinyMCE API key | - |
72
97
 
73
- });
98
+ The admin settings screen can also manage application settings after the
99
+ initial installation.
74
100
 
75
- ```
101
+ ## npm scripts
76
102
 
103
+ | Command | Description |
104
+ | --- | --- |
105
+ | `npm run dev` | Run the TypeScript application with file watching |
106
+ | `npm run build` | Compile TypeScript into `dist/` and copy the SQL schema |
107
+ | `npm start` | Build the application and start the compiled server |
108
+ | `npm run app` | Start the already-compiled server |
77
109
 
110
+ For a production deployment, build once with `npm run build`, set production
111
+ environment variables, and run the compiled application with `npm run app`.
78
112
 
79
- \### Configuration Options
113
+ ## Customization
80
114
 
115
+ ### Themes
81
116
 
117
+ Public themes are stored in `views/themes/`. A theme can contain an EJS
118
+ template and assets such as CSS and JavaScript. Theme assets are available
119
+ under `/themes/<theme-name>/`.
82
120
 
83
- You can pass an optional configuration object to `startCMS()`:
121
+ ### Static pages
84
122
 
123
+ Static EJS pages can be added to `views/pages/`. For example,
124
+ `views/pages/contact.ejs` can provide a custom `/contact` page.
85
125
 
126
+ ### Dynamic pages
86
127
 
87
- | Property | Type | Default | Description |
128
+ Editors and Administrators can create database-backed pages from the **Pages**
129
+ screen. Each page has a title, slug, status, access role, template, and
130
+ editable content.
88
131
 
89
- | :--- | :--- | :--- | :--- |
132
+ More detailed user and developer documentation is available in:
90
133
 
91
- | `hostname` | `string` | `'127.0.0.1'` | The IP address or hostname the server binds to. |
134
+ - [`docs/CMS_USER_GUIDE.md`](docs/CMS_USER_GUIDE.md)
135
+ - [`docs/CMS_CODE_GUIDE.md`](docs/CMS_CODE_GUIDE.md)
92
136
 
93
- | `port` | `number` | `3000` | The port network traffic will use. |
137
+ ## Production and security notes
94
138
 
139
+ - Use a long, random `SESSION_SECRET`.
140
+ - Never commit `.env`, database passwords, SMTP credentials, or API keys.
141
+ - Run behind HTTPS in production.
142
+ - Use a dedicated database user with only the permissions Radix requires.
143
+ - Back up the database and uploaded media regularly.
144
+ - Review uploaded files and server permissions before exposing the application
145
+ to the public internet.
146
+ - The default Express session store is intended for development. Use a
147
+ production-ready session store for multi-instance or high-traffic
148
+ deployments.
95
149
 
150
+ ## Troubleshooting
96
151
 
97
- \---
152
+ ### The application redirects to `/admin/install`
98
153
 
154
+ Check that `DB_HOST`, `DB_USER`, `DB_PASSWORD`, and `DB_NAME` are present in
155
+ `.env`, and verify that MySQL/MariaDB is running and reachable.
99
156
 
157
+ ### The server starts but pages or templates are missing
100
158
 
101
- \## License
159
+ Run:
102
160
 
161
+ ```bash
162
+ npm run build
163
+ ```
103
164
 
165
+ The compiled application expects the `views/`, `public/`, and generated
166
+ `dist/sql/radix.sql` files to be available.
104
167
 
105
- This project is licensed under the MIT License.
168
+ ## Contributing
106
169
 
170
+ Bug reports and feature requests are welcome through the project's GitHub
171
+ Issues page. Please include the Radix version, Node.js version, database
172
+ engine/version, reproduction steps, and relevant logs. Never include secrets
173
+ from `.env` in an issue.
107
174
 
175
+ ## License
108
176
 
177
+ This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
178
+ Copyright © 2026 Ultra Spark Software
package/SECURITY.md ADDED
@@ -0,0 +1,22 @@
1
+ # Security Policy
2
+
3
+ ## Supported versions
4
+
5
+ Security fixes are intended for the latest supported Radix CMS release. Users
6
+ should keep their installation and dependencies up to date.
7
+
8
+ ## Reporting a vulnerability
9
+
10
+ Please do not report security vulnerabilities in public issues or pull
11
+ requests. Use either of these private support methods:
12
+
13
+ - [Private support request form](https://ultraspark.net/request-support/)
14
+ - [support@ultraspark.net](mailto:support@ultraspark.net)
15
+
16
+ Include a description of the vulnerability, affected version, reproduction
17
+ steps or proof of concept, and any suggested mitigation. Do not include
18
+ production credentials or other sensitive data unless it is necessary for
19
+ investigation.
20
+
21
+ We will acknowledge the report, investigate it, and coordinate disclosure and
22
+ fix details with the reporter.
package/dist/app.js ADDED
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**************************************************************************************************
4
+ * RadixCMS
5
+ *
6
+ * DESCRIPTION: application startup, middleware, and route configuration.
7
+ *
8
+ * Copyright (C) 2026 Ultra Spark Software <salve@ultraspark.net>
9
+ * SPDX-License-Identifier: GPL-3.0-or-later
10
+ **************************************************************************************************/
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const express_1 = __importDefault(require("express"));
16
+ const express_session_1 = __importDefault(require("express-session"));
17
+ const path_1 = __importDefault(require("path"));
18
+ // Import Routers
19
+ const admin_1 = __importDefault(require("./routes/admin"));
20
+ const index_1 = __importDefault(require("./routes/index"));
21
+ const dbInit2_1 = require("./init/dbInit2");
22
+ ``;
23
+ const app = (0, express_1.default)();
24
+ const PORT = process.env.SITE_PORT || 3000;
25
+ let app_name = process.env.APP_NAME || 'Radix';
26
+ let app_version = process.env.APP_VERSION || '0.10.0';
27
+ // ==========================================
28
+ // 1. VIEW ENGINE CONFIGURATION (EJS)
29
+ // ==========================================
30
+ app.set('view engine', 'ejs');
31
+ app.set('views', path_1.default.join(__dirname, '../views'));
32
+ // ==========================================
33
+ // 2. PARSING & SESSION MIDDLEWARE
34
+ // ==========================================
35
+ app.use(express_1.default.json());
36
+ app.use(express_1.default.urlencoded({ extended: true }));
37
+ app.use((0, express_session_1.default)({
38
+ secret: process.env.SESSION_SECRET || 'radix-secret-key-change-this-in-production',
39
+ resave: false,
40
+ saveUninitialized: false,
41
+ cookie: {
42
+ maxAge: 1000 * 60 * 60 * 24 // 24 Hours
43
+ }
44
+ }));
45
+ // ==========================================
46
+ // 3. STATIC FILE SERVING
47
+ // ==========================================
48
+ // Serve public assets (CSS, JS, fonts)
49
+ app.use(express_1.default.static(path_1.default.join(__dirname, '../public')));
50
+ // Serve theme assets such as /themes/default/assets/css/style.css
51
+ app.use('/themes', express_1.default.static(path_1.default.join(__dirname, '../views/themes')));
52
+ // Serve media library uploads dynamically
53
+ app.use('/uploads', express_1.default.static(path_1.default.join(__dirname, '../public/uploads')));
54
+ // ==========================================
55
+ // 4. ROUTE MOUNTING
56
+ // ==========================================
57
+ // CRITICAL: /admin MUST be mounted before / so that /:slug does not catch /admin URLs
58
+ app.use('/admin', admin_1.default);
59
+ app.use('/', index_1.default);
60
+ // ==========================================
61
+ // 5. SERVER INITIALIZATION
62
+ // ==========================================
63
+ async function startServer() {
64
+ try {
65
+ await (0, dbInit2_1.initDatabase)();
66
+ }
67
+ catch (err) {
68
+ console.error('Error during DB initialization:', err);
69
+ }
70
+ app.listen(PORT, () => {
71
+ console.log(`\n==================================================`);
72
+ console.log(` 🚀 ${app_name} ${app_version} is running!`);
73
+ console.log(` 🌐 Public Site: http://localhost:${PORT}`);
74
+ console.log(` 🔑 Admin Panel: http://localhost:${PORT}/admin`);
75
+ console.log(`==================================================\n`);
76
+ console.log('Start Time:', new Date().toLocaleString(), '\n');
77
+ });
78
+ }
79
+ startServer();
80
+ exports.default = app;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**************************************************************************************************
3
+ * RadixCMS
4
+ *
5
+ * DESCRIPTION: database connection pool and query helpers.
6
+ *
7
+ * Copyright (C) 2026 Ultra Spark Software <salve@ultraspark.net>
8
+ * SPDX-License-Identifier: GPL-3.0-or-later
9
+ **************************************************************************************************/
10
+ var __importDefault = (this && this.__importDefault) || function (mod) {
11
+ return (mod && mod.__esModule) ? mod : { "default": mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const promise_1 = __importDefault(require("mysql2/promise"));
15
+ const dotenv_1 = __importDefault(require("dotenv"));
16
+ // Load env now; installer may re-load dotenv later when writing .env
17
+ dotenv_1.default.config();
18
+ let pool = null;
19
+ let lastConfigKey = '';
20
+ function makeConfigKey() {
21
+ return `${process.env.DB_HOST || ''}:${process.env.DB_PORT || ''}|${process.env.DB_USER || ''}|${process.env.DB_NAME || ''}`;
22
+ }
23
+ async function ensurePool() {
24
+ const key = makeConfigKey();
25
+ if (pool && key === lastConfigKey)
26
+ return pool;
27
+ // close existing pool if config changed
28
+ if (pool) {
29
+ try {
30
+ await pool.end();
31
+ }
32
+ catch (e) { /* ignore */ }
33
+ pool = null;
34
+ }
35
+ console.log(`[DB Pool] Creating pool for ${process.env.DB_HOST || '127.0.0.1'}:${process.env.DB_PORT || 3306} (user=${process.env.DB_USER || 'unknown'})`);
36
+ pool = promise_1.default.createPool({
37
+ host: process.env.DB_HOST || '127.0.0.1',
38
+ user: process.env.DB_USER,
39
+ password: process.env.DB_PASSWORD,
40
+ database: process.env.DB_NAME,
41
+ port: Number(process.env.DB_PORT) || 3306,
42
+ waitForConnections: true,
43
+ connectionLimit: 10,
44
+ queueLimit: 0,
45
+ connectTimeout: 5000
46
+ });
47
+ lastConfigKey = key;
48
+ return pool;
49
+ }
50
+ exports.default = {
51
+ async execute(sql, params) {
52
+ const p = await ensurePool();
53
+ // mysql2's execute has its own stricter generic constraints; cast the result to preserve caller generics
54
+ const res = await p.execute(sql, params);
55
+ return res;
56
+ },
57
+ async query(sql, params) {
58
+ const p = await ensurePool();
59
+ const res = await p.query(sql, params);
60
+ return res;
61
+ },
62
+ async getConnection() {
63
+ const p = await ensurePool();
64
+ return p.getConnection();
65
+ }
66
+ };