@cyberismo/backend 0.0.6 → 0.0.8
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 +1 -0
- package/dist/app.js +65 -0
- package/dist/app.js.map +1 -0
- package/dist/export.js +228 -0
- package/dist/export.js.map +1 -0
- package/dist/index.js +41 -76
- package/dist/index.js.map +1 -1
- package/dist/main.js +19 -1
- package/dist/main.js.map +1 -1
- package/dist/public/THIRD-PARTY.txt +47 -47
- package/dist/public/assets/index-BngW8o1w.css +1 -0
- package/dist/public/assets/index-D5kiRHuF.js +111171 -0
- package/dist/public/config.json +3 -0
- package/dist/public/index.html +11 -2
- package/dist/routes/cards.js +48 -20
- package/dist/routes/cards.js.map +1 -1
- package/dist/routes/fieldTypes.js +3 -1
- package/dist/routes/fieldTypes.js.map +1 -1
- package/dist/routes/linkTypes.js +3 -1
- package/dist/routes/linkTypes.js.map +1 -1
- package/dist/routes/templates.js +8 -1
- package/dist/routes/templates.js.map +1 -1
- package/dist/routes/tree.js +3 -1
- package/dist/routes/tree.js.map +1 -1
- package/dist/utils.js +87 -0
- package/dist/utils.js.map +1 -0
- package/package.json +7 -3
- package/src/app.ts +79 -0
- package/src/export.ts +288 -0
- package/src/index.ts +47 -91
- package/src/main.ts +18 -1
- package/src/routes/cards.ts +121 -69
- package/src/routes/fieldTypes.ts +4 -2
- package/src/routes/linkTypes.ts +6 -1
- package/src/routes/templates.ts +11 -1
- package/src/routes/tree.ts +6 -1
- package/src/utils.ts +100 -0
- package/dist/public/assets/index-DqBrVRB4.js +0 -605
- package/dist/public/assets/index-ImgtZ9pq.css +0 -1
- package/dist/routes/cardTypes.js +0 -49
- package/dist/routes/cardTypes.js.map +0 -1
- package/src/routes/cardTypes.ts +0 -54
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hono backend server for [Cyberismo Solution](https://cyberismo.com/solution)
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2025
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation.
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
8
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
9
|
+
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
10
|
+
details. You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
import { Hono } from 'hono';
|
|
14
|
+
import { staticFrontendDirRelative } from './utils.js';
|
|
15
|
+
import { cors } from 'hono/cors';
|
|
16
|
+
import { serveStatic } from '@hono/node-server/serve-static';
|
|
17
|
+
import { attachCommandManager } from './middleware/commandManager.js';
|
|
18
|
+
import cardsRouter from './routes/cards.js';
|
|
19
|
+
import fieldTypesRouter from './routes/fieldTypes.js';
|
|
20
|
+
import linkTypesRouter from './routes/linkTypes.js';
|
|
21
|
+
import templatesRouter from './routes/templates.js';
|
|
22
|
+
import treeRouter from './routes/tree.js';
|
|
23
|
+
import { readFile } from 'node:fs/promises';
|
|
24
|
+
import path from 'node:path';
|
|
25
|
+
import { isSSGContext } from './export.js';
|
|
26
|
+
/**
|
|
27
|
+
* Create the Hono app for the backend
|
|
28
|
+
* @param projectPath - Path to the project
|
|
29
|
+
*/
|
|
30
|
+
export function createApp(projectPath) {
|
|
31
|
+
const app = new Hono();
|
|
32
|
+
app.use('/api', cors());
|
|
33
|
+
app.use('*', serveStatic({
|
|
34
|
+
root: staticFrontendDirRelative,
|
|
35
|
+
}));
|
|
36
|
+
// Attach CommandManager to all requests
|
|
37
|
+
app.use(attachCommandManager(projectPath));
|
|
38
|
+
// Wire up routes
|
|
39
|
+
app.route('/api/cards', cardsRouter);
|
|
40
|
+
app.route('/api/fieldTypes', fieldTypesRouter);
|
|
41
|
+
app.route('/api/linkTypes', linkTypesRouter);
|
|
42
|
+
app.route('/api/templates', templatesRouter);
|
|
43
|
+
app.route('/api/tree', treeRouter);
|
|
44
|
+
// serve index.html for all other routes
|
|
45
|
+
app.notFound(async (c) => {
|
|
46
|
+
if (c.req.path.startsWith('/api')) {
|
|
47
|
+
return c.text('Not Found', 400);
|
|
48
|
+
}
|
|
49
|
+
const file = await readFile(path.join(import.meta.dirname, 'public', 'index.html'));
|
|
50
|
+
return c.html(file.toString());
|
|
51
|
+
});
|
|
52
|
+
// Error handling
|
|
53
|
+
app.onError((err, c) => {
|
|
54
|
+
if (!isSSGContext(c)) {
|
|
55
|
+
console.error(err.stack);
|
|
56
|
+
}
|
|
57
|
+
return c.json({
|
|
58
|
+
error: isSSGContext(c)
|
|
59
|
+
? err.message || 'Internal Server Error'
|
|
60
|
+
: 'Internal Server Error',
|
|
61
|
+
}, 500);
|
|
62
|
+
});
|
|
63
|
+
return app;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AACF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,wBAAwB,CAAC;AACtD,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACp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C;QACF,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,iBAAiB;IACjB,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QACrB,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,CAAC,CAAC,IAAI,CACX;YACE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;gBACpB,CAAC,CAAC,GAAG,CAAC,OAAO,IAAI,uBAAuB;gBACxC,CAAC,CAAC,uBAAuB;SAC5B,EACD,GAAG,CACJ,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/export.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2025
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation.
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
8
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
9
|
+
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
10
|
+
details. You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import { mkdir, readFile } from 'node:fs/promises';
|
|
15
|
+
import { CommandManager } from '@cyberismo/data-handler';
|
|
16
|
+
import { createApp } from './app.js';
|
|
17
|
+
import { cp, writeFile } from 'node:fs/promises';
|
|
18
|
+
import { runCbSafely, runInParallel, staticFrontendDirRelative, } from './utils.js';
|
|
19
|
+
import mime from 'mime-types';
|
|
20
|
+
let _cardQueryPromise = null;
|
|
21
|
+
/**
|
|
22
|
+
* DO NO USE DIRECTLY. This resets the callOnce map, allowing you to redo the export.
|
|
23
|
+
* Also resets the card query promise.
|
|
24
|
+
*/
|
|
25
|
+
export function reset() {
|
|
26
|
+
_cardQueryPromise = null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get the card query result for a given card key. Should only be called during
|
|
30
|
+
* static site generation
|
|
31
|
+
* @param projectPath - Path to the project.
|
|
32
|
+
* @param cardKey - Key of the card to get the query result for.
|
|
33
|
+
* @returns The card query result for the given card key.
|
|
34
|
+
*/
|
|
35
|
+
export async function getCardQueryResult(projectPath, cardKey) {
|
|
36
|
+
if (!_cardQueryPromise) {
|
|
37
|
+
const commands = await CommandManager.getInstance(projectPath);
|
|
38
|
+
// fetch all cards
|
|
39
|
+
_cardQueryPromise = commands.calculateCmd.runQuery('card', {});
|
|
40
|
+
}
|
|
41
|
+
return _cardQueryPromise.then((results) => {
|
|
42
|
+
if (!cardKey) {
|
|
43
|
+
return results;
|
|
44
|
+
}
|
|
45
|
+
const card = results.find((r) => r.key === cardKey);
|
|
46
|
+
if (!card) {
|
|
47
|
+
throw new Error(`Card ${cardKey} not found`);
|
|
48
|
+
}
|
|
49
|
+
return [card];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Export the site to a given directory.
|
|
54
|
+
* Note: Do not call this function in parallel.
|
|
55
|
+
* @param projectPath - Path to the project.
|
|
56
|
+
* @param exportDir - Directory to export to.
|
|
57
|
+
* @param level - Log level for the operation.
|
|
58
|
+
* @param onProgress - Optional progress callback function.
|
|
59
|
+
*/
|
|
60
|
+
export async function exportSite(projectPath, exportDir, level, onProgress) {
|
|
61
|
+
exportDir = exportDir || 'static';
|
|
62
|
+
const app = createApp(projectPath);
|
|
63
|
+
// copy whole frontend to the same directory
|
|
64
|
+
await cp(staticFrontendDirRelative, exportDir, { recursive: true });
|
|
65
|
+
// read config file and change export to true
|
|
66
|
+
const config = await readFile(path.join(exportDir, 'config.json'), 'utf-8');
|
|
67
|
+
const configJson = JSON.parse(config);
|
|
68
|
+
configJson.staticMode = true;
|
|
69
|
+
await writeFile(path.join(exportDir, 'config.json'), JSON.stringify(configJson));
|
|
70
|
+
const commands = await CommandManager.getInstance(projectPath, {
|
|
71
|
+
logLevel: level,
|
|
72
|
+
});
|
|
73
|
+
await toSsg(app, commands, exportDir, onProgress);
|
|
74
|
+
}
|
|
75
|
+
async function getRoutes(app) {
|
|
76
|
+
const routes = new Set();
|
|
77
|
+
for (const route of app.routes) {
|
|
78
|
+
if (route.method === 'GET')
|
|
79
|
+
routes.add(route.path);
|
|
80
|
+
}
|
|
81
|
+
// handles both routes with and without dynamic parameters
|
|
82
|
+
const filteredRoutes = [];
|
|
83
|
+
for (const route of routes) {
|
|
84
|
+
if (!route.includes(':')) {
|
|
85
|
+
filteredRoutes.push(route);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const response = await createSsgRequest(app, route, true);
|
|
89
|
+
if (response.ok) {
|
|
90
|
+
const params = await response.json();
|
|
91
|
+
if (Array.isArray(params) && params.length > 0) {
|
|
92
|
+
for (const param of params) {
|
|
93
|
+
let newRoute = route;
|
|
94
|
+
for (const [key, value] of Object.entries(param)) {
|
|
95
|
+
newRoute = newRoute.replace(`:${key}`, `${value}`);
|
|
96
|
+
}
|
|
97
|
+
filteredRoutes.push(newRoute);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return filteredRoutes;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* This is similar to hono's ssg function, but it only calls middlewares once
|
|
106
|
+
* @param app
|
|
107
|
+
* @param onProgress
|
|
108
|
+
*/
|
|
109
|
+
async function toSsg(app, commands, dir, onProgress) {
|
|
110
|
+
reset();
|
|
111
|
+
await commands.calculateCmd.generate();
|
|
112
|
+
const promises = [];
|
|
113
|
+
const routes = await getRoutes(app);
|
|
114
|
+
await runCbSafely(() => onProgress?.(0, routes.length));
|
|
115
|
+
let processedFiles = 0;
|
|
116
|
+
let failed = false;
|
|
117
|
+
let errors = [];
|
|
118
|
+
const done = async (error) => {
|
|
119
|
+
if (error) {
|
|
120
|
+
failed = true;
|
|
121
|
+
errors.push(error);
|
|
122
|
+
}
|
|
123
|
+
processedFiles++;
|
|
124
|
+
await runCbSafely(() => onProgress?.(processedFiles, routes.length));
|
|
125
|
+
};
|
|
126
|
+
for (const route of routes) {
|
|
127
|
+
promises.push(async () => {
|
|
128
|
+
try {
|
|
129
|
+
const response = await createSsgRequest(app, route, false);
|
|
130
|
+
if (!response.ok) {
|
|
131
|
+
const error = await response.json();
|
|
132
|
+
if (typeof error === 'object' && error !== null && 'error' in error) {
|
|
133
|
+
await done(new Error(`Failed to export route ${route}: ${error.error}`));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
await done(new Error(`Failed to export route ${route}`));
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
await writeFileToDir(dir, response, route);
|
|
141
|
+
await done();
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
await done(error instanceof Error ? error : new Error(String(error)));
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
await runInParallel(promises, 5);
|
|
149
|
+
if (failed) {
|
|
150
|
+
const message = `Errors:\n${errors.map((e) => e.message).join('\n')}`;
|
|
151
|
+
throw new Error(message);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get the file content and file ending for a given response and route.
|
|
156
|
+
* @param response - The response to get the file content and file ending for.
|
|
157
|
+
* @param route - The route to get the file content and file ending for.
|
|
158
|
+
* @returns The file content and file ending for the given response and route.
|
|
159
|
+
* If the route already has a file ending, it will be returned as an empty string.
|
|
160
|
+
*/
|
|
161
|
+
async function getFileContent(response, route) {
|
|
162
|
+
// Check if route already has an extension
|
|
163
|
+
const routeExtension = path.extname(route);
|
|
164
|
+
if (routeExtension) {
|
|
165
|
+
// Trust the existing extension in the route
|
|
166
|
+
const content = await response.arrayBuffer();
|
|
167
|
+
return {
|
|
168
|
+
content,
|
|
169
|
+
fileEnding: '',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
// No extension in route, fall back to content type detection
|
|
173
|
+
const contentType = response.headers.get('content-type');
|
|
174
|
+
if (!contentType) {
|
|
175
|
+
throw new Error('No content type');
|
|
176
|
+
}
|
|
177
|
+
const extension = mime.extension(contentType);
|
|
178
|
+
if (!extension) {
|
|
179
|
+
throw new Error('Unsupported content type');
|
|
180
|
+
}
|
|
181
|
+
// Use ArrayBuffer for all content types
|
|
182
|
+
const content = await response.arrayBuffer();
|
|
183
|
+
return {
|
|
184
|
+
content,
|
|
185
|
+
fileEnding: `.${extension}`,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
async function writeFileToDir(dir, response, route) {
|
|
189
|
+
const { content, fileEnding } = await getFileContent(response, route);
|
|
190
|
+
let filePath = path.join(dir, route);
|
|
191
|
+
// if route does not have a file ending, add it based on the content type
|
|
192
|
+
if (!route.endsWith(fileEnding)) {
|
|
193
|
+
filePath += fileEnding;
|
|
194
|
+
}
|
|
195
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
196
|
+
await writeFile(filePath, Buffer.from(content));
|
|
197
|
+
}
|
|
198
|
+
// findroutes = if this request is used to find the routes in the app
|
|
199
|
+
function createSsgRequest(app, route, findRoutes = true) {
|
|
200
|
+
return app.request(route, {
|
|
201
|
+
headers: new Headers({
|
|
202
|
+
'x-ssg': 'true',
|
|
203
|
+
'x-ssg-find': findRoutes ? 'true' : 'false',
|
|
204
|
+
}),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Check if the request is a static site generation request.
|
|
209
|
+
* @param c - The context of the request.
|
|
210
|
+
* @returns True if the request is a static site generation request.
|
|
211
|
+
*/
|
|
212
|
+
export function isSSGContext(c) {
|
|
213
|
+
return c.req.header('x-ssg') === 'true';
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* This middleware is used to find the routes in the app.
|
|
217
|
+
* @param fn - The function to call to get the parameters for the route.
|
|
218
|
+
* @returns The middleware handler.
|
|
219
|
+
*/
|
|
220
|
+
export function ssgParams(fn) {
|
|
221
|
+
return async (c, next) => {
|
|
222
|
+
if (c.req.header('x-ssg-find') === 'true') {
|
|
223
|
+
return fn ? c.json(await fn(c)) : c.json([]);
|
|
224
|
+
}
|
|
225
|
+
return next();
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,WAAW,EACX,aAAa,EACb,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAGpB,OAAO,IAAI,MAAM,YAAY,CAAC;AAE9B,IAAI,iBAAiB,GAA0C,IAAI,CAAC;AAEpE;;;GAGG;AACH,MAAM,UAAU,KAAK;IACnB,iBAAiB,GAAG,IAAI,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,WAAmB,EACnB,OAAgB;IAEhB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,QAAQ,GAAG,MAA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AE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,qEAAqE;AACrE,SAAS,gBAAgB,CACvB,GAAS,EACT,KAAa,EACb,aAAsB,IAAI;IAE1B,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE;QACxB,OAAO,EAAE,IAAI,OAAO,CAAC;YACnB,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;SAC5C,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,CAAU;IACrC,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,EAAuC;IAEvC,OAAO,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QACvB,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,MAAM,EAAE,CAAC;YAC1C,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,96 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2025
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation.
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
8
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
9
|
+
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
10
|
+
details. You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
1
13
|
import { serve } from '@hono/node-server';
|
|
2
14
|
import { Hono } from 'hono';
|
|
3
|
-
import { cors } from 'hono/cors';
|
|
4
15
|
import { serveStatic } from '@hono/node-server/serve-static';
|
|
5
16
|
import path from 'node:path';
|
|
6
|
-
import { createServer } from 'node:net';
|
|
7
|
-
import { attachCommandManager } from './middleware/commandManager.js';
|
|
8
|
-
// Import routes
|
|
9
|
-
import cardsRouter from './routes/cards.js';
|
|
10
|
-
import cardTypesRouter from './routes/cardTypes.js';
|
|
11
|
-
import fieldTypesRouter from './routes/fieldTypes.js';
|
|
12
|
-
import linkTypesRouter from './routes/linkTypes.js';
|
|
13
|
-
import templatesRouter from './routes/templates.js';
|
|
14
|
-
import treeRouter from './routes/tree.js';
|
|
15
|
-
import { fileURLToPath } from 'node:url';
|
|
16
17
|
import { readFile } from 'node:fs/promises';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export
|
|
18
|
+
import { findFreePort } from './utils.js';
|
|
19
|
+
import { createApp } from './app.js';
|
|
20
|
+
export { exportSite } from './export.js';
|
|
21
|
+
const DEFAULT_PORT = 3000;
|
|
22
|
+
const DEFAULT_MAX_PORT = DEFAULT_PORT + 100;
|
|
23
|
+
/**
|
|
24
|
+
* Preview the exported site
|
|
25
|
+
* @param dir - Directory to preview
|
|
26
|
+
* @param findPort - If true, find a free port
|
|
27
|
+
*/
|
|
28
|
+
export async function previewSite(dir, findPort = true) {
|
|
20
29
|
const app = new Hono();
|
|
21
|
-
app.use(
|
|
22
|
-
app.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
app.route('/api/cards', cardsRouter);
|
|
29
|
-
app.route('/api/cardTypes', cardTypesRouter);
|
|
30
|
-
app.route('/api/fieldTypes', fieldTypesRouter);
|
|
31
|
-
app.route('/api/linkTypes', linkTypesRouter);
|
|
32
|
-
app.route('/api/templates', templatesRouter);
|
|
33
|
-
app.route('/api/tree', treeRouter);
|
|
34
|
-
// serve index.html for all other routes
|
|
35
|
-
app.notFound(async (c) => {
|
|
36
|
-
if (c.req.path.startsWith('/api')) {
|
|
37
|
-
return c.text('Not Found', 400);
|
|
38
|
-
}
|
|
39
|
-
const file = await readFile(path.join(dirname, 'public', 'index.html'));
|
|
40
|
-
return c.html(file.toString());
|
|
41
|
-
});
|
|
42
|
-
// Error handling
|
|
43
|
-
app.onError((err, c) => {
|
|
44
|
-
console.error(err.stack);
|
|
45
|
-
return c.text('Internal Server Error', 500);
|
|
46
|
-
});
|
|
47
|
-
return app;
|
|
30
|
+
app.use(serveStatic({ root: dir }));
|
|
31
|
+
app.get('*', (c) => c.html(readFile(path.join(dir, 'index.html')).then((file) => file.toString())));
|
|
32
|
+
let port = parseInt(process.env.PORT || DEFAULT_PORT.toString(), 10);
|
|
33
|
+
if (findPort) {
|
|
34
|
+
port = await findFreePort(port, DEFAULT_MAX_PORT);
|
|
35
|
+
}
|
|
36
|
+
await startApp(app, port);
|
|
48
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Start the server
|
|
40
|
+
* @param projectPath - Path to the project
|
|
41
|
+
* @param findPort - If true, find a free port
|
|
42
|
+
*/
|
|
49
43
|
export async function startServer(projectPath, findPort = true) {
|
|
50
|
-
let port = parseInt(process.env.PORT ||
|
|
44
|
+
let port = parseInt(process.env.PORT || DEFAULT_PORT.toString(), 10);
|
|
51
45
|
if (findPort) {
|
|
52
|
-
port = await findFreePort(port);
|
|
46
|
+
port = await findFreePort(port, DEFAULT_MAX_PORT);
|
|
53
47
|
}
|
|
54
48
|
const app = createApp(projectPath);
|
|
49
|
+
await startApp(app, port);
|
|
50
|
+
}
|
|
51
|
+
async function startApp(app, port) {
|
|
55
52
|
// Start server
|
|
56
53
|
serve({
|
|
57
54
|
fetch: app.fetch,
|
|
58
|
-
port:
|
|
55
|
+
port: port,
|
|
59
56
|
}, (info) => {
|
|
60
57
|
console.log(`Running Cyberismo app on http://localhost:${info.port}`);
|
|
61
58
|
console.log('Press Control+C to stop.');
|
|
62
59
|
});
|
|
63
60
|
}
|
|
64
|
-
async function findFreePort(port, maxAttempts = 100) {
|
|
65
|
-
for (let i = port; i < port + maxAttempts; i++) {
|
|
66
|
-
try {
|
|
67
|
-
await testPort(i);
|
|
68
|
-
return i;
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
if (err instanceof Error && err.message.includes('EADDRINUSE')) {
|
|
72
|
-
console.log(`Port ${i} is already in use, trying next port...`);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
throw err;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
throw new Error('Failed to find free port');
|
|
80
|
-
}
|
|
81
|
-
function testPort(port) {
|
|
82
|
-
return new Promise((resolve, reject) => {
|
|
83
|
-
const server = createServer();
|
|
84
|
-
server.listen(port, () => {
|
|
85
|
-
server.close();
|
|
86
|
-
resolve(true);
|
|
87
|
-
});
|
|
88
|
-
server.on('error', (err) => {
|
|
89
|
-
reject(err);
|
|
90
|
-
});
|
|
91
|
-
setTimeout(() => {
|
|
92
|
-
reject(new Error('Timed out waiting for port to be free'));
|
|
93
|
-
}, 2000);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
61
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.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;IACD,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,WAAoB,EACpB,WAAoB,IAAI;IAExB,IAAI,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IAErE,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IACnC,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,GAAS,EAAE,IAAY;IAC7C,eAAe;IACf,KAAK,CACH;QACE,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,IAAI,EAAE,IAAI;KACX,EACD,CAAC,IAAI,EAAE,EAAE;QACP,OAAO,CAAC,GAAG,CAAC,6CAA6C,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;IAC1C,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Cyberismo
|
|
3
|
+
Copyright © Cyberismo Ltd and contributors 2025
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU Affero General Public License version 3 as published by
|
|
6
|
+
the Free Software Foundation.
|
|
7
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
8
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
9
|
+
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
10
|
+
details. You should have received a copy of the GNU Affero General Public
|
|
11
|
+
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
|
+
*/
|
|
1
13
|
import { startServer } from './index.js';
|
|
14
|
+
import { exportSite } from './export.js';
|
|
2
15
|
import dotenv from 'dotenv';
|
|
3
16
|
// Load environment variables from .env file
|
|
4
17
|
dotenv.config();
|
|
5
|
-
|
|
18
|
+
if (process.argv.includes('--export')) {
|
|
19
|
+
exportSite(process.env.npm_config_project_path || '');
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
startServer(process.env.npm_config_project_path || '');
|
|
23
|
+
}
|
|
6
24
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,4CAA4C;AAC5C,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AACF,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,4CAA4C;AAC5C,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;IACtC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;AACxD,CAAC;KAAM,CAAC;IACN,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;AACzD,CAAC"}
|