@nitronjs/framework 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/cli/create.js +88 -72
- package/cli/njs.js +14 -7
- package/lib/Auth/Auth.js +167 -0
- package/lib/Build/CssBuilder.js +9 -0
- package/lib/Build/FileAnalyzer.js +16 -0
- package/lib/Build/HydrationBuilder.js +17 -0
- package/lib/Build/Manager.js +15 -0
- package/lib/Build/colors.js +4 -0
- package/lib/Build/plugins.js +84 -20
- package/lib/Console/Commands/DevCommand.js +13 -9
- package/lib/Console/Commands/MakeCommand.js +24 -10
- package/lib/Console/Commands/MigrateCommand.js +0 -1
- package/lib/Console/Commands/MigrateFreshCommand.js +17 -25
- package/lib/Console/Commands/MigrateRollbackCommand.js +6 -3
- package/lib/Console/Commands/MigrateStatusCommand.js +6 -3
- package/lib/Console/Commands/SeedCommand.js +4 -2
- package/lib/Console/Commands/StorageLinkCommand.js +20 -5
- package/lib/Console/Output.js +142 -0
- package/lib/Core/Config.js +2 -1
- package/lib/Core/Paths.js +8 -0
- package/lib/Database/DB.js +141 -51
- package/lib/Database/Drivers/MySQLDriver.js +102 -157
- package/lib/Database/Migration/Checksum.js +3 -8
- package/lib/Database/Migration/MigrationRepository.js +25 -35
- package/lib/Database/Migration/MigrationRunner.js +56 -61
- package/lib/Database/Model.js +157 -83
- package/lib/Database/QueryBuilder.js +31 -0
- package/lib/Database/QueryValidation.js +36 -44
- package/lib/Database/Schema/Blueprint.js +25 -36
- package/lib/Database/Schema/Manager.js +31 -68
- package/lib/Database/Seeder/SeederRunner.js +12 -31
- package/lib/Date/DateTime.js +9 -0
- package/lib/Encryption/Encryption.js +52 -0
- package/lib/Faker/Faker.js +11 -0
- package/lib/Filesystem/Storage.js +120 -0
- package/lib/HMR/Server.js +81 -10
- package/lib/Hashing/Hash.js +41 -0
- package/lib/Http/Server.js +177 -152
- package/lib/Logging/{Manager.js → Log.js} +68 -80
- package/lib/Mail/Mail.js +187 -0
- package/lib/Route/Router.js +416 -0
- package/lib/Session/File.js +135 -233
- package/lib/Session/Manager.js +117 -171
- package/lib/Session/Memory.js +28 -38
- package/lib/Session/Session.js +71 -107
- package/lib/Support/Str.js +103 -0
- package/lib/Translation/Lang.js +54 -0
- package/lib/View/Client/hmr-client.js +94 -51
- package/lib/View/Client/nitronjs-icon.png +0 -0
- package/lib/View/{Manager.js → View.js} +44 -29
- package/lib/index.d.ts +42 -8
- package/lib/index.js +19 -12
- package/package.json +1 -1
- package/skeleton/app/Controllers/HomeController.js +7 -1
- package/skeleton/resources/css/global.css +1 -0
- package/skeleton/resources/views/Site/Home.tsx +456 -79
- package/skeleton/tsconfig.json +6 -1
- package/lib/Auth/Manager.js +0 -111
- package/lib/Database/Connection.js +0 -61
- package/lib/Database/Manager.js +0 -162
- package/lib/Encryption/Manager.js +0 -47
- package/lib/Filesystem/Manager.js +0 -74
- package/lib/Hashing/Manager.js +0 -25
- package/lib/Mail/Manager.js +0 -120
- package/lib/Route/Loader.js +0 -80
- package/lib/Route/Manager.js +0 -286
- package/lib/Translation/Manager.js +0 -49
|
@@ -1,18 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HMR Client - Browser-side hot module replacement handler.
|
|
3
|
+
* Connects to the HMR WebSocket server and handles live updates.
|
|
4
|
+
*/
|
|
1
5
|
(function() {
|
|
2
6
|
"use strict";
|
|
3
7
|
|
|
4
8
|
var socket = null;
|
|
5
|
-
var
|
|
9
|
+
var errorOverlay = null;
|
|
6
10
|
|
|
11
|
+
// Connection
|
|
7
12
|
function connect() {
|
|
8
13
|
if (socket) return;
|
|
14
|
+
|
|
9
15
|
if (typeof io === "undefined") {
|
|
10
16
|
setTimeout(connect, 100);
|
|
17
|
+
|
|
11
18
|
return;
|
|
12
19
|
}
|
|
13
20
|
|
|
14
21
|
try {
|
|
15
|
-
socket = io({
|
|
22
|
+
socket = io({
|
|
23
|
+
path: "/__nitron_hmr",
|
|
24
|
+
transports: ["websocket"],
|
|
25
|
+
reconnection: true,
|
|
26
|
+
reconnectionAttempts: 5,
|
|
27
|
+
reconnectionDelay: 1000,
|
|
28
|
+
timeout: 5000
|
|
29
|
+
});
|
|
16
30
|
}
|
|
17
31
|
catch (e) {
|
|
18
32
|
return;
|
|
@@ -20,147 +34,176 @@
|
|
|
20
34
|
|
|
21
35
|
socket.on("connect", function() {
|
|
22
36
|
window.__nitron_hmr_connected__ = true;
|
|
23
|
-
|
|
37
|
+
hideErrorOverlay();
|
|
24
38
|
});
|
|
25
39
|
|
|
26
40
|
socket.on("disconnect", function() {
|
|
27
41
|
window.__nitron_hmr_connected__ = false;
|
|
28
42
|
});
|
|
29
43
|
|
|
30
|
-
socket.on("
|
|
44
|
+
socket.on("connect_error", function() {
|
|
45
|
+
window.__nitron_hmr_connected__ = false;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
socket.on("hmr:update", function() {
|
|
31
49
|
refetchPage();
|
|
32
50
|
});
|
|
33
51
|
|
|
34
|
-
socket.on("hmr:reload", function(
|
|
52
|
+
socket.on("hmr:reload", function() {
|
|
35
53
|
location.reload();
|
|
36
54
|
});
|
|
37
55
|
|
|
38
56
|
socket.on("hmr:css", function(data) {
|
|
39
|
-
|
|
57
|
+
refreshCss(data.file);
|
|
40
58
|
});
|
|
41
59
|
|
|
42
60
|
socket.on("hmr:error", function(data) {
|
|
43
|
-
|
|
61
|
+
showErrorOverlay(data.message || "Unknown error", data.file);
|
|
44
62
|
});
|
|
45
63
|
}
|
|
46
64
|
|
|
65
|
+
// Page Updates
|
|
47
66
|
function refetchPage() {
|
|
48
67
|
var url = location.pathname + location.search;
|
|
49
|
-
|
|
68
|
+
|
|
50
69
|
fetch("/__nitron/navigate?url=" + encodeURIComponent(url), {
|
|
51
70
|
headers: { "X-Nitron-SPA": "1" },
|
|
52
71
|
credentials: "same-origin"
|
|
53
72
|
})
|
|
54
|
-
.then(function(
|
|
55
|
-
if (!
|
|
56
|
-
|
|
73
|
+
.then(function(response) {
|
|
74
|
+
if (!response.ok) throw new Error("HTTP " + response.status);
|
|
75
|
+
|
|
76
|
+
return response.json();
|
|
57
77
|
})
|
|
58
|
-
.then(function(
|
|
59
|
-
if (
|
|
78
|
+
.then(function(data) {
|
|
79
|
+
if (data.error || data.redirect) {
|
|
60
80
|
location.reload();
|
|
81
|
+
|
|
61
82
|
return;
|
|
62
83
|
}
|
|
63
84
|
|
|
64
|
-
// Find current slot
|
|
65
85
|
var slot = document.querySelector("[data-nitron-slot='page']");
|
|
66
|
-
|
|
86
|
+
|
|
87
|
+
if (!slot || !data.html) {
|
|
67
88
|
location.reload();
|
|
89
|
+
|
|
68
90
|
return;
|
|
69
91
|
}
|
|
70
92
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
tmp.innerHTML = d.html;
|
|
74
|
-
var newSlot = tmp.querySelector("[data-nitron-slot='page']");
|
|
75
|
-
var newContent = newSlot ? newSlot.innerHTML : d.html;
|
|
93
|
+
var container = document.createElement("div");
|
|
94
|
+
container.innerHTML = data.html;
|
|
76
95
|
|
|
77
|
-
|
|
78
|
-
slot.innerHTML =
|
|
96
|
+
var newSlot = container.querySelector("[data-nitron-slot='page']");
|
|
97
|
+
slot.innerHTML = newSlot ? newSlot.innerHTML : data.html;
|
|
79
98
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
Object.assign(window.__NITRON_RUNTIME__, d.runtime);
|
|
99
|
+
if (data.hydrationScript) {
|
|
100
|
+
if (data.runtime && window.__NITRON_RUNTIME__) {
|
|
101
|
+
Object.assign(window.__NITRON_RUNTIME__, data.runtime);
|
|
84
102
|
}
|
|
85
|
-
|
|
86
|
-
|
|
103
|
+
|
|
104
|
+
if (data.props) {
|
|
105
|
+
window.__NITRON_PROPS__ = data.props;
|
|
87
106
|
}
|
|
88
|
-
|
|
107
|
+
|
|
108
|
+
loadHydrationScript(data.hydrationScript);
|
|
89
109
|
}
|
|
90
110
|
})
|
|
91
|
-
.catch(function(
|
|
111
|
+
.catch(function() {
|
|
92
112
|
location.reload();
|
|
93
113
|
});
|
|
94
114
|
}
|
|
95
115
|
|
|
96
|
-
function
|
|
116
|
+
function loadHydrationScript(scriptPath) {
|
|
97
117
|
var script = document.createElement("script");
|
|
98
118
|
script.type = "module";
|
|
99
119
|
script.src = "/storage" + scriptPath + "?t=" + Date.now();
|
|
120
|
+
|
|
100
121
|
script.onload = function() {
|
|
101
122
|
if (window.__NITRON_REFRESH__) {
|
|
102
123
|
try {
|
|
103
124
|
window.__NITRON_REFRESH__.performReactRefresh();
|
|
104
|
-
}
|
|
125
|
+
}
|
|
126
|
+
catch (e) {}
|
|
105
127
|
}
|
|
128
|
+
|
|
106
129
|
script.remove();
|
|
107
130
|
};
|
|
131
|
+
|
|
108
132
|
document.head.appendChild(script);
|
|
109
133
|
}
|
|
110
134
|
|
|
111
|
-
|
|
135
|
+
// CSS Updates
|
|
136
|
+
function refreshCss(filename) {
|
|
112
137
|
var links = document.querySelectorAll('link[rel="stylesheet"]');
|
|
113
138
|
var timestamp = Date.now();
|
|
114
139
|
|
|
115
|
-
if (!
|
|
140
|
+
if (!filename) {
|
|
116
141
|
for (var i = 0; i < links.length; i++) {
|
|
117
142
|
var href = (links[i].href || "").split("?")[0];
|
|
118
143
|
links[i].href = href + "?t=" + timestamp;
|
|
119
144
|
}
|
|
145
|
+
|
|
120
146
|
return;
|
|
121
147
|
}
|
|
122
148
|
|
|
123
149
|
var found = false;
|
|
124
|
-
var target =
|
|
150
|
+
var target = filename.split(/[\\/]/).pop();
|
|
125
151
|
|
|
126
152
|
for (var i = 0; i < links.length; i++) {
|
|
127
153
|
var href = (links[i].href || "").split("?")[0];
|
|
154
|
+
|
|
128
155
|
if (href.endsWith("/" + target)) {
|
|
129
156
|
links[i].href = href + "?t=" + timestamp;
|
|
130
157
|
found = true;
|
|
131
158
|
}
|
|
132
159
|
}
|
|
133
160
|
|
|
134
|
-
if (!found)
|
|
161
|
+
if (!found) {
|
|
162
|
+
location.reload();
|
|
163
|
+
}
|
|
135
164
|
}
|
|
136
165
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
166
|
+
// Error Overlay
|
|
167
|
+
function showErrorOverlay(message, file) {
|
|
168
|
+
hideErrorOverlay();
|
|
169
|
+
|
|
170
|
+
errorOverlay = document.createElement("div");
|
|
171
|
+
errorOverlay.id = "__nitron_error__";
|
|
172
|
+
errorOverlay.innerHTML =
|
|
142
173
|
'<div style="position:fixed;inset:0;background:rgba(0,0,0,.95);color:#ff4444;padding:32px;font-family:monospace;z-index:999999;overflow:auto">' +
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
174
|
+
'<div style="font-size:24px;font-weight:bold;margin-bottom:16px">Build Error</div>' +
|
|
175
|
+
'<div style="color:#888;margin-bottom:16px">' + escapeHtml(file || "") + '</div>' +
|
|
176
|
+
'<pre style="white-space:pre-wrap;background:#1a1a2e;padding:16px;border-radius:8px">' + escapeHtml(message) + '</pre>' +
|
|
177
|
+
'<button onclick="this.parentNode.parentNode.remove()" style="position:absolute;top:16px;right:16px;background:#333;color:#fff;border:none;padding:8px 16px;cursor:pointer;border-radius:4px">Close</button>' +
|
|
147
178
|
'</div>';
|
|
148
|
-
|
|
179
|
+
|
|
180
|
+
document.body.appendChild(errorOverlay);
|
|
149
181
|
}
|
|
150
182
|
|
|
151
|
-
function
|
|
183
|
+
function hideErrorOverlay() {
|
|
152
184
|
var el = document.getElementById("__nitron_error__");
|
|
153
|
-
|
|
154
|
-
|
|
185
|
+
|
|
186
|
+
if (el) {
|
|
187
|
+
el.remove();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
errorOverlay = null;
|
|
155
191
|
}
|
|
156
192
|
|
|
193
|
+
// Utilities
|
|
157
194
|
function escapeHtml(str) {
|
|
158
|
-
return String(str || "")
|
|
195
|
+
return String(str || "")
|
|
196
|
+
.replace(/&/g, "&")
|
|
197
|
+
.replace(/</g, "<")
|
|
198
|
+
.replace(/>/g, ">");
|
|
159
199
|
}
|
|
160
200
|
|
|
201
|
+
// Initialize
|
|
161
202
|
if (document.readyState === "loading") {
|
|
162
203
|
document.addEventListener("DOMContentLoaded", connect);
|
|
163
|
-
}
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
164
206
|
connect();
|
|
165
207
|
}
|
|
208
|
+
|
|
166
209
|
})();
|
|
Binary file
|
|
@@ -6,8 +6,8 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
6
6
|
import { PassThrough } from "stream";
|
|
7
7
|
import React from "react";
|
|
8
8
|
import { renderToPipeableStream } from "react-dom/server";
|
|
9
|
-
import Log from "../Logging/
|
|
10
|
-
import
|
|
9
|
+
import Log from "../Logging/Log.js";
|
|
10
|
+
import Router from "../Route/Router.js";
|
|
11
11
|
import Paths from "../Core/Paths.js";
|
|
12
12
|
import Config from "../Core/Config.js";
|
|
13
13
|
import Environment from "../Core/Environment.js";
|
|
@@ -38,6 +38,13 @@ function escapeHtml(str) {
|
|
|
38
38
|
return String(str).replace(/[&<>"'`]/g, char => ESC_MAP[char]);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* React SSR view renderer with streaming support.
|
|
43
|
+
* Handles component rendering, asset injection, and client hydration.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* return View.render(res, "Dashboard", { user: currentUser });
|
|
47
|
+
*/
|
|
41
48
|
class View {
|
|
42
49
|
static #root = Paths.project;
|
|
43
50
|
static #userViews = Paths.buildViews;
|
|
@@ -110,27 +117,38 @@ class View {
|
|
|
110
117
|
});
|
|
111
118
|
});
|
|
112
119
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
if (View.#isDev) {
|
|
121
|
+
server.get("/__nitron/navigate", async (req, res) => {
|
|
122
|
+
const url = req.query.url;
|
|
123
|
+
if (!url) {
|
|
124
|
+
return res.code(400).send({ error: "Missing url" });
|
|
125
|
+
}
|
|
118
126
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
const result = await View.#renderPartial(url, req, res);
|
|
128
|
+
|
|
129
|
+
if (result.handled) return;
|
|
130
|
+
|
|
131
|
+
return res
|
|
132
|
+
.code(result.status || 200)
|
|
133
|
+
.header("X-Content-Type-Options", "nosniff")
|
|
134
|
+
.send(result);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
server.get("/__nitron/icon.png", async (req, res) => {
|
|
138
|
+
const iconPath = path.join(__dirname, "Client", "nitronjs-icon.png");
|
|
139
|
+
const iconBuffer = readFileSync(iconPath);
|
|
140
|
+
return res
|
|
141
|
+
.header("Content-Type", "image/png")
|
|
142
|
+
.header("Cache-Control", "public, max-age=31536000")
|
|
143
|
+
.send(iconBuffer);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
128
146
|
}
|
|
129
147
|
|
|
130
148
|
static async #renderPartial(url, originalReq, originalRes) {
|
|
131
149
|
try {
|
|
132
150
|
const parsedUrl = new URL(url, `http://${originalReq.headers.host}`);
|
|
133
|
-
const routeMatch =
|
|
151
|
+
const routeMatch = Router.match(parsedUrl.pathname, "GET");
|
|
134
152
|
|
|
135
153
|
if (!routeMatch) {
|
|
136
154
|
return { status: 404, error: "Route not found" };
|
|
@@ -220,7 +238,7 @@ class View {
|
|
|
220
238
|
}
|
|
221
239
|
|
|
222
240
|
static #getRoutesForScript(script) {
|
|
223
|
-
const allRoutes =
|
|
241
|
+
const allRoutes = Router.getClientManifest();
|
|
224
242
|
const usedNames = this.#getUsedRoutes(script);
|
|
225
243
|
const routes = {};
|
|
226
244
|
for (const name of usedNames) {
|
|
@@ -645,7 +663,7 @@ class View {
|
|
|
645
663
|
const nonceAttr = nonce ? ` nonce="${escapeHtml(nonce)}"` : "";
|
|
646
664
|
const hasHydration = !!hydrationScript;
|
|
647
665
|
|
|
648
|
-
const allRoutes =
|
|
666
|
+
const allRoutes = Router.getClientManifest();
|
|
649
667
|
const usedRouteNames = hasHydration ? this.#getUsedRoutes(hydrationScript) : [];
|
|
650
668
|
const routes = {};
|
|
651
669
|
for (const name of usedRouteNames) {
|
|
@@ -733,10 +751,10 @@ ${vendorScript}${hmrScript}${hydrateScript}${spaScript}${devIndicator}
|
|
|
733
751
|
box-shadow:0 6px 24px rgba(0,0,0,0.6);
|
|
734
752
|
}
|
|
735
753
|
#__nitron_dev_btn__ .logo {
|
|
736
|
-
width:20px;height:20px;
|
|
737
|
-
|
|
754
|
+
width:20px;height:20px;
|
|
755
|
+
display:flex;align-items:center;justify-content:center;
|
|
738
756
|
}
|
|
739
|
-
#__nitron_dev_btn__ .logo svg { width:
|
|
757
|
+
#__nitron_dev_btn__ .logo svg { width:20px;height:20px; }
|
|
740
758
|
#__nitron_dev_btn__ .dot { width:6px;height:6px;border-radius:50%;animation:pulse 2s infinite; }
|
|
741
759
|
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }
|
|
742
760
|
#__nitron_dev_panel__ {
|
|
@@ -752,10 +770,9 @@ ${vendorScript}${hmrScript}${hydrateScript}${spaScript}${devIndicator}
|
|
|
752
770
|
border-bottom:1px solid #1f1f1f;display:flex;align-items:center;gap:10px;
|
|
753
771
|
}
|
|
754
772
|
#__nitron_dev_panel__ .header .icon {
|
|
755
|
-
width:28px;height:28px;
|
|
773
|
+
width:28px;height:28px;
|
|
756
774
|
border-radius:6px;display:flex;align-items:center;justify-content:center;
|
|
757
775
|
}
|
|
758
|
-
#__nitron_dev_panel__ .header .icon svg { width:16px;height:16px; }
|
|
759
776
|
#__nitron_dev_panel__ .header .info { display:flex;flex-direction:column; }
|
|
760
777
|
#__nitron_dev_panel__ .header .title { font-size:14px;font-weight:600;color:#fff;line-height:1.2; }
|
|
761
778
|
#__nitron_dev_panel__ .header .version { font-size:11px;color:#666;line-height:1.2; }
|
|
@@ -788,13 +805,13 @@ ${vendorScript}${hmrScript}${hydrateScript}${spaScript}${devIndicator}
|
|
|
788
805
|
#__nitron_dev_panel__ .footer a:hover { background:#1a1a1a;color:#999;border-color:#2a2a2a; }
|
|
789
806
|
</style>
|
|
790
807
|
<button id="__nitron_dev_btn__">
|
|
791
|
-
<span class="logo"><
|
|
808
|
+
<span class="logo"><img src="/__nitron/icon.png" alt="N" style="width:20px;height:20px;"></span>
|
|
792
809
|
<span style="color:#888;">NitronJS</span>
|
|
793
810
|
<span class="dot" id="__nitron_status_dot__" style="background:#4ade80;"></span>
|
|
794
811
|
</button>
|
|
795
|
-
<div id="__nitron_dev_panel__">
|
|
812
|
+
<div id="__nitron_dev_panel__" style="display:none;">
|
|
796
813
|
<div class="header">
|
|
797
|
-
<div class="icon"><
|
|
814
|
+
<div class="icon"><img src="/__nitron/icon.png" alt="N" style="width:28px;height:28px;"></div>
|
|
798
815
|
<div class="info">
|
|
799
816
|
<span class="title">NitronJS</span>
|
|
800
817
|
<span class="version">v${FRAMEWORK_VERSION}</span>
|
|
@@ -802,11 +819,9 @@ ${vendorScript}${hmrScript}${hydrateScript}${spaScript}${devIndicator}
|
|
|
802
819
|
<span class="badge">dev</span>
|
|
803
820
|
</div>
|
|
804
821
|
<div class="body">
|
|
805
|
-
<div class="row"><span class="label">Environment</span><span class="value"><span class="status ok"></span>Development</span></div>
|
|
806
822
|
<div class="row"><span class="label">HMR</span><span class="value"><span class="status" id="__nitron_hmr_ind__"></span><span id="__nitron_hmr_txt__">Checking...</span></span></div>
|
|
807
823
|
<div class="row"><span class="label">Server</span><span class="value">localhost:${port}</span></div>
|
|
808
824
|
<div class="row"><span class="label">Node.js</span><span class="value">${nodeVersion}</span></div>
|
|
809
|
-
<div class="row"><span class="label">React</span><span class="value"><span class="status ok"></span>Ready</span></div>
|
|
810
825
|
</div>
|
|
811
826
|
<div class="footer">
|
|
812
827
|
<a href="/__nitron/routes" target="_blank">Routes</a>
|
package/lib/index.d.ts
CHANGED
|
@@ -351,18 +351,23 @@ export class Config {
|
|
|
351
351
|
static has(key: string): boolean;
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
export class
|
|
355
|
-
static get(path: string, handler: any):
|
|
356
|
-
static post(path: string, handler: any):
|
|
357
|
-
static put(path: string, handler: any):
|
|
358
|
-
static patch(path: string, handler: any):
|
|
359
|
-
static delete(path: string, handler: any):
|
|
354
|
+
export class Router {
|
|
355
|
+
static get(path: string, handler: any): Router;
|
|
356
|
+
static post(path: string, handler: any): Router;
|
|
357
|
+
static put(path: string, handler: any): Router;
|
|
358
|
+
static patch(path: string, handler: any): Router;
|
|
359
|
+
static delete(path: string, handler: any): Router;
|
|
360
360
|
static group(options: Record<string, any>, callback: () => void): void;
|
|
361
361
|
static resource(name: string, controller: any): void;
|
|
362
|
-
|
|
363
|
-
middleware(...middleware: any[]):
|
|
362
|
+
static prefix(prefix: string): Router;
|
|
363
|
+
static middleware(...middleware: any[]): Router;
|
|
364
|
+
name(name: string): Router;
|
|
365
|
+
middleware(...middleware: any[]): Router;
|
|
364
366
|
}
|
|
365
367
|
|
|
368
|
+
// Alias for backwards compatibility
|
|
369
|
+
export { Router as Route };
|
|
370
|
+
|
|
366
371
|
export class Mail {
|
|
367
372
|
static to(address: string): Mail;
|
|
368
373
|
static from(address: string): Mail;
|
|
@@ -394,6 +399,35 @@ export const Environment: any;
|
|
|
394
399
|
|
|
395
400
|
export function start(): Promise<void>;
|
|
396
401
|
|
|
402
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
403
|
+
// Path Aliases (for import convenience)
|
|
404
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
405
|
+
|
|
406
|
+
declare module "@css/*" {
|
|
407
|
+
const content: string;
|
|
408
|
+
export default content;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
declare module "@views/*" {
|
|
412
|
+
const component: React.ComponentType<any>;
|
|
413
|
+
export default component;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
declare module "@models/*" {
|
|
417
|
+
const model: any;
|
|
418
|
+
export default model;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
declare module "@controllers/*" {
|
|
422
|
+
const controller: any;
|
|
423
|
+
export default controller;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
declare module "@middlewares/*" {
|
|
427
|
+
const middleware: any;
|
|
428
|
+
export default middleware;
|
|
429
|
+
}
|
|
430
|
+
|
|
397
431
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
398
432
|
// Global Functions (available in all views without import)
|
|
399
433
|
// ─────────────────────────────────────────────────────────────────────────────
|
package/lib/index.js
CHANGED
|
@@ -3,18 +3,27 @@ export { default as Config } from "./Core/Config.js";
|
|
|
3
3
|
export { default as Paths } from "./Core/Paths.js";
|
|
4
4
|
export { default as Environment } from "./Core/Environment.js";
|
|
5
5
|
|
|
6
|
+
// Version
|
|
7
|
+
import { readFileSync } from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
|
|
11
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const packageJsonPath = path.join(__dirname, "../package.json");
|
|
13
|
+
export const VERSION = JSON.parse(readFileSync(packageJsonPath, "utf-8")).version;
|
|
14
|
+
|
|
6
15
|
// Http
|
|
7
16
|
export { default as Server } from "./Http/Server.js";
|
|
8
17
|
export { start } from "./Runtime/Entry.js";
|
|
9
18
|
|
|
10
19
|
// Routing
|
|
11
|
-
export { default as
|
|
20
|
+
export { default as Router } from "./Route/Router.js";
|
|
21
|
+
export { default as Route } from "./Route/Router.js";
|
|
12
22
|
|
|
13
23
|
// Database
|
|
14
24
|
export { default as DB } from "./Database/DB.js";
|
|
15
25
|
export { default as Model } from "./Database/Model.js";
|
|
16
26
|
export { default as Schema } from "./Database/Schema/Manager.js";
|
|
17
|
-
export { default as DatabaseManager } from "./Database/Manager.js";
|
|
18
27
|
|
|
19
28
|
// Migration
|
|
20
29
|
export { default as MigrationRunner } from "./Database/Migration/MigrationRunner.js";
|
|
@@ -25,35 +34,35 @@ export { default as Checksum } from "./Database/Migration/Checksum.js";
|
|
|
25
34
|
export { default as SeederRunner } from "./Database/Seeder/SeederRunner.js";
|
|
26
35
|
|
|
27
36
|
// Authentication
|
|
28
|
-
export { default as Auth } from "./Auth/
|
|
37
|
+
export { default as Auth } from "./Auth/Auth.js";
|
|
29
38
|
|
|
30
39
|
// Session
|
|
31
40
|
export { default as Session } from "./Session/Session.js";
|
|
32
41
|
export { default as SessionManager } from "./Session/Manager.js";
|
|
33
42
|
|
|
34
43
|
// View
|
|
35
|
-
export { default as View } from "./View/
|
|
44
|
+
export { default as View } from "./View/View.js";
|
|
36
45
|
|
|
37
46
|
// Hashing
|
|
38
|
-
export { default as Hash } from "./Hashing/
|
|
47
|
+
export { default as Hash } from "./Hashing/Hash.js";
|
|
39
48
|
|
|
40
49
|
// Logging
|
|
41
|
-
export { default as Log } from "./Logging/
|
|
50
|
+
export { default as Log } from "./Logging/Log.js";
|
|
42
51
|
|
|
43
52
|
// Filesystem
|
|
44
|
-
export { default as Storage } from "./Filesystem/
|
|
53
|
+
export { default as Storage } from "./Filesystem/Storage.js";
|
|
45
54
|
|
|
46
55
|
// Mail
|
|
47
|
-
export { default as Mail } from "./Mail/
|
|
56
|
+
export { default as Mail } from "./Mail/Mail.js";
|
|
48
57
|
|
|
49
58
|
// Encryption
|
|
50
|
-
export { default as AES } from "./Encryption/
|
|
59
|
+
export { default as AES } from "./Encryption/Encryption.js";
|
|
51
60
|
|
|
52
61
|
// Validation
|
|
53
62
|
export { default as Validator } from "./Validation/Validator.js";
|
|
54
63
|
|
|
55
64
|
// Translation
|
|
56
|
-
export { default as Lang } from "./Translation/
|
|
65
|
+
export { default as Lang } from "./Translation/Lang.js";
|
|
57
66
|
|
|
58
67
|
// Date
|
|
59
68
|
export { default as DateTime } from "./Date/DateTime.js";
|
|
@@ -64,5 +73,3 @@ export { default as Str } from "./Support/Str.js";
|
|
|
64
73
|
// Faker
|
|
65
74
|
export { default as Faker } from "./Faker/Faker.js";
|
|
66
75
|
|
|
67
|
-
// Backward Compatibility Aliases
|
|
68
|
-
export { default as Enviroment } from "./Core/Environment.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitronjs/framework",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "NitronJS is a modern and extensible Node.js MVC framework built on Fastify. It focuses on clean architecture, modular structure, and developer productivity, offering built-in routing, middleware, configuration management, CLI tooling, and native React integration for scalable full-stack applications.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"njs": "./cli/njs.js"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "tailwindcss";
|