miqro 6.3.0 → 7.0.1
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 +9 -17
- package/build/editor.bundle.js +11601 -10129
- package/build/esm/src/bin/types.js +10 -5
- package/build/esm/src/cluster.js +1 -1
- package/build/esm/src/common/arguments.d.ts +1 -1
- package/build/esm/src/common/arguments.js +28 -14
- package/build/esm/src/common/assets.d.ts +1 -1
- package/build/esm/src/common/assets.js +34 -13
- package/build/esm/src/common/esbuild.d.ts +4 -1
- package/build/esm/src/common/esbuild.js +31 -26
- package/build/esm/src/common/exit.js +4 -4
- package/build/esm/src/common/help.d.ts +1 -1
- package/build/esm/src/common/help.js +0 -1
- package/build/esm/src/common/jsx.d.ts +2 -3
- package/build/esm/src/common/jsx.js +70 -75
- package/build/esm/src/common/paths.d.ts +0 -1
- package/build/esm/src/common/paths.js +3 -3
- package/build/esm/src/common/watch.d.ts +0 -1
- package/build/esm/src/common/watch.js +1 -1
- package/build/esm/src/inflate/inflate-sea.js +35 -24
- package/build/esm/src/inflate/inflate.js +4 -4
- package/build/esm/src/inflate/setup-auth.js +1 -1
- package/build/esm/src/inflate/setup-cors.js +1 -1
- package/build/esm/src/inflate/setup-db.js +2 -2
- package/build/esm/src/inflate/setup-error.js +1 -1
- package/build/esm/src/inflate/setup-http.js +16 -16
- package/build/esm/src/inflate/setup-log.js +1 -1
- package/build/esm/src/inflate/setup-middleware.js +1 -1
- package/build/esm/src/inflate/setup-server-config.js +1 -1
- package/build/esm/src/inflate/setup-ws.js +1 -1
- package/build/esm/src/inflate/setup.doc.d.ts +2 -2
- package/build/esm/src/inflate/setup.doc.js +23 -2
- package/build/esm/src/inflate/utils/sea-utils.js +2 -2
- package/build/esm/src/lib.d.ts +10 -1
- package/build/esm/src/lib.js +16 -1
- package/build/esm/src/main.js +1 -1
- package/build/esm/src/services/app.js +3 -4
- package/build/esm/src/services/migrations.js +2 -2
- package/build/esm/src/services/utils/jwt.d.ts +2 -0
- package/build/esm/src/services/utils/jwt.js +23 -0
- package/build/esm/src/services/utils/middleware.d.ts +9 -0
- package/build/esm/src/services/utils/middleware.js +9 -0
- package/build/esm/src/services/utils/server-interface.js +33 -4
- package/build/esm/src/types.d.ts +50 -83
- package/build/lib.cjs +15684 -15612
- package/package.json +6 -8
- package/sea/basic-compile.base64.sh +1 -1
- package/sea/basic-compile.sh +1 -1
- package/sea/install-nodejs.sh +1 -1
- package/sea/node.version.tag +1 -1
- package/.eslintrc +0 -15
- package/build/esm/editor/auth.d.ts +0 -6
- package/build/esm/editor/auth.js +0 -41
- package/build/esm/editor/common/admin-interface.d.ts +0 -36
- package/build/esm/editor/common/admin-interface.js +0 -44
- package/build/esm/editor/common/constants.d.ts +0 -4
- package/build/esm/editor/common/constants.js +0 -20
- package/build/esm/editor/common/constants.server.d.ts +0 -2
- package/build/esm/editor/common/constants.server.js +0 -4
- package/build/esm/editor/common/editor-index.d.ts +0 -2
- package/build/esm/editor/common/editor-index.js +0 -14
- package/build/esm/editor/common/html-encode.d.ts +0 -1
- package/build/esm/editor/common/html-encode.js +0 -14
- package/build/esm/editor/common/log-socket.d.ts +0 -15
- package/build/esm/editor/common/log-socket.js +0 -70
- package/build/esm/editor/common/templates.d.ts +0 -11
- package/build/esm/editor/common/templates.js +0 -477
- package/build/esm/editor/components/api-preview.d.ts +0 -11
- package/build/esm/editor/components/api-preview.js +0 -90
- package/build/esm/editor/components/editor.d.ts +0 -16
- package/build/esm/editor/components/editor.js +0 -365
- package/build/esm/editor/components/file-browser.d.ts +0 -37
- package/build/esm/editor/components/file-browser.js +0 -126
- package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
- package/build/esm/editor/components/file-editor-toolbar.js +0 -93
- package/build/esm/editor/components/file-editor.d.ts +0 -32
- package/build/esm/editor/components/file-editor.js +0 -59
- package/build/esm/editor/components/filter-query.d.ts +0 -1
- package/build/esm/editor/components/filter-query.js +0 -22
- package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
- package/build/esm/editor/components/highlight-text-area.js +0 -125
- package/build/esm/editor/components/log-viewer.d.ts +0 -6
- package/build/esm/editor/components/log-viewer.js +0 -69
- package/build/esm/editor/components/new-file.d.ts +0 -10
- package/build/esm/editor/components/new-file.js +0 -117
- package/build/esm/editor/components/scroll-query.d.ts +0 -7
- package/build/esm/editor/components/scroll-query.js +0 -21
- package/build/esm/editor/components/start-page.d.ts +0 -13
- package/build/esm/editor/components/start-page.js +0 -30
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -29
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -5
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -49
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -4
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -39
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -149
- package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -38
- package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -46
- package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -45
- package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
- package/build/esm/editor/http/admin/editor/editor.js +0 -7
- package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/index.api.js +0 -21
- package/build/esm/editor/server.d.ts +0 -3
- package/build/esm/editor/server.js +0 -49
- package/build/esm/editor/ws.d.ts +0 -3
- package/build/esm/editor/ws.js +0 -11
- package/build/esm/src/services/globals.d.ts +0 -3
- package/build/esm/src/services/globals.js +0 -182
- package/build/jsx.dom.js +0 -1587
- package/build/postject.base64.cjs +0 -1
- package/editor/auth.ts +0 -51
- package/editor/common/admin-interface.ts +0 -84
- package/editor/common/constants.server.ts +0 -5
- package/editor/common/constants.ts +0 -21
- package/editor/common/editor-index.tsx +0 -17
- package/editor/common/html-encode.ts +0 -14
- package/editor/common/log-socket.tsx +0 -85
- package/editor/common/templates.ts +0 -481
- package/editor/components/api-preview.tsx +0 -116
- package/editor/components/editor.tsx +0 -494
- package/editor/components/file-browser.tsx +0 -308
- package/editor/components/file-editor-toolbar.tsx +0 -191
- package/editor/components/file-editor.tsx +0 -122
- package/editor/components/filter-query.tsx +0 -22
- package/editor/components/highlight-text-area.tsx +0 -145
- package/editor/components/log-viewer.tsx +0 -110
- package/editor/components/new-file.tsx +0 -169
- package/editor/components/scroll-query.tsx +0 -22
- package/editor/components/start-page.tsx +0 -49
- package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
- package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
- package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
- package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
- package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
- package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
- package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
- package/editor/http/admin/editor/editor.tsx +0 -8
- package/editor/http/admin/editor/index.api.tsx +0 -39
- package/editor/server.ts +0 -57
- package/editor/ws.ts +0 -15
- package/sea/types.json +0 -1
- package/src/bin/compile.ts +0 -35
- package/src/bin/doc-md.ts +0 -210
- package/src/bin/generate-doc.ts +0 -64
- package/src/bin/test.ts +0 -92
- package/src/bin/types.ts +0 -29
- package/src/cluster.ts +0 -27
- package/src/common/arguments.ts +0 -745
- package/src/common/assets.ts +0 -128
- package/src/common/checksum.ts +0 -58
- package/src/common/constants.ts +0 -18
- package/src/common/content-type.ts +0 -84
- package/src/common/esbuild.ts +0 -94
- package/src/common/exit.ts +0 -91
- package/src/common/fs.ts +0 -82
- package/src/common/help.ts +0 -61
- package/src/common/jsx.ts +0 -547
- package/src/common/jwt.ts +0 -85
- package/src/common/paths.ts +0 -107
- package/src/common/watch.ts +0 -88
- package/src/inflate/inflate-sea.ts +0 -226
- package/src/inflate/inflate.ts +0 -101
- package/src/inflate/md.ts +0 -25
- package/src/inflate/setup-auth.ts +0 -41
- package/src/inflate/setup-cors.ts +0 -41
- package/src/inflate/setup-db.ts +0 -117
- package/src/inflate/setup-error.ts +0 -44
- package/src/inflate/setup-http.ts +0 -704
- package/src/inflate/setup-log.ts +0 -45
- package/src/inflate/setup-middleware.ts +0 -47
- package/src/inflate/setup-server-config.ts +0 -48
- package/src/inflate/setup-test.ts +0 -23
- package/src/inflate/setup-ws.ts +0 -50
- package/src/inflate/setup.doc.ts +0 -68
- package/src/inflate/utils/sea-utils.ts +0 -14
- package/src/lib.ts +0 -19
- package/src/main.ts +0 -101
- package/src/services/app.ts +0 -699
- package/src/services/editor.tsx +0 -101
- package/src/services/globals.ts +0 -186
- package/src/services/hot-reload.ts +0 -51
- package/src/services/migrations.ts +0 -68
- package/src/services/utils/admin-interface.ts +0 -37
- package/src/services/utils/cache.ts +0 -88
- package/src/services/utils/cluster-cache.ts +0 -230
- package/src/services/utils/cluster-ws.ts +0 -202
- package/src/services/utils/db-manager.ts +0 -92
- package/src/services/utils/get-route.ts +0 -70
- package/src/services/utils/log-transport.ts +0 -81
- package/src/services/utils/log.ts +0 -92
- package/src/services/utils/server-interface.ts +0 -92
- package/src/services/utils/websocketmanager.ts +0 -157
- package/src/types/@esbuild.d.ts +0 -1
- package/src/types/@miqro/core.d.ts +0 -2
- package/src/types/@miqro/jsx.d.ts +0 -2
- package/src/types/@miqro/parser.d.ts +0 -2
- package/src/types/@miqro/query.d.ts +0 -2
- package/src/types/@miqro/request.d.ts +0 -2
- package/src/types/@miqro/test.d.ts +0 -2
- package/src/types/@miqro.d.ts +0 -1
- package/src/types/@types.d.ts +0 -1
- package/src/types/browser.globals.d.ts +0 -1
- package/src/types/cookie.d.ts +0 -2
- package/src/types/globals.d.ts +0 -2
- package/src/types/jose.d.ts +0 -2
- package/src/types/jsx.globals.d.ts +0 -38
- package/src/types/miqro.d.ts +0 -228
- package/src/types/postject.d.ts +0 -1
- package/src/types/server.globals.d.ts +0 -47
- package/src/types.ts +0 -304
- package/tsconfig.json +0 -35
|
@@ -24,7 +24,7 @@ export async function inflateSeaAssets(logger, inflateDir) {
|
|
|
24
24
|
writeFile(logger, resolve(inflateDir, "sea", "esbuild"), esbuildBinaryBuffer);
|
|
25
25
|
chmodSync(resolve(inflateDir, "sea", "esbuild"), constants.S_IXUSR | constants.S_IRUSR | constants.S_IWUSR);
|
|
26
26
|
}
|
|
27
|
-
writeFile(logger, resolve(inflateDir, "sea", "postject.cjs"), Buffer.from(Buffer.from(getAsset("postject.base64.cjs")).toString(), "base64"));
|
|
27
|
+
// writeFile(logger, resolve(inflateDir, "sea", "postject.cjs"), Buffer.from(Buffer.from(getAsset("postject.base64.cjs")).toString(), "base64"));
|
|
28
28
|
writeFile(logger, resolve(inflateDir, "sea", "config.json"), Buffer.from(getAsset("sea.basic.config.json")));
|
|
29
29
|
writeFile(logger, resolve(inflateDir, "sea", "run.sh"), Buffer.from(getAsset("app.sh")));
|
|
30
30
|
writeFile(logger, resolve(inflateDir, "sea", "node.sh"), Buffer.from(getAsset("node.sh")));
|
|
@@ -38,16 +38,16 @@ export async function inflateAppForSea(logger, inflateDir, services, port) {
|
|
|
38
38
|
inflateSeaAssets(logger, inflateDir);
|
|
39
39
|
writeFile(logger, resolve(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
|
|
40
40
|
const WSLIST = services.filter(service => getWSConfigPath(resolve(cwd(), service))).map(service => {
|
|
41
|
-
return `(await
|
|
41
|
+
return `(await require("../${service}/ws.cjs")).default`;
|
|
42
42
|
}).join(",");
|
|
43
43
|
const SERVERCONFIGLIST = services.filter(service => getServerConfigPath(resolve(cwd(), service))).map(service => {
|
|
44
|
-
return `(await
|
|
44
|
+
return `(await require("../${service}/server.cjs")).default`;
|
|
45
45
|
}).join(",\n");
|
|
46
46
|
const DBCONFIGLIST = services.filter(service => getDBConfigPath(resolve(cwd(), service))).map(service => {
|
|
47
47
|
return `new Promise(async (resolve, reject) => {
|
|
48
48
|
try {
|
|
49
|
-
const db = await dbManager.setupDB((await
|
|
50
|
-
await (await
|
|
49
|
+
const db = await dbManager.setupDB((await require("../${service}/db.cjs")).default);
|
|
50
|
+
await (await require("./${service}/migration-up.cjs")).runMigrations(db);
|
|
51
51
|
resolve();
|
|
52
52
|
} catch(e) {
|
|
53
53
|
reject(e);
|
|
@@ -56,7 +56,7 @@ export async function inflateAppForSea(logger, inflateDir, services, port) {
|
|
|
56
56
|
})`;
|
|
57
57
|
}).join(",");
|
|
58
58
|
writeFile(logger, join(inflateDir, "sea", "package.json"), `{ "type": "module", "private": true }`);
|
|
59
|
-
writeFile(logger, join(inflateDir, "sea", "app.cjs"), `const { createServerInterface, ServerRequestHandler, WebSocketManager,
|
|
59
|
+
writeFile(logger, join(inflateDir, "sea", "app.cjs"), `const { createServerInterface, ServerRequestHandler, WebSocketManager, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
|
|
60
60
|
|
|
61
61
|
async function main() {
|
|
62
62
|
const PORT = "${PORT}";
|
|
@@ -65,7 +65,6 @@ async function main() {
|
|
|
65
65
|
const cache = new ClusterCache();
|
|
66
66
|
const webSocketManager = new WebSocketManager();
|
|
67
67
|
const dbManager = new DBManager();
|
|
68
|
-
await initGlobals();
|
|
69
68
|
const serverInterface = createServerInterface({
|
|
70
69
|
cache,
|
|
71
70
|
localCache,
|
|
@@ -85,7 +84,7 @@ async function main() {
|
|
|
85
84
|
${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.preload).map(config=>config.preload(serverInterface)));\n` : ""}
|
|
86
85
|
app.use(ServerRequestHandler(serverInterface));
|
|
87
86
|
app.use(LoggerHandler());
|
|
88
|
-
${services.map(service => `app.use(await (await
|
|
87
|
+
${services.map(service => `app.use(await (await require("./${join(service, "router.cjs")}")).setupRouter());`).join("\n")}
|
|
89
88
|
${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.load).map(config=>config.load(serverInterface)));\n` : ""}
|
|
90
89
|
|
|
91
90
|
await app.listen(PORT);
|
|
@@ -112,20 +111,20 @@ main().catch(e=>console.error(e));
|
|
|
112
111
|
export async function inflateServiceForSea(logger, inflateDir, service, servicePath /*, serviceMigrations: string[]*/, serviceRouteFileMap, serviceStaticFileMap) {
|
|
113
112
|
const migrationsFolderPath = getMigrationsPath(servicePath);
|
|
114
113
|
const serviceMigrations = migrationsFolderPath ? migration.getSortedMigrations(migrationsFolderPath) : [];
|
|
115
|
-
writeFile(logger, join(inflateDir, "sea", service, "router.
|
|
116
|
-
|
|
114
|
+
writeFile(logger, join(inflateDir, "sea", service, "router.cjs"), `const { appendAPIModule, Router, middleware } = require("./../lib.cjs");\n
|
|
115
|
+
async function setupRouter() {
|
|
117
116
|
const router = new Router();
|
|
118
117
|
${getErrorConfigPath(servicePath) ? `
|
|
119
|
-
const errorConfig = (await
|
|
118
|
+
const errorConfig = (await require("../../${service}/catch.cjs")).default;
|
|
120
119
|
if(errorConfig && errorConfig.catch) {
|
|
121
120
|
for(const m of errorConfig.catch) {
|
|
122
121
|
router.catch(m);
|
|
123
122
|
}
|
|
124
123
|
}` : ""}
|
|
125
|
-
${getCORSConfigPath(servicePath) ? ` router.use(
|
|
126
|
-
${getAuthConfigPath(servicePath) ? ` router.use(
|
|
124
|
+
${getCORSConfigPath(servicePath) ? ` router.use(middleware.cors((await require("../../${service}/cors.cjs")).default));` : ""}
|
|
125
|
+
${getAuthConfigPath(servicePath) ? ` router.use(middleware.session((await require("../../${service}/auth.cjs")).default));` : ""}
|
|
127
126
|
${getMiddlewareConfigPath(servicePath) ? `
|
|
128
|
-
const middlewareConfig = (await
|
|
127
|
+
const middlewareConfig = (await require("../../${service}/middleware.cjs")).default;
|
|
129
128
|
if(middlewareConfig && middlewareConfig.middleware) {
|
|
130
129
|
for(const m of middlewareConfig.middleware) {
|
|
131
130
|
router.use(m);
|
|
@@ -139,14 +138,14 @@ ${Object.keys(serviceRouteFileMap)
|
|
|
139
138
|
if (rPath) {
|
|
140
139
|
const rPathExt = extname(rPath);
|
|
141
140
|
const apiInflatedPath = join("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".cjs");
|
|
142
|
-
return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await
|
|
141
|
+
return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await require("./${apiInflatedPath}")).default);`;
|
|
143
142
|
}
|
|
144
143
|
else {
|
|
145
144
|
return "";
|
|
146
145
|
}
|
|
147
146
|
}).filter(l => l)[0])
|
|
148
147
|
.join("\n")}
|
|
149
|
-
router.use(await (await
|
|
148
|
+
router.use(await (await require("./static-router.cjs")).setupRouter())
|
|
150
149
|
|
|
151
150
|
${getMiddlewareConfigPath(servicePath) ? `
|
|
152
151
|
if(middlewareConfig && middlewareConfig.post) {
|
|
@@ -156,29 +155,38 @@ ${getMiddlewareConfigPath(servicePath) ? `
|
|
|
156
155
|
}` : ""}
|
|
157
156
|
|
|
158
157
|
return router;
|
|
158
|
+
}
|
|
159
|
+
module.exports = {
|
|
160
|
+
setupRouter
|
|
159
161
|
}`);
|
|
160
|
-
writeFile(logger, join(inflateDir, "sea", service, "migration-up.
|
|
161
|
-
|
|
162
|
+
writeFile(logger, join(inflateDir, "sea", service, "migration-up.cjs"), `const { migration } = require("./../lib.cjs");\n
|
|
163
|
+
async function runMigrations(db) {
|
|
162
164
|
await migration.init(db);
|
|
163
165
|
${serviceMigrations.map(file => {
|
|
164
166
|
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
165
|
-
return ` await migration.up.module(db, "${file}", (await
|
|
167
|
+
return ` await migration.up.module(db, "${file}", (await require("../../${service}/migration/${name}.cjs")).default)`;
|
|
166
168
|
}).join("\n")}
|
|
169
|
+
}
|
|
170
|
+
module.exports = {
|
|
171
|
+
runMigrations
|
|
167
172
|
}`);
|
|
168
|
-
writeFile(logger, join(inflateDir, "sea", service, "migration-down.
|
|
169
|
-
|
|
173
|
+
writeFile(logger, join(inflateDir, "sea", service, "migration-down.cjs"), `const { migration } = require("./../lib.cjs");\n
|
|
174
|
+
async function runMigrations(db) {
|
|
170
175
|
await migration.init(db);
|
|
171
176
|
${serviceMigrations.reverse().map(file => {
|
|
172
177
|
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
173
|
-
return ` await migration.down.module(db, "${file}", (await
|
|
178
|
+
return ` await migration.down.module(db, "${file}", (await require("../../${service}/migration/${name}.cjs")).default)`;
|
|
174
179
|
}).join("\n")}
|
|
180
|
+
}
|
|
181
|
+
module.exports = {
|
|
182
|
+
runMigrations
|
|
175
183
|
}`);
|
|
176
184
|
const staticFiles = Object.keys(serviceStaticFileMap);
|
|
177
185
|
/*if (staticFiles.length !== 0) {
|
|
178
186
|
writeFile(logger, join(inflateDir, "sea", service, "static.base64.json"), JSON.stringify(serviceStaticFileMap));
|
|
179
187
|
}*/
|
|
180
|
-
writeFile(logger, join(inflateDir, "sea", service, "static-router.
|
|
181
|
-
|
|
188
|
+
writeFile(logger, join(inflateDir, "sea", service, "static-router.cjs"), `const { appendAPIModule, Router } = require("./../lib.cjs");\n
|
|
189
|
+
async function setupRouter() {
|
|
182
190
|
const router = new Router();
|
|
183
191
|
${staticFiles.length === 0 ? "" : `
|
|
184
192
|
${staticFiles.map((filePath) => {
|
|
@@ -194,6 +202,9 @@ ${staticFiles.map((filePath) => {
|
|
|
194
202
|
}).join("\n")}
|
|
195
203
|
`}
|
|
196
204
|
return router;
|
|
205
|
+
}
|
|
206
|
+
module.exports = {
|
|
207
|
+
setupRouter
|
|
197
208
|
}`);
|
|
198
209
|
}
|
|
199
210
|
function writeFile(logger, path, buffer) {
|
|
@@ -2,7 +2,7 @@ import { Router } from "@miqro/core";
|
|
|
2
2
|
import { setupHTTPRouter } from "./setup-http.js";
|
|
3
3
|
//import { WSMapConfig } from "./utils/websocketmanager.js";
|
|
4
4
|
//import { ServerConfigMap, setupServerConfig } from "./setup-server-config.js";
|
|
5
|
-
import { assertGlobalTampered } from "../services/globals.js";
|
|
5
|
+
// import { assertGlobalTampered } from "../services/globals.js";
|
|
6
6
|
import { getServicePath } from "../common/paths.js";
|
|
7
7
|
import { inflateWSConfig } from "./setup-ws.js";
|
|
8
8
|
import { inflateAppForSea, inflateServiceForSea } from "./inflate-sea.js";
|
|
@@ -17,7 +17,7 @@ export async function inflateApp({ inflateParallel, serverInterface, logger, hot
|
|
|
17
17
|
const router = new Router();
|
|
18
18
|
const logConfigMap = {};
|
|
19
19
|
//const serverConfigMap: ServerConfigMap = {};
|
|
20
|
-
router.use(assertGlobalTampered);
|
|
20
|
+
// router.use(assertGlobalTampered);
|
|
21
21
|
/*if (editor) {
|
|
22
22
|
logger.info("setting up editor on %s", BASEEDITOR_PATH);
|
|
23
23
|
const editorRouter = await createEditorRouter();
|
|
@@ -48,7 +48,7 @@ export async function inflateApp({ inflateParallel, serverInterface, logger, hot
|
|
|
48
48
|
...routeFileMap,
|
|
49
49
|
...serviceRouteFileMap
|
|
50
50
|
};
|
|
51
|
-
await setupDoc(logger, servicePath, service, router, routeFileMap, inflateDir, errors);
|
|
51
|
+
await setupDoc(logger, servicePath, service, router, routeFileMap, serviceStaticFileMap, inflateDir, errors);
|
|
52
52
|
await inflateWSConfig(logger, servicePath, service, wsConfigList, inflateSea ? inflateDir : undefined, errors);
|
|
53
53
|
//await setupServerConfig(logger, servicePath, service, serverConfigMap, inflateSea ? inflateDir : undefined, errors);
|
|
54
54
|
if (inflateDir && inflateSea) {
|
|
@@ -61,6 +61,6 @@ export async function inflateApp({ inflateParallel, serverInterface, logger, hot
|
|
|
61
61
|
if (inflateDir && inflateSea) {
|
|
62
62
|
await inflateAppForSea(logger, inflateDir, services, port);
|
|
63
63
|
}
|
|
64
|
-
router.use(assertGlobalTampered);
|
|
64
|
+
// router.use(assertGlobalTampered);
|
|
65
65
|
return errors.length === 0 ? [router, null, routeFileMap /*, migrations*/, wsConfigList /*, serverConfigMap*/, logConfigMap] : [router, errors, routeFileMap /*, migrations*/, wsConfigList /*, serverConfigMap*/, logConfigMap];
|
|
66
66
|
}
|
|
@@ -18,7 +18,7 @@ export async function setupAUTH(logger, servicePath, service, mainRouter, inflat
|
|
|
18
18
|
});
|
|
19
19
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
20
20
|
writeFileSync(inflatePath, await inflateJSX(authPath, {
|
|
21
|
-
embemedJSX: false,
|
|
21
|
+
// embemedJSX: false,
|
|
22
22
|
minify: false,
|
|
23
23
|
useExport: true,
|
|
24
24
|
platform: "node",
|
|
@@ -18,7 +18,7 @@ export async function setupCORS(logger, servicePath, service, mainRouter, inflat
|
|
|
18
18
|
});
|
|
19
19
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
20
20
|
writeFileSync(inflatePath, await inflateJSX(corsPath, {
|
|
21
|
-
embemedJSX: false,
|
|
21
|
+
// embemedJSX: false,
|
|
22
22
|
minify: false,
|
|
23
23
|
useExport: true,
|
|
24
24
|
platform: "node",
|
|
@@ -28,7 +28,7 @@ export async function inflateDBConfig(logger, service, dbConfigList, inflateDir,
|
|
|
28
28
|
});
|
|
29
29
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
30
30
|
writeFileSync(inflatePath, await inflateJSX(dbConfigPath, {
|
|
31
|
-
embemedJSX: false,
|
|
31
|
+
// embemedJSX: false,
|
|
32
32
|
minify: false,
|
|
33
33
|
useExport: true,
|
|
34
34
|
platform: "node",
|
|
@@ -76,7 +76,7 @@ export async function inflateDBMigrations(logger, service, dbName, inflateDir, e
|
|
|
76
76
|
});
|
|
77
77
|
logger?.log("writing [%s]", relative(cwd(), inflatePath));
|
|
78
78
|
writeFileSync(inflatePath, await inflateJSX(resolve(migrationsFolderPath, migrationName), {
|
|
79
|
-
embemedJSX: false,
|
|
79
|
+
// embemedJSX: false,
|
|
80
80
|
minify: false,
|
|
81
81
|
useExport: true,
|
|
82
82
|
platform: "node",
|
|
@@ -21,7 +21,7 @@ export async function setupError(logger, servicePath, service, mainRouter, infla
|
|
|
21
21
|
});
|
|
22
22
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
23
23
|
writeFileSync(inflatePath, await inflateJSX(errorPath, {
|
|
24
|
-
embemedJSX: false,
|
|
24
|
+
// embemedJSX: false,
|
|
25
25
|
minify: false,
|
|
26
26
|
useExport: true,
|
|
27
27
|
platform: "node",
|
|
@@ -6,7 +6,7 @@ import { importHTMLModule, importAPIRoute, inflateJSX, importJSONModule, jsx2HTM
|
|
|
6
6
|
import { createNodeRuntime } from "@miqro/jsx-node";
|
|
7
7
|
import { getHotReloadScript } from "../services/hot-reload.js";
|
|
8
8
|
import { cwd } from "node:process";
|
|
9
|
-
import { assertGlobalTampered } from "../services/globals.js";
|
|
9
|
+
// import { assertGlobalTampered } from "../services/globals.js";
|
|
10
10
|
import { getHTTPRouterPath, getStaticFilesPath } from "../common/paths.js";
|
|
11
11
|
import { setupCORS } from "./setup-cors.js";
|
|
12
12
|
import { setupAUTH } from "./setup-auth.js";
|
|
@@ -84,7 +84,7 @@ async function createStaticRoute(service, logger, router, dir, file, inflateDir,
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
router.use(assertGlobalTampered);
|
|
87
|
+
// router.use(assertGlobalTampered);
|
|
88
88
|
router.get(path, async function (_req, res) {
|
|
89
89
|
await new Promise((resolve, reject) => {
|
|
90
90
|
try {
|
|
@@ -145,7 +145,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
145
145
|
const maxParallel = inflateParallel ? inflateParallel : 1;
|
|
146
146
|
server.logger.debug("loading http directory with parallel [%s]", maxParallel);
|
|
147
147
|
let tR = [];
|
|
148
|
-
router.use(assertGlobalTampered);
|
|
148
|
+
// router.use(assertGlobalTampered);
|
|
149
149
|
const files = scanFiles(dir);
|
|
150
150
|
for (const file of files) {
|
|
151
151
|
tR.push(new Promise(async (resolve) => {
|
|
@@ -172,7 +172,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
172
172
|
previewMethod: "api"
|
|
173
173
|
};
|
|
174
174
|
const inflatedCode = inflateDir ? await inflateJSX(file.filePath, {
|
|
175
|
-
embemedJSX: false,
|
|
175
|
+
// embemedJSX: false,
|
|
176
176
|
minify: false,
|
|
177
177
|
useExport: true,
|
|
178
178
|
platform: "node",
|
|
@@ -197,7 +197,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
197
197
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
198
198
|
await writeFileASync(inflatePath, inflatedCode);
|
|
199
199
|
}
|
|
200
|
-
router.use(assertGlobalTampered);
|
|
200
|
+
// router.use(assertGlobalTampered);
|
|
201
201
|
router.use(module.handler, r.path, r.method, r.options);
|
|
202
202
|
}
|
|
203
203
|
return resolve();
|
|
@@ -243,7 +243,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
router.use(assertGlobalTampered);
|
|
246
|
+
// router.use(assertGlobalTampered);
|
|
247
247
|
router.use(async function (req, res) {
|
|
248
248
|
const JSON = await getJSON(req, res, newURL(req.path), module.apiOptions?.basePath, module.default);
|
|
249
249
|
return res.asyncEnd({
|
|
@@ -298,7 +298,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
router.use(assertGlobalTampered);
|
|
301
|
+
// router.use(assertGlobalTampered);
|
|
302
302
|
router.use(async function (req, res) {
|
|
303
303
|
const toRender = typeof module.default === "function" ? module.default(req, res) : module.default;
|
|
304
304
|
const HTML = await getHTML(hotreload, req, res, newURL(req.path), module.apiOptions?.basePath, await toRender);
|
|
@@ -319,9 +319,9 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
319
319
|
// allow fall-through when extension is .js and .ts because is a static route without embemedJSX
|
|
320
320
|
if (file.ext !== ".js" && file.ext !== ".ts") {
|
|
321
321
|
const code = await inflateJSX(file.filePath, {
|
|
322
|
-
embemedJSX: true,
|
|
322
|
+
// embemedJSX: true,
|
|
323
323
|
minify: file.subExt === ".min" ? true : false,
|
|
324
|
-
useExport:
|
|
324
|
+
useExport: true,
|
|
325
325
|
logger
|
|
326
326
|
});
|
|
327
327
|
const contentType = CONTENT_TYPE_MAP[".js"];
|
|
@@ -354,7 +354,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
354
354
|
};
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
|
-
router.use(assertGlobalTampered);
|
|
357
|
+
// router.use(assertGlobalTampered);
|
|
358
358
|
router.get(path, async function (req, res) {
|
|
359
359
|
return res.asyncEnd({
|
|
360
360
|
status: 200,
|
|
@@ -403,7 +403,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
403
403
|
};
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
router.use(assertGlobalTampered);
|
|
406
|
+
// router.use(assertGlobalTampered);
|
|
407
407
|
router.get(path, async function (_req, res) {
|
|
408
408
|
res.asyncEnd({
|
|
409
409
|
status: 200,
|
|
@@ -427,9 +427,9 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
427
427
|
case ".bundle":
|
|
428
428
|
case ".min": {
|
|
429
429
|
const code = await inflateJSX(file.filePath, {
|
|
430
|
-
embemedJSX: false,
|
|
430
|
+
// embemedJSX: false,
|
|
431
431
|
minify: file.subExt === ".min" ? true : false,
|
|
432
|
-
useExport:
|
|
432
|
+
useExport: true,
|
|
433
433
|
logger
|
|
434
434
|
});
|
|
435
435
|
const contentType = CONTENT_TYPE_MAP[".js"];
|
|
@@ -462,7 +462,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
|
-
router.use(assertGlobalTampered);
|
|
465
|
+
// router.use(assertGlobalTampered);
|
|
466
466
|
router.get(path, async function (_req, res) {
|
|
467
467
|
res.asyncEnd({
|
|
468
468
|
status: 200,
|
|
@@ -519,7 +519,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
519
519
|
};
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
-
router.use(assertGlobalTampered);
|
|
522
|
+
// router.use(assertGlobalTampered);
|
|
523
523
|
router.get(path, async function (_req, res) {
|
|
524
524
|
res.asyncEnd({
|
|
525
525
|
status: 200,
|
|
@@ -558,7 +558,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
558
558
|
await Promise.all(tR);
|
|
559
559
|
tR = [];
|
|
560
560
|
}
|
|
561
|
-
router.use(assertGlobalTampered);
|
|
561
|
+
// router.use(assertGlobalTampered);
|
|
562
562
|
return {
|
|
563
563
|
routeFileMap,
|
|
564
564
|
router,
|
|
@@ -17,7 +17,7 @@ export async function setupLogConfig(logger, servicePath, service, logConfigMap,
|
|
|
17
17
|
});
|
|
18
18
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
19
19
|
writeFileSync(inflatePath, await inflateJSX(logPath, {
|
|
20
|
-
embemedJSX: false,
|
|
20
|
+
// embemedJSX: false,
|
|
21
21
|
minify: false,
|
|
22
22
|
useExport: true,
|
|
23
23
|
platform: "node",
|
|
@@ -21,7 +21,7 @@ export async function setupMiddleware(logger, servicePath, service, mainRouter,
|
|
|
21
21
|
});
|
|
22
22
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
23
23
|
writeFileSync(inflatePath, await inflateJSX(middlewarePath, {
|
|
24
|
-
embemedJSX: false,
|
|
24
|
+
// embemedJSX: false,
|
|
25
25
|
minify: false,
|
|
26
26
|
platform: "node",
|
|
27
27
|
useExport: true,
|
|
@@ -17,7 +17,7 @@ export async function setupServerConfig(logger, servicePath, service, serverConf
|
|
|
17
17
|
});
|
|
18
18
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
19
19
|
writeFileSync(inflatePath, await inflateJSX(serverPath, {
|
|
20
|
-
embemedJSX: false,
|
|
20
|
+
// embemedJSX: false,
|
|
21
21
|
minify: false,
|
|
22
22
|
platform: "node",
|
|
23
23
|
useExport: true,
|
|
@@ -24,7 +24,7 @@ export async function inflateWSConfig(logger, servicePath, service, wsConfigList
|
|
|
24
24
|
});
|
|
25
25
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
26
26
|
writeFileSync(inflatePath, await inflateJSX(wsPath, {
|
|
27
|
-
embemedJSX: false,
|
|
27
|
+
// embemedJSX: false,
|
|
28
28
|
minify: false,
|
|
29
29
|
platform: "node",
|
|
30
30
|
useExport: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Logger, Router } from "@miqro/core";
|
|
2
2
|
import { InflateError } from "../common/jsx.js";
|
|
3
|
-
import { RouteFileMap } from "./setup-http.js";
|
|
4
|
-
export declare function setupDoc(logger: Logger, servicePath: string, service: string, mainRouter: Router, fileMap: RouteFileMap, inflateDir: string | undefined | false, errors: InflateError[]): Promise<any>;
|
|
3
|
+
import { RouteFileMap, StaticFileMap } from "./setup-http.js";
|
|
4
|
+
export declare function setupDoc(logger: Logger, servicePath: string, service: string, mainRouter: Router, fileMap: RouteFileMap, staticFileMap: StaticFileMap, inflateDir: string | undefined | false, errors: InflateError[]): Promise<any>;
|
|
@@ -5,7 +5,7 @@ import { mkdirSync, writeFileSync } from "node:fs";
|
|
|
5
5
|
import { cwd } from "node:process";
|
|
6
6
|
import { getDocOutput } from "../bin/generate-doc.js";
|
|
7
7
|
import { CONTENT_TYPE_MAP } from "../common/content-type.js";
|
|
8
|
-
export async function setupDoc(logger, servicePath, service, mainRouter, fileMap, inflateDir, errors) {
|
|
8
|
+
export async function setupDoc(logger, servicePath, service, mainRouter, fileMap, staticFileMap, inflateDir, errors) {
|
|
9
9
|
const docPath = getDocConfigPath(servicePath); //resolve(process.cwd(), service, "auth.ts");
|
|
10
10
|
if (docPath) {
|
|
11
11
|
try {
|
|
@@ -15,11 +15,12 @@ export async function setupDoc(logger, servicePath, service, mainRouter, fileMap
|
|
|
15
15
|
const paths = Object.keys(docModule.publish);
|
|
16
16
|
for (const path of paths) {
|
|
17
17
|
const config = docModule.publish[path];
|
|
18
|
+
const contentType = config.type === "MD" ? CONTENT_TYPE_MAP[".md"] :
|
|
19
|
+
config.type === "JSON" ? CONTENT_TYPE_MAP[".json"] : CONTENT_TYPE_MAP[".html"];
|
|
18
20
|
const body = await getDocOutput(mainRouter, fileMap, config.all, config.type);
|
|
19
21
|
mainRouter.get(path, async (_, res) => {
|
|
20
22
|
switch (config.type) {
|
|
21
23
|
case "MD": {
|
|
22
|
-
const contentType = CONTENT_TYPE_MAP[".md"];
|
|
23
24
|
return await res.asyncEnd({
|
|
24
25
|
headers: {
|
|
25
26
|
"content-type": contentType
|
|
@@ -45,6 +46,26 @@ export async function setupDoc(logger, servicePath, service, mainRouter, fileMap
|
|
|
45
46
|
});
|
|
46
47
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
47
48
|
writeFileSync(inflatePath, body);
|
|
49
|
+
fileMap[docPath + path] = {
|
|
50
|
+
routes: [{
|
|
51
|
+
method: "GET",
|
|
52
|
+
path
|
|
53
|
+
}],
|
|
54
|
+
service,
|
|
55
|
+
filePath: docPath,
|
|
56
|
+
previewMethod: "html"
|
|
57
|
+
};
|
|
58
|
+
if (staticFileMap) {
|
|
59
|
+
staticFileMap[docPath + path] = {
|
|
60
|
+
contentType,
|
|
61
|
+
filePath: docPath,
|
|
62
|
+
previewMethod: "html",
|
|
63
|
+
method: "GET",
|
|
64
|
+
path,
|
|
65
|
+
body: Buffer.from(body),
|
|
66
|
+
inflatePath: inflateDir ? join(inflateDir, service, "static", path) : undefined
|
|
67
|
+
};
|
|
68
|
+
}
|
|
48
69
|
}
|
|
49
70
|
}
|
|
50
71
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describeFilePath } from "../../common/fs.js";
|
|
2
2
|
import { getRoutes } from "../../services/utils/get-route.js";
|
|
3
|
-
import { assertGlobalTampered } from "../../services/globals.js";
|
|
3
|
+
// import { assertGlobalTampered } from "../../services/globals.js";
|
|
4
4
|
import { dirname, join, relative } from "node:path";
|
|
5
5
|
export async function appendAPIModule(router, dir, filePath, module) {
|
|
6
6
|
const file = describeFilePath(filePath);
|
|
7
7
|
const routes = getRoutes(join("/", dirname(relative(dir, file.filePath))), file.subName, module);
|
|
8
8
|
for (const r of routes) {
|
|
9
|
-
router.use(assertGlobalTampered);
|
|
9
|
+
// router.use(assertGlobalTampered);
|
|
10
10
|
router.use(module.handler, r.path, r.method, r.options);
|
|
11
11
|
}
|
|
12
12
|
}
|
package/build/esm/src/lib.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Component, enableDebugLog, Fragment, Props } from "@miqro/jsx";
|
|
1
2
|
export * from "./types.js";
|
|
2
3
|
export { ClusterWebSocketServer2 } from "./services/utils/cluster-ws.js";
|
|
3
4
|
export { ClusterCache } from "./services/utils/cluster-cache.js";
|
|
@@ -6,8 +7,16 @@ export { WebSocketManager, WebSocketManagerOptions } from "./services/utils/webs
|
|
|
6
7
|
export { DBManager } from "./services/utils/db-manager.js";
|
|
7
8
|
export { LogProvider, LogProviderOptions } from "./services/utils/log.js";
|
|
8
9
|
export { Miqro, MiqroOptions, ServerRequestHandler } from "./services/app.js";
|
|
9
|
-
export {
|
|
10
|
+
export { jsx2HTML } from "./common/jsx.js";
|
|
10
11
|
export { appendAPIModule } from "./inflate/utils/sea-utils.js";
|
|
11
12
|
export { createServerInterface, ServerInterfaceImplOptions } from "./services/utils/server-interface.js";
|
|
12
13
|
export { App, LoggerHandler, Router } from "@miqro/core";
|
|
13
14
|
export { migration } from "@miqro/query";
|
|
15
|
+
export { middleware } from "./services/utils/middleware.js";
|
|
16
|
+
export { jwt } from "./services/utils/jwt.js";
|
|
17
|
+
export declare const JSX: {
|
|
18
|
+
createElement: (tag: string | Component<any> | typeof Fragment, attributes: Props<any>, ...children: any[]) => JSX.Element;
|
|
19
|
+
Fragment: symbol;
|
|
20
|
+
enableDebugLog: typeof enableDebugLog;
|
|
21
|
+
};
|
|
22
|
+
export * as jsx from "@miqro/jsx";
|
package/build/esm/src/lib.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { enableDebugLog, Fragment, createElement as realCreateElement } from "@miqro/jsx";
|
|
2
|
+
import { jsx2HTML } from "./common/jsx.js";
|
|
1
3
|
/*export * from "@miqro/core";
|
|
2
4
|
export * from "@miqro/query";*/
|
|
3
5
|
export * from "./types.js";
|
|
@@ -8,9 +10,22 @@ export { WebSocketManager } from "./services/utils/websocketmanager.js";
|
|
|
8
10
|
export { DBManager } from "./services/utils/db-manager.js";
|
|
9
11
|
export { LogProvider } from "./services/utils/log.js";
|
|
10
12
|
export { Miqro, ServerRequestHandler } from "./services/app.js";
|
|
11
|
-
export { initGlobals, assertGlobalTampered } from "./services/globals.js";
|
|
13
|
+
// export { initGlobals, assertGlobalTampered } from "./services/globals.js";
|
|
14
|
+
export { jsx2HTML } from "./common/jsx.js";
|
|
12
15
|
//exported for --inflate-sea
|
|
13
16
|
export { appendAPIModule } from "./inflate/utils/sea-utils.js";
|
|
14
17
|
export { createServerInterface } from "./services/utils/server-interface.js";
|
|
15
18
|
export { App, LoggerHandler, Router } from "@miqro/core";
|
|
16
19
|
export { migration } from "@miqro/query";
|
|
20
|
+
export { middleware } from "./services/utils/middleware.js";
|
|
21
|
+
export { jwt } from "./services/utils/jwt.js";
|
|
22
|
+
export const JSX = {
|
|
23
|
+
createElement: (...args) => {
|
|
24
|
+
const ret = realCreateElement(...args);
|
|
25
|
+
ret.toString = () => jsx2HTML(ret);
|
|
26
|
+
return ret;
|
|
27
|
+
},
|
|
28
|
+
Fragment,
|
|
29
|
+
enableDebugLog
|
|
30
|
+
};
|
|
31
|
+
export * as jsx from "@miqro/jsx";
|
package/build/esm/src/main.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Miqro } from "./services/app.js";
|
|
|
9
9
|
import { TEST_SOCKET } from "./common/paths.js";
|
|
10
10
|
import { Logger } from "@miqro/core";
|
|
11
11
|
async function main(args) {
|
|
12
|
-
if (args.
|
|
12
|
+
if (args.install || args.installTSConfig || args.installMiqroJSON) {
|
|
13
13
|
await installTypings(args, new Logger(""));
|
|
14
14
|
process.exit(EXIT_CODES.NORMAL_EXIT);
|
|
15
15
|
}
|
|
@@ -13,7 +13,6 @@ import { createEditorRouter } from "./editor.js";
|
|
|
13
13
|
import { EDITOR_CONFIG_KEY, HOT_RELOAD_PATH } from "../common/constants.js";
|
|
14
14
|
import { watchAndServer } from "../common/watch.js";
|
|
15
15
|
import { LocalCache } from "./utils/cache.js";
|
|
16
|
-
import { initGlobals } from "./globals.js";
|
|
17
16
|
import { LogProvider } from "./utils/log.js";
|
|
18
17
|
import { initAssets } from "../common/assets.js";
|
|
19
18
|
import { setupExitHandlers } from "../common/exit.js";
|
|
@@ -156,7 +155,7 @@ export class Miqro {
|
|
|
156
155
|
if (this.inflated !== null) {
|
|
157
156
|
throw new Error("already inflated! call deflate()");
|
|
158
157
|
}
|
|
159
|
-
initGlobals();
|
|
158
|
+
// initGlobals();
|
|
160
159
|
// block others from inflating while inflateApp is running
|
|
161
160
|
this.inflated = undefined;
|
|
162
161
|
this.inflated = {
|
|
@@ -204,7 +203,7 @@ export class Miqro {
|
|
|
204
203
|
// init assets only once for all ApplicationServer's
|
|
205
204
|
if (Miqro.initAssetsPromise === null) {
|
|
206
205
|
// init globals only once for all inflations
|
|
207
|
-
initGlobals();
|
|
206
|
+
// initGlobals();
|
|
208
207
|
Miqro.initAssetsPromise = initAssets(this.logger);
|
|
209
208
|
}
|
|
210
209
|
await Miqro.initAssetsPromise;
|
|
@@ -253,7 +252,7 @@ export class Miqro {
|
|
|
253
252
|
// init assets only once for all ApplicationServer's
|
|
254
253
|
if (Miqro.initAssetsPromise === null) {
|
|
255
254
|
// init globals only once for all inflations
|
|
256
|
-
initGlobals();
|
|
255
|
+
// initGlobals();
|
|
257
256
|
Miqro.initAssetsPromise = initAssets(this.logger);
|
|
258
257
|
}
|
|
259
258
|
await Miqro.initAssetsPromise;
|
|
@@ -21,7 +21,7 @@ export async function runMigrations(logger, db, servicePath, service, inflateDir
|
|
|
21
21
|
});
|
|
22
22
|
logger?.log("writing [%s]", relative(cwd(), inflatePath));
|
|
23
23
|
writeFileSync(inflatePath, await inflateJSX(resolve(migrationsFolderPath, migration), {
|
|
24
|
-
embemedJSX: false,
|
|
24
|
+
// embemedJSX: false,
|
|
25
25
|
minify: false,
|
|
26
26
|
useExport: true,
|
|
27
27
|
platform: "node",
|
|
@@ -49,7 +49,7 @@ export async function runMigrationsDown(logger, db, servicePath, service, inflat
|
|
|
49
49
|
});
|
|
50
50
|
logger?.log("writing [%s]", relative(cwd(), inflatePath));
|
|
51
51
|
writeFileSync(inflatePath, await inflateJSX(resolve(migrationsFolderPath, migration), {
|
|
52
|
-
embemedJSX: false,
|
|
52
|
+
// embemedJSX: false,
|
|
53
53
|
platform: "node",
|
|
54
54
|
minify: false,
|
|
55
55
|
useExport: true,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { decodeJWT, decodeProtectedHeaderJWT, decryptJWT, encryptJWT, signJWT, verifyJWT } from "../../common/jwt.js";
|
|
2
|
+
import { createSecretKey } from "node:crypto";
|
|
3
|
+
export const jwt = {
|
|
4
|
+
createSecretKey,
|
|
5
|
+
decode(jwt) {
|
|
6
|
+
return decodeJWT(jwt);
|
|
7
|
+
},
|
|
8
|
+
decodeProtectedHeader(token) {
|
|
9
|
+
return decodeProtectedHeaderJWT(token);
|
|
10
|
+
},
|
|
11
|
+
decrypt(jwt, secret, options) {
|
|
12
|
+
return decryptJWT(jwt, secret, options);
|
|
13
|
+
},
|
|
14
|
+
encrypt(payload, secret, options) {
|
|
15
|
+
return encryptJWT(payload, secret, options);
|
|
16
|
+
},
|
|
17
|
+
sign(payload, secret, options) {
|
|
18
|
+
return signJWT(payload, secret, options);
|
|
19
|
+
},
|
|
20
|
+
verify(jwt, secret, options) {
|
|
21
|
+
return verifyJWT(jwt, secret, options);
|
|
22
|
+
}
|
|
23
|
+
};
|