juxscript 1.1.259 → 1.1.261
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/machinery/serve.js +36 -16
- package/package.json +1 -1
package/machinery/serve.js
CHANGED
|
@@ -106,6 +106,24 @@ app.use((req, res, next) => {
|
|
|
106
106
|
app.get('/favicon.ico', (req, res) => res.status(204).end());
|
|
107
107
|
app.get('/favicon.png', (req, res) => res.status(204).end());
|
|
108
108
|
|
|
109
|
+
// ═══════════════════════════════════════════════════════════════
|
|
110
|
+
// API ROUTES — BEFORE static and catch-all
|
|
111
|
+
// ═══════════════════════════════════════════════════════════════
|
|
112
|
+
app.get('/api/test', (req, res) => {
|
|
113
|
+
res.json({
|
|
114
|
+
users: [
|
|
115
|
+
{ id: 1, name: 'Alice', email: 'alice@example.com' },
|
|
116
|
+
{ id: 2, name: 'Bob', email: 'bob@example.com' },
|
|
117
|
+
{ id: 3, name: 'Charlie', email: 'charlie@example.com' }
|
|
118
|
+
],
|
|
119
|
+
posts: [
|
|
120
|
+
{ id: 1, title: 'Hello World', userId: 1 },
|
|
121
|
+
{ id: 2, title: 'Testing JUX', userId: 2 }
|
|
122
|
+
],
|
|
123
|
+
timestamp: new Date().toISOString()
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
109
127
|
app.get('/__jux_sources.json', (req, res) => {
|
|
110
128
|
const snapshotPath = path.join(DIST_DIR, '__jux_sources.json');
|
|
111
129
|
if (fs.existsSync(snapshotPath)) {
|
|
@@ -116,6 +134,24 @@ app.get('/__jux_sources.json', (req, res) => {
|
|
|
116
134
|
}
|
|
117
135
|
});
|
|
118
136
|
|
|
137
|
+
// ═══════════════════════════════════════════════════════════════
|
|
138
|
+
// API ROUTES — must come BEFORE static middleware and catch-all
|
|
139
|
+
// ═══════════════════════════════════════════════════════════════
|
|
140
|
+
app.get('/api/test', (req, res) => {
|
|
141
|
+
res.json({
|
|
142
|
+
users: [
|
|
143
|
+
{ id: 1, name: 'Alice', email: 'alice@example.com' },
|
|
144
|
+
{ id: 2, name: 'Bob', email: 'bob@example.com' },
|
|
145
|
+
{ id: 3, name: 'Charlie', email: 'charlie@example.com' }
|
|
146
|
+
],
|
|
147
|
+
posts: [
|
|
148
|
+
{ id: 1, title: 'Hello World', userId: 1 },
|
|
149
|
+
{ id: 2, title: 'Testing JUX', userId: 2 }
|
|
150
|
+
],
|
|
151
|
+
timestamp: new Date().toISOString()
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
119
155
|
const hotReloadScript = `
|
|
120
156
|
<script>
|
|
121
157
|
(function() {
|
|
@@ -226,22 +262,6 @@ if (HOT_RELOAD) {
|
|
|
226
262
|
});
|
|
227
263
|
};
|
|
228
264
|
|
|
229
|
-
// Fake data API endpoint for testing
|
|
230
|
-
app.get('/api/test', (req, res) => {
|
|
231
|
-
res.json({
|
|
232
|
-
users: [
|
|
233
|
-
{ id: 1, name: 'Alice', email: 'alice@example.com' },
|
|
234
|
-
{ id: 2, name: 'Bob', email: 'bob@example.com' },
|
|
235
|
-
{ id: 3, name: 'Charlie', email: 'charlie@example.com' }
|
|
236
|
-
],
|
|
237
|
-
posts: [
|
|
238
|
-
{ id: 1, title: 'Hello World', userId: 1 },
|
|
239
|
-
{ id: 2, title: 'Testing JUX', userId: 2 }
|
|
240
|
-
],
|
|
241
|
-
timestamp: new Date().toISOString()
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
|
|
245
265
|
const compiler = new JuxCompiler({
|
|
246
266
|
srcDir: SRC_DIR,
|
|
247
267
|
distDir: DIST_DIR,
|