tungsten 0.1.70 → 0.1.72
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/dist/Components.d.ts +2 -2
- package/dist/Components.d.ts.map +1 -1
- package/dist/Framework.d.ts.map +1 -1
- package/dist/Framework.js +11 -7
- package/dist/FrameworkConfig.d.ts +3 -1
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/Instance/Instance.d.ts +3 -1
- package/dist/Instance/Instance.d.ts.map +1 -1
- package/dist/Instance/Instance.js +39 -10
- package/dist/Servers/DevServer.d.ts +4 -1
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +143 -48
- package/dist/Servers/ProdServer.d.ts +0 -1
- package/dist/Servers/ProdServer.d.ts.map +1 -1
- package/dist/Servers/ProdServer.js +48 -12
- package/dist/Servers/TungstenServer.d.ts.map +1 -1
- package/dist/Servers/TungstenServer.js +21 -7
- package/dist/Servers/hono/DevServerHono.d.ts +2 -0
- package/dist/Servers/hono/DevServerHono.d.ts.map +1 -0
- package/dist/Servers/hono/DevServerHono.js +427 -0
- package/dist/Servers/hono/ProdServerHono.d.ts +2 -0
- package/dist/Servers/hono/ProdServerHono.d.ts.map +1 -0
- package/dist/Servers/hono/ProdServerHono.js +313 -0
- package/dist/Servers/hono/TungstenServerHono.d.ts +6 -0
- package/dist/Servers/hono/TungstenServerHono.d.ts.map +1 -0
- package/dist/Servers/hono/TungstenServerHono.js +53 -0
- package/dist/Servers/initStores.js +1 -1
- package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
- package/dist/Servers/loadEnvsDev.js +9 -1
- package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts +10 -0
- package/dist/Servers/tungstenCorePrivateEnvSchema.d.ts.map +1 -0
- package/dist/Servers/tungstenCorePrivateEnvSchema.js +24 -0
- package/dist/Store/InternalStoreSchema.d.ts +3 -1
- package/dist/Store/InternalStoreSchema.d.ts.map +1 -1
- package/dist/Store/InternalStoreSchema.js +3 -1
- package/dist/api/ApiEndpointHono.d.ts +3 -0
- package/dist/api/ApiEndpointHono.d.ts.map +1 -0
- package/dist/api/ApiEndpointHono.js +1 -0
- package/dist/api/ApiRouteHono.d.ts +7 -0
- package/dist/api/ApiRouteHono.d.ts.map +1 -0
- package/dist/api/ApiRouteHono.js +1 -0
- package/dist/api/ApiRoutesHono.d.ts +5 -0
- package/dist/api/ApiRoutesHono.d.ts.map +1 -0
- package/dist/api/ApiRoutesHono.js +1 -0
- package/dist/api/getApiRoutesHono.d.ts +6 -0
- package/dist/api/getApiRoutesHono.d.ts.map +1 -0
- package/dist/api/getApiRoutesHono.js +14 -0
- package/dist/build/modifySassImports.sxyt.js +1 -1
- package/dist/components/RouteRedirectComponent.d.ts +12 -0
- package/dist/components/RouteRedirectComponent.d.ts.map +1 -0
- package/dist/components/RouteRedirectComponent.js +15 -0
- package/dist/components/WebRedirectComponent.d.ts +11 -0
- package/dist/components/WebRedirectComponent.d.ts.map +1 -0
- package/dist/components/{RedirectComponent.js → WebRedirectComponent.js} +2 -2
- package/dist/defaultConfig.d.ts +2 -0
- package/dist/defaultConfig.d.ts.map +1 -1
- package/dist/defaultConfig.js +3 -1
- package/dist/env/Interfaces.d.ts +2 -4
- package/dist/env/Interfaces.d.ts.map +1 -1
- package/dist/frameworkConfigSchema.d.ts +7 -7
- package/dist/indexInner.d.ts +5 -2
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/indexInner.js +4 -1
- package/dist/makeFinalConfig.d.ts.map +1 -1
- package/dist/makeFinalConfig.js +1 -1
- package/dist/routing/RedirectCode.d.ts +2 -0
- package/dist/routing/RedirectCode.d.ts.map +1 -0
- package/dist/routing/RedirectCode.js +1 -0
- package/dist/routing/RouteDataFunction.type.d.ts +2 -1
- package/dist/routing/RouteDataFunction.type.d.ts.map +1 -1
- package/dist/routing/RouteDataReturnType.d.ts +2 -1
- package/dist/routing/RouteDataReturnType.d.ts.map +1 -1
- package/dist/routing/Routes.d.ts +5 -0
- package/dist/routing/Routes.d.ts.map +1 -1
- package/dist/routing/RoutingRedirect.d.ts +1 -1
- package/dist/routing/RoutingRedirect.d.ts.map +1 -1
- package/dist/routing/WebRedirect.d.ts +8 -0
- package/dist/routing/WebRedirect.d.ts.map +1 -0
- package/dist/routing/WebRedirect.js +11 -0
- package/dist/routing/registerGlobalData.d.ts +3 -1
- package/dist/routing/registerGlobalData.d.ts.map +1 -1
- package/dist/routing/registerGlobalData.js +4 -2
- package/package.json +35 -31
- package/types/helpers.d.ts +2 -0
- package/dist/components/RedirectComponent.d.ts +0 -12
- package/dist/components/RedirectComponent.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProdServer.d.ts","sourceRoot":"","sources":["../../src/Servers/ProdServer.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAI7B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAMpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAM3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAKnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"ProdServer.d.ts","sourceRoot":"","sources":["../../src/Servers/ProdServer.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAI7B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAMpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAM3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAKnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AASrD,qBAAa,UAAW,SAAQ,cAAc;IAC1C,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,uBAAuB,CAAA;IAC/B,eAAe,EAAE,eAAe,CAAA;IAChC,SAAS,EAAE,SAAS,CAAA;IACpB,mBAAmB,EAAE,gBAAgB,GAAG,IAAI,CAAA;IAK5C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAO;IAC9B,GAAG,EAAE,OAAO,CAAC,WAAW,CAAA;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IACrC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;gBAEX,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,uBAAuB,EAC/B,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,EACpB,mBAAmB,EAAE,gBAAgB,GAAG,IAAI,EAC5C,gBAAgB,EAAE,gBAAgB,GAAG,IAAI;IAuH7C,OAAO,CAAC,gBAAgB,CAgBvB;IACD,aAAa,GAAU,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,KAAG,OAAO,CAAC,IAAI,CAAC,CA6GjF;IACD,SAAS,eASR;IAMD,KAAK,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,UAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAwBlE,IAAI;CAKP"}
|
|
@@ -8,7 +8,7 @@ import { staticFolder, assetsFolder, packageNameCapitalized, publicFolder } from
|
|
|
8
8
|
import { rootToHtml as renderRootToHtml } from "../render/rootToHtml.js";
|
|
9
9
|
import { contentToHtml as renderContentToHtml } from "../render/contentToHtml.js";
|
|
10
10
|
import { Instance } from "../Instance/Instance.js";
|
|
11
|
-
import { cliOut, cliLog, cliNews, cliDebug } from "../cliOutput.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
11
|
+
import { cliOut, cliWarn, cliLog, cliNews, cliDebug } from "../cliOutput.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
12
12
|
import { TungstenError } from "../TungstenError.js";
|
|
13
13
|
import { makeInstanceConfigFromFrameworkConfig } from "../makeInstanceConfigFromFrameworkConfig.js";
|
|
14
14
|
//import { addRequireResolveHooks } from '../reRouting/addRequireResolveHooks.js'
|
|
@@ -33,7 +33,7 @@ export class ProdServer extends TungstenServer {
|
|
|
33
33
|
// projectDir: string
|
|
34
34
|
// prodBuildLocation: string
|
|
35
35
|
// bundleLocation: string
|
|
36
|
-
|
|
36
|
+
//port: number
|
|
37
37
|
_defineProperty(this, "location", null);
|
|
38
38
|
_defineProperty(this, "app", void 0);
|
|
39
39
|
_defineProperty(this, "apiRoutesPromise", void 0);
|
|
@@ -115,7 +115,7 @@ export class ProdServer extends TungstenServer {
|
|
|
115
115
|
value: false
|
|
116
116
|
};
|
|
117
117
|
const routes = typeof appRoutes === 'function' ? appRoutes(reqRes) : appRoutes;
|
|
118
|
-
const [globalData, matchedRouteInfo] = await Promise.all([globalDataFunc !== undefined ? globalDataFunc(reqRes) : {}, routing(location, routes, serverDataLoading)]);
|
|
118
|
+
const [globalData, matchedRouteInfo] = await Promise.all([globalDataFunc.value !== undefined ? globalDataFunc.value(reqRes) : {}, routing(location, routes, serverDataLoading)]);
|
|
119
119
|
//instance.matchedRouteInfo =
|
|
120
120
|
//cliTodo('Can we move redirect handling to base class?')
|
|
121
121
|
// // 2025-03-14 copied this code here from Dev server,
|
|
@@ -185,15 +185,14 @@ export class ProdServer extends TungstenServer {
|
|
|
185
185
|
this.compilationInfo = compilationInfo;
|
|
186
186
|
this.appRoutes = _appRoutes;
|
|
187
187
|
this.RootComponentOrNull = _RootComponentOrNull;
|
|
188
|
-
if (tungstenPrivateEnv.TUNGSTEN_SERVER_PORT === -999) {
|
|
189
|
-
|
|
190
|
-
}
|
|
188
|
+
// if (tungstenPrivateEnv.TUNGSTEN_SERVER_PORT === -999) {
|
|
189
|
+
// throwError('ProdServer', 'TUNGSTEN_SERVER_PORT environment variable has not been set')
|
|
190
|
+
// }
|
|
191
191
|
// !! I wrote this line while drunk. Please check this over. I think its wrong
|
|
192
|
-
const _port = Number(typeof tungstenPrivateEnv !== 'undefined'
|
|
192
|
+
//const _port = Number((typeof tungstenPrivateEnv !== 'undefined')
|
|
193
|
+
// ? tungstenPrivateEnv.TUNGSTEN_SERVER_PORT
|
|
194
|
+
// : process.env.TUNGSTEN_SERVER_PORT)
|
|
193
195
|
// seems like all we need is:
|
|
194
|
-
//const _port = tungstenPrivateEnv.TUNGSTEN_SERVER_PORT
|
|
195
|
-
if (isNaN(_port) || _port === 0) throwError('ProdServer', portError(_port));
|
|
196
|
-
this.port = _port;
|
|
197
196
|
this.app = express();
|
|
198
197
|
if (tungstenPrivateEnv.DEBUG === true) {
|
|
199
198
|
let reqId = 0;
|
|
@@ -203,6 +202,31 @@ export class ProdServer extends TungstenServer {
|
|
|
203
202
|
next();
|
|
204
203
|
});
|
|
205
204
|
}
|
|
205
|
+
const requestLog = tungstenPrivateEnv.DEBUG === true;
|
|
206
|
+
const originMismatchWarning = this.config.suppressOriginMismatchWarning !== true;
|
|
207
|
+
if (requestLog || originMismatchWarning) {
|
|
208
|
+
this.app.use((req, res, next) => {
|
|
209
|
+
const target = req.protocol + '://' + String(req.header('host')) + req.url;
|
|
210
|
+
const origin = req.header('origin');
|
|
211
|
+
// request log
|
|
212
|
+
if (requestLog) {
|
|
213
|
+
let message = 'Received request at ' + target;
|
|
214
|
+
if (origin !== undefined) {
|
|
215
|
+
message += ' from ' + String(req.header('origin'));
|
|
216
|
+
// should we use referrer as a backup option?
|
|
217
|
+
// not sure what that is
|
|
218
|
+
}
|
|
219
|
+
cliOut(message);
|
|
220
|
+
}
|
|
221
|
+
// origin-target mismatch warning
|
|
222
|
+
if (originMismatchWarning) {
|
|
223
|
+
if (origin !== undefined && origin === this.location && origin !== target) {
|
|
224
|
+
cliWarn(`Received a request from the frontend, but it's origin` + ` is not the same as the request origin.` + ` This may indicate a misconfiguration, and may prevent` + ` the passing of cookies to the tungsten server.`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
next();
|
|
228
|
+
});
|
|
229
|
+
}
|
|
206
230
|
if (serverMiddleware) {
|
|
207
231
|
const {
|
|
208
232
|
path,
|
|
@@ -235,12 +259,24 @@ export class ProdServer extends TungstenServer {
|
|
|
235
259
|
// private async handlePost(req: express.Request, res: express.Response): Promise<void> {
|
|
236
260
|
// throw new TungstenError(`Err - Dev server received a post request. Not supported yet.`)
|
|
237
261
|
// }
|
|
262
|
+
// I don't think we ever override the port, not sure why
|
|
238
263
|
start(portOverride, mute = false) {
|
|
239
264
|
return new Promise(resolve => {
|
|
240
|
-
const
|
|
265
|
+
const proto = tungstenPrivateEnv.FRONTEND_PROTO ?? 'http';
|
|
266
|
+
const host = tungstenPrivateEnv.FRONTEND_HOST ?? 'localhost';
|
|
267
|
+
let port;
|
|
268
|
+
if (portOverride !== undefined) {
|
|
269
|
+
port = portOverride;
|
|
270
|
+
} else {
|
|
271
|
+
const _port = tungstenPrivateEnv.TUNGSTEN_SERVER_PORT ?? 3000;
|
|
272
|
+
if (isNaN(_port) || _port === 0) throwError('ProdServer', portError(_port));
|
|
273
|
+
port = _port;
|
|
274
|
+
}
|
|
275
|
+
//const port = (portOverride !== undefined) ? portOverride : port
|
|
241
276
|
// eslint-disable-next-line no-console
|
|
242
277
|
this.server = this.app.listen(port, () => {
|
|
243
|
-
|
|
278
|
+
const serverAddress = this.server.address(); // eslint-disable-line @typescript-eslint/no-non-null-assertion, no-type-assertion/no-type-assertion
|
|
279
|
+
this.location = `${proto}://${host}:${serverAddress.port}`;
|
|
244
280
|
if (!mute) cliNews(`${packageNameCapitalized} prod server ready at ${this.location}`);
|
|
245
281
|
resolve(this.location);
|
|
246
282
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TungstenServer.d.ts","sourceRoot":"","sources":["../../src/Servers/TungstenServer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,KAAK,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"TungstenServer.d.ts","sourceRoot":"","sources":["../../src/Servers/TungstenServer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,KAAK,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,SAAS,CAAA;AAiB1D,qBAAa,cAAc;IACvB,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO;CAoD/F"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ContentNodeIsClassComponent } from "../ContentNode.js";
|
|
2
2
|
import { RoutingRedirect } from "../routing/RoutingRedirect.js";
|
|
3
3
|
import { cliTodo } from "../cliOutput.js";
|
|
4
|
-
import {
|
|
4
|
+
import { RouteRedirectComponent } from "../components/RouteRedirectComponent.js";
|
|
5
|
+
import { WebRedirectComponent } from "../components/WebRedirectComponent.js";
|
|
5
6
|
import { $props, $type } from "../contentNodeSymbols.js";
|
|
7
|
+
import { WebRedirect } from "../routing/WebRedirect.js";
|
|
6
8
|
function debug(...texts) {
|
|
7
9
|
// console.log(...texts)
|
|
8
10
|
}
|
|
@@ -13,6 +15,10 @@ export class TungstenServer {
|
|
|
13
15
|
const redirect = matchedRouteInfo.data;
|
|
14
16
|
res.redirect(redirect.code, redirect.to);
|
|
15
17
|
return true;
|
|
18
|
+
} else if (matchedRouteInfo.data instanceof WebRedirect) {
|
|
19
|
+
const redirect = matchedRouteInfo.data;
|
|
20
|
+
res.redirect(redirect.code, redirect.to);
|
|
21
|
+
return true;
|
|
16
22
|
}
|
|
17
23
|
// console.log('content', matchedRouteInfo.content)
|
|
18
24
|
// console.log('is func', typeof matchedRouteInfo.content !== 'function')
|
|
@@ -23,12 +29,20 @@ export class TungstenServer {
|
|
|
23
29
|
// console.log('$type', (matchedRouteInfo as any).content[$type])
|
|
24
30
|
//console.log('content[$type]', matchedRouteInfo.content[$type])
|
|
25
31
|
//console.log('instanceof', matchedRouteInfo.content instanceof RedirectComponent)
|
|
26
|
-
if (typeof matchedRouteInfo.content !== 'function' && ContentNodeIsClassComponent(matchedRouteInfo.content)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
if (typeof matchedRouteInfo.content !== 'function' && ContentNodeIsClassComponent(matchedRouteInfo.content)) {
|
|
33
|
+
if (matchedRouteInfo.content[$type] === RouteRedirectComponent || matchedRouteInfo.content[$type].prototype instanceof RouteRedirectComponent) {
|
|
34
|
+
cliTodo('consider type of RedirectComponent props');
|
|
35
|
+
const code = matchedRouteInfo.content[$props].code || 302;
|
|
36
|
+
const to = matchedRouteInfo.content[$props].to;
|
|
37
|
+
res.redirect(code, to);
|
|
38
|
+
return true;
|
|
39
|
+
} else if (matchedRouteInfo.content[$type] === WebRedirectComponent || matchedRouteInfo.content[$type].prototype instanceof WebRedirectComponent) {
|
|
40
|
+
cliTodo('consider type of RedirectComponent props');
|
|
41
|
+
const code = matchedRouteInfo.content[$props].code || 302;
|
|
42
|
+
const to = matchedRouteInfo.content[$props].to;
|
|
43
|
+
res.redirect(code, to);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
32
46
|
}
|
|
33
47
|
return false;
|
|
34
48
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevServerHono.d.ts","sourceRoot":"","sources":["../../../src/Servers/hono/DevServerHono.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
// import type { Server } from 'http'
|
|
2
|
+
// //import express, { Request, Response, NextFunction, RequestHandler } from 'express'
|
|
3
|
+
// import { Context, Hono } from 'hono'
|
|
4
|
+
// import type { BlankEnv, BlankSchema, Handler, Next } from 'hono/types'
|
|
5
|
+
// import { serve } from '@hono/node-server'
|
|
6
|
+
// import { serveStatic } from '@hono/node-server/serve-static'
|
|
7
|
+
// import { join } from 'path'
|
|
8
|
+
// import { allObj as promiseAllObj } from 'sxy-lib/promises.js'
|
|
9
|
+
// import type { FrameworkConfigComplete, ServerMiddlewareInfo } from '../../FrameworkConfig.js'
|
|
10
|
+
// import type { CompilationInfo } from '../../build/CompilationInfo.js'
|
|
11
|
+
// import type { ApiRoutes } from '../../api/ApiRoutes.js'
|
|
12
|
+
// import {
|
|
13
|
+
// staticFolder, assetsFolder, publicFolder, packagesFolder, clientFolder, componentCssFolder
|
|
14
|
+
// } from '../../settings.js'
|
|
15
|
+
// import { rootToHtmlDev as renderRootToHtmlDev } from '../../render/rootToHtmlDev.js'
|
|
16
|
+
// import { contentToHtmlDev as renderContentToHtmlDev } from '../../render/contentToHtmlDev.js'
|
|
17
|
+
// import { Instance } from '../../Instance/Instance.js'
|
|
18
|
+
// import { Framework } from '../../Framework.js'
|
|
19
|
+
// import { TungstenError } from '../../TungstenError.js'
|
|
20
|
+
// import { makeInstanceConfigFromFrameworkConfig } from '../../makeInstanceConfigFromFrameworkConfig.js'
|
|
21
|
+
// import { cliNews, cliOut, cliWarn, cliLog, cliDebug, cliTodo, cliAlert } from '../../cliOutput.js' // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
22
|
+
// import { existsSync } from 'fs'
|
|
23
|
+
// import { getApiRoutes } from '../../api/getApiRoutes.js'
|
|
24
|
+
// import { getApiRoutesHono } from '../../api/getApiRoutesHono.js'
|
|
25
|
+
// import { standardizeWebPath } from '../../standardizeWebPath.js'
|
|
26
|
+
// import { log } from '../../appOutput.js'
|
|
27
|
+
// import { throwError } from '../../throwError.js'
|
|
28
|
+
// import { getRoutesDev } from '../../getRoutesDevs.js'
|
|
29
|
+
// import { getComponentDev } from '../../getComponentDev.js'
|
|
30
|
+
// import { ReqRes } from '../../ReqRes.js'
|
|
31
|
+
// import sxyLoaderConfig from '../../../sxy-loader.config.js'
|
|
32
|
+
// import { createLoad } from 'sxy-loader'
|
|
33
|
+
// import { routing } from '../routing.jsx'
|
|
34
|
+
// import { GlobalData, globalDataFunc } from '../../routing/registerGlobalData.js'
|
|
35
|
+
// import { ServerDataLoading } from '../../Store/ServerDataLoading.js'
|
|
36
|
+
// import { TungstenServer } from '../TungstenServer.jsx'
|
|
37
|
+
// import { Routes } from '../../routing/Routes.js'
|
|
38
|
+
// import { RedirectCode, RoutingRedirect } from '../../routing/RoutingRedirect.js'
|
|
39
|
+
// import { portError } from '../portError.js'
|
|
40
|
+
// import { loadEnvsDev } from '../loadEnvsDev.js'
|
|
41
|
+
// import { initStores } from '../initStores.js'
|
|
42
|
+
// import { AppRoutes } from '../../routing/AppRoutes.js'
|
|
43
|
+
// import { AnyComponentType } from '../../AnyComponentType.js'
|
|
44
|
+
// import { MatchedRouteInfo } from '../MatchedRouteInfo.js'
|
|
45
|
+
// import { MatchedRoute } from '../../routing/MatchedRoute.js'
|
|
46
|
+
// import { ContentNodeIsClassComponent } from '../../ContentNode.js'
|
|
47
|
+
// import { $props, $type } from '../../contentNodeSymbols.js'
|
|
48
|
+
// import { RedirectComponent } from '../../components/RedirectComponent.js'
|
|
49
|
+
// import { Path } from '../../routing/RouteTypes.js'
|
|
50
|
+
// import type { ApiRoutesHono } from '../../api/ApiRoutesHono.js'
|
|
51
|
+
// import { TungstenServerHono } from './TungstenServerHono.jsx'
|
|
52
|
+
export {};
|
|
53
|
+
// //import cookieParser from 'cookie-parser'
|
|
54
|
+
// function debug(...texts: any[]) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
55
|
+
// // console.log(...texts)
|
|
56
|
+
// }
|
|
57
|
+
// export class DevServerHono extends TungstenServerHono {
|
|
58
|
+
// framework: Framework
|
|
59
|
+
// config: FrameworkConfigComplete
|
|
60
|
+
// compilationInfo: CompilationInfo
|
|
61
|
+
// port: number
|
|
62
|
+
// location: string | null = null
|
|
63
|
+
// initialProcessEnv: Record<string, string>
|
|
64
|
+
// app: Hono<BlankEnv, BlankSchema, '/'>
|
|
65
|
+
// apiRoutes?: ApiRoutesHono
|
|
66
|
+
// apiPath?: string
|
|
67
|
+
// server?: Server
|
|
68
|
+
// reqId: number
|
|
69
|
+
// firstRender: boolean = true
|
|
70
|
+
// constructor(
|
|
71
|
+
// framework: Framework, config: FrameworkConfigComplete, compilationInfo: CompilationInfo,
|
|
72
|
+
// initialProcessEnv: Record<string, string> = {}/* FIX ME */
|
|
73
|
+
// ) {
|
|
74
|
+
// super()
|
|
75
|
+
// try {
|
|
76
|
+
// this.framework = framework
|
|
77
|
+
// this.config = config
|
|
78
|
+
// this.compilationInfo = compilationInfo
|
|
79
|
+
// // if (tungstenPrivateEnv.TUNGSTEN_SERVER_PORT === -999) {
|
|
80
|
+
// // throwError(
|
|
81
|
+
// // 'DevServer',
|
|
82
|
+
// // 'TUNGSTEN_SERVER_PORT environment variable has not been set,'
|
|
83
|
+
// // + '\n Ensure that you have an env schema with this field, and a matching env file'
|
|
84
|
+
// // )
|
|
85
|
+
// // }
|
|
86
|
+
// const proto = tungstenPrivateEnv.FRONTEND_PROTO ?? 'http'
|
|
87
|
+
// const host = tungstenPrivateEnv.FRONTEND_HOST ?? 'localhost'
|
|
88
|
+
// const port = tungstenPrivateEnv.TUNGSTEN_SERVER_PORT ?? 3000
|
|
89
|
+
// if (isNaN(port) || port === 0) throwError('DevServer', portError(port))
|
|
90
|
+
// this.port = port
|
|
91
|
+
// //this.port = _port
|
|
92
|
+
// this.location = `${proto}://${host}:${port}`
|
|
93
|
+
// this.initialProcessEnv = initialProcessEnv
|
|
94
|
+
// this.app = new Hono()
|
|
95
|
+
// this.reqId = 0
|
|
96
|
+
// //this.app.use(cookieParser)
|
|
97
|
+
// let reqId = 0
|
|
98
|
+
// this.app.use(async (c, next) => {
|
|
99
|
+
// reqId++
|
|
100
|
+
// await next()
|
|
101
|
+
// })
|
|
102
|
+
// //if (tungstenPrivateEnv.DEBUG === true) {
|
|
103
|
+
// this.app.use(async (c, next) => {
|
|
104
|
+
// const { req } = c
|
|
105
|
+
// const urlObj = new URL(c.req.url)
|
|
106
|
+
// //const targetOrigin = urlObj.protocol + '://' + String(req.header('host'))
|
|
107
|
+
// const targetOrigin = urlObj.origin
|
|
108
|
+
// const target = targetOrigin + req.url
|
|
109
|
+
// const origin = req.header('origin')
|
|
110
|
+
// // request log
|
|
111
|
+
// let message = 'Received request at ' + target
|
|
112
|
+
// if (origin !== undefined) {
|
|
113
|
+
// message += ' from ' + String(req.header('origin'))
|
|
114
|
+
// // should we use referrer as a backup option?
|
|
115
|
+
// // not sure what that is
|
|
116
|
+
// }
|
|
117
|
+
// cliOut(message)
|
|
118
|
+
// if ((this.config.suppressOriginMismatchWarning !== true)) {
|
|
119
|
+
// // origin-target mismatch warning
|
|
120
|
+
// if (origin !== undefined && origin === this.location && origin !== targetOrigin) {
|
|
121
|
+
// cliWarn(
|
|
122
|
+
// `Received a request from the frontend, but it's origin`
|
|
123
|
+
// + ` is not the same as the request origin.`
|
|
124
|
+
// + ` This may indicate a misconfiguration, and may prevent`
|
|
125
|
+
// + ` the passing of cookies to the tungsten server.`
|
|
126
|
+
// )
|
|
127
|
+
// cliWarn(`source: ${targetOrigin}`)
|
|
128
|
+
// cliWarn(`target: ${target}`)
|
|
129
|
+
// }
|
|
130
|
+
// }
|
|
131
|
+
// next()
|
|
132
|
+
// })
|
|
133
|
+
// // this.app.use((req, res, next) => {
|
|
134
|
+
// // cliDebug(`Received request [${res.locals.reqId}] for ${req.url}`)
|
|
135
|
+
// // next()
|
|
136
|
+
// // })
|
|
137
|
+
// //}
|
|
138
|
+
// if (config.serverMiddleware) { this.addServerMiddleware(config.serverMiddleware) }
|
|
139
|
+
// /// CHECK: Do we need to do this with hono?
|
|
140
|
+
// // can we set the mime type for .cjs files?
|
|
141
|
+
// //express.static.mime.define({'application/javascript': ['cjs']})
|
|
142
|
+
// this.app.use(
|
|
143
|
+
// `/.tungsten.config.js`,
|
|
144
|
+
// //express.static(join(this.compilationInfo.location, '.tungsten.config.js'))
|
|
145
|
+
// serveStatic({ root: join(this.compilationInfo.location, '.tungsten.config.js') })
|
|
146
|
+
// ) // config file
|
|
147
|
+
// this.app.use(
|
|
148
|
+
// `/${packagesFolder}/`,
|
|
149
|
+
// //express.static(join(this.compilationInfo.location, packagesFolder))
|
|
150
|
+
// serveStatic({ root: join(this.compilationInfo.location, packagesFolder) })
|
|
151
|
+
// ) // compiled packages
|
|
152
|
+
// this.app.use(
|
|
153
|
+
// `/${clientFolder}/`,
|
|
154
|
+
// //express.static(join(this.compilationInfo.location, clientFolder))
|
|
155
|
+
// serveStatic({ root: join(this.compilationInfo.location, clientFolder) })
|
|
156
|
+
// ) // ?
|
|
157
|
+
// this.app.use(
|
|
158
|
+
// `/${componentCssFolder}/`,
|
|
159
|
+
// //express.static(join(this.compilationInfo.location, componentCssFolder))
|
|
160
|
+
// serveStatic({ root: join(this.compilationInfo.location, componentCssFolder) })
|
|
161
|
+
// ) // app component css?/s
|
|
162
|
+
// this.app.use(
|
|
163
|
+
// //express.static(join(this.compilationInfo.location, staticFolder))
|
|
164
|
+
// serveStatic({ root: join(this.compilationInfo.location, staticFolder) })
|
|
165
|
+
// ) // compiled stylesheets? -- etag: false to disable caching (from express days...)
|
|
166
|
+
// const publicLocation = join(this.compilationInfo.location, publicFolder)
|
|
167
|
+
// if (existsSync(publicLocation)) {
|
|
168
|
+
// //this.app.use(express.static(publicLocation)) // files from public folder
|
|
169
|
+
// this.app.use(serveStatic({ root: publicLocation })) // files from public folder
|
|
170
|
+
// }
|
|
171
|
+
// //cliWarn(`assets dir:`, this.config.assetsDir)
|
|
172
|
+
// if (this.config.assetsDir !== undefined) {
|
|
173
|
+
// this.app.use(
|
|
174
|
+
// `/${this.config.assetsDir}`,
|
|
175
|
+
// //express.static(join(this.compilationInfo.location, assetsFolder))
|
|
176
|
+
// serveStatic({ root: join(this.compilationInfo.location, assetsFolder) })
|
|
177
|
+
// ) // files from assets folder
|
|
178
|
+
// }
|
|
179
|
+
// this.app.use(
|
|
180
|
+
// //express.static(this.compilationInfo.location, { dotfiles:'allow' })
|
|
181
|
+
// serveStatic({ root: this.compilationInfo.location })
|
|
182
|
+
// ) // serving the app files themselves
|
|
183
|
+
// //this.app.use('/__server_rpc__', this.handleRpc)
|
|
184
|
+
// // seems there was a plan to have API routes built into the main app
|
|
185
|
+
// // can't remember this much
|
|
186
|
+
// if (typeof config.apiRoutes === 'string' && config.apiRoutes !== '') {
|
|
187
|
+
// const apiPath = this.apiPath = standardizeWebPath(this.config.apiPath)
|
|
188
|
+
// cliOut(`API listening at ${this.apiPath}`)
|
|
189
|
+
// // should not be needed with hono
|
|
190
|
+
// // this.app.use(apiPath, express.json())
|
|
191
|
+
// //throwError('DevServerHono', 'Support for app apiRoutes not yet implemented')
|
|
192
|
+
// this.app.use(apiPath, this.handleRequestApi)
|
|
193
|
+
// }
|
|
194
|
+
// this.app.use(this.handleRequest)
|
|
195
|
+
// // !!! obsolete?
|
|
196
|
+
// // start hooking into require to rewrite react requires to tungsten
|
|
197
|
+
// //addRequireResolveHooks() // we need this for server side
|
|
198
|
+
// // we will need a server side import loader too
|
|
199
|
+
// } catch (e) {
|
|
200
|
+
// throw new TungstenError(`${this.constructor.name} construction error: ${e}`)
|
|
201
|
+
// }
|
|
202
|
+
// }
|
|
203
|
+
// private addServerMiddleware = (serverMiddleware: ServerMiddlewareInfo): void => {
|
|
204
|
+
// //console.log('addServerMiddleware')
|
|
205
|
+
// const [middlewareFile, middlewareExportName, middlewarePath] = serverMiddleware
|
|
206
|
+
// const path = middlewarePath.startsWith('/') ? middlewarePath : '/' + middlewarePath
|
|
207
|
+
// this.app.use(path, async (c) => {
|
|
208
|
+
// // this is going to reload the server application on each request
|
|
209
|
+
// // will cause trouble if anything depends on memory
|
|
210
|
+
// // but should be OK for an ordinary DB based system, including DB based sessions
|
|
211
|
+
// // [*] We could look into replacing this with a watcher + reload based system
|
|
212
|
+
// // we'd have to set up a watcher which triggers a reload of middleware to
|
|
213
|
+
// // a variable that can be accessed here. Probably in a promise format so
|
|
214
|
+
// // that a loading middleware can be awaited instead of running the outdated
|
|
215
|
+
// // code
|
|
216
|
+
// // [*] const middlewares = await middlewaresPromise
|
|
217
|
+
// const load = await createLoad(import.meta.url, sxyLoaderConfig)
|
|
218
|
+
// const fullFilePath = 'file://' + join(this.compilationInfo.codeLocation, middlewareFile)
|
|
219
|
+
// const middlewareModule = await load(fullFilePath)
|
|
220
|
+
// if ( ! (middlewareExportName in middlewareModule) ) {
|
|
221
|
+
// throwError(
|
|
222
|
+
// 'DevServer',
|
|
223
|
+
// `export ${middlewareExportName} not found in ${middlewareFile}`
|
|
224
|
+
// + ` when trying to load server middleware`
|
|
225
|
+
// )
|
|
226
|
+
// }
|
|
227
|
+
// const middlewares = middlewareModule[middlewareExportName] as Handler[] // eslint-disable-line no-type-assertion/no-type-assertion
|
|
228
|
+
// // TODO should we add a manual type check here?
|
|
229
|
+
// if (!Array.isArray(middlewares)) throwError('addServerMiddleware', `Expected middlewares to be an array`)
|
|
230
|
+
// if (!(0 in middlewares)) throwError('addServerMiddleware', `No middleware entry at index 0`)
|
|
231
|
+
// const firstMiddleware = middlewares[0]
|
|
232
|
+
// if (!(typeof firstMiddleware === 'function')) {
|
|
233
|
+
// throwError('addServerMiddleware', `Expected middleware to be a function`)
|
|
234
|
+
// }
|
|
235
|
+
// // mimicing hono here so we can modify behaviour on each run
|
|
236
|
+
// let i = 0
|
|
237
|
+
// const next: Next = async () => {
|
|
238
|
+
// i++
|
|
239
|
+
// const m = middlewares[i]
|
|
240
|
+
// if (m !== undefined) {
|
|
241
|
+
// m(c, next)
|
|
242
|
+
// }
|
|
243
|
+
// }
|
|
244
|
+
// firstMiddleware(c, next)
|
|
245
|
+
// })
|
|
246
|
+
// cliOut(`Server Middleware added to server at ${path}`)
|
|
247
|
+
// }
|
|
248
|
+
// // private handleRpc = async (req: Request, res: Response, next: NextFunction) => {
|
|
249
|
+
// // //
|
|
250
|
+
// // console.log('Server is handling server rpc')
|
|
251
|
+
// // }
|
|
252
|
+
// private handleRequestApi = async (c: Context, next: Next): Promise<Response> => {
|
|
253
|
+
// const { req } = c
|
|
254
|
+
// this.apiRoutes = await getApiRoutesHono(this.config, this.compilationInfo, 'dev')
|
|
255
|
+
// //const requestPath = standardizeWebPath(req.baseUrl + req.path)
|
|
256
|
+
// const subPath = standardizeWebPath(req.path)
|
|
257
|
+
// //console.log('received an API req', req.originalUrl, res.locals.reqId)
|
|
258
|
+
// for (const [path, route] of Object.entries(this.apiRoutes)) {
|
|
259
|
+
// if (route.method === req.method && standardizeWebPath(path) === subPath) {
|
|
260
|
+
// //console.log('API route matched', path)
|
|
261
|
+
// return await route.endpoint(c, next)
|
|
262
|
+
// }
|
|
263
|
+
// }
|
|
264
|
+
// // otherwise
|
|
265
|
+
// //res.sendStatus(404)
|
|
266
|
+
// return c.notFound()
|
|
267
|
+
// }
|
|
268
|
+
// private handleRequest = async (c: Context, next: Next): Promise<Response> => {
|
|
269
|
+
// const { req } = c
|
|
270
|
+
// if (/\.(css|scss|sass|js|jsx|png|jpg|jpeg|svg|ico)$/.test(req.path)) {
|
|
271
|
+
// // warn(
|
|
272
|
+
// // `Dev server received request ${req.url} which was not matched by a static file.`
|
|
273
|
+
// // + '\nBlocking request to prevent pointless app render'
|
|
274
|
+
// // )
|
|
275
|
+
// cliLog(`Requested asset file ${req.url} was not found`)
|
|
276
|
+
// return c.notFound()
|
|
277
|
+
// //res.status(404).end()
|
|
278
|
+
// //return
|
|
279
|
+
// }
|
|
280
|
+
// try {
|
|
281
|
+
// const _firstRender = this.firstRender
|
|
282
|
+
// this.firstRender = false
|
|
283
|
+
// //console.log('received a frontend req', req.originalUrl, res.locals.reqId)
|
|
284
|
+
// //// I think we need to pass req, (res?) to the app
|
|
285
|
+
// //// so that it can set response codes
|
|
286
|
+
// //// or
|
|
287
|
+
// //// the app has to return some data other than response string
|
|
288
|
+
// ////
|
|
289
|
+
// //// perhaps, set some return data in the instance
|
|
290
|
+
// //// then return html string + other data
|
|
291
|
+
// const location = req.url
|
|
292
|
+
// const instanceConfig = makeInstanceConfigFromFrameworkConfig(this.config, true)
|
|
293
|
+
// if (this.framework.frameworkModules === undefined) {
|
|
294
|
+
// throwError('DevServer.handleRequest()',
|
|
295
|
+
// 'framework.frameworkModules is undefined'
|
|
296
|
+
// )
|
|
297
|
+
// }
|
|
298
|
+
// if (this.framework.clientImportAliases === undefined) {
|
|
299
|
+
// throwError('DevServer.handleRequest()',
|
|
300
|
+
// 'framework.frameworkModules is undefined'
|
|
301
|
+
// )
|
|
302
|
+
// }
|
|
303
|
+
// globalDataFunc.value = undefined
|
|
304
|
+
// const load = await createLoad(import.meta.url, sxyLoaderConfig)
|
|
305
|
+
// await loadEnvsDev(this.config, load, this.initialProcessEnv, false)
|
|
306
|
+
// // we are delaying instance creation until after we load the app code, to lets things initialise?
|
|
307
|
+
// //const reqRes: ReqRes = { req, res }
|
|
308
|
+
// //const honoContext = c
|
|
309
|
+
// // Save some state. I think this is a placeholder for later
|
|
310
|
+
// const serverDataLoading: ServerDataLoading = { value: false }
|
|
311
|
+
// const routingPromise = getRoutesDev(this.compilationInfo, this.config, load).then(
|
|
312
|
+
// async (appRoutes) => {
|
|
313
|
+
// const routes = (typeof appRoutes === 'function') ? appRoutes(c) : appRoutes
|
|
314
|
+
// // load data, and do routing
|
|
315
|
+
// return promiseAllObj({
|
|
316
|
+
// appRoutes,
|
|
317
|
+
// routes,
|
|
318
|
+
// globalData: (globalDataFunc.value !== undefined) ? globalDataFunc.value(c) : {},
|
|
319
|
+
// matchedRouteInfo: routing(location, routes, serverDataLoading)
|
|
320
|
+
// })
|
|
321
|
+
// }
|
|
322
|
+
// )
|
|
323
|
+
// let appRoutes: AppRoutes
|
|
324
|
+
// let routes: Routes
|
|
325
|
+
// let globalData: GlobalData
|
|
326
|
+
// let matchedRouteInfo: MatchedRouteInfo
|
|
327
|
+
// let RootComponentClass: AnyComponentType | null = null
|
|
328
|
+
// if (this.config.useRootComponent) {
|
|
329
|
+
// const rootComponentFileFull = join(this.compilationInfo.location, this.config.rootComponent)
|
|
330
|
+
// ;({ routing: { appRoutes, routes, globalData, matchedRouteInfo }, RootComponentClass }
|
|
331
|
+
// = await promiseAllObj({
|
|
332
|
+
// routing: routingPromise,
|
|
333
|
+
// RootComponentClass: getComponentDev(rootComponentFileFull, this.config.rootComponent, load)
|
|
334
|
+
// }))
|
|
335
|
+
// } else {
|
|
336
|
+
// ({ appRoutes, routes, globalData, matchedRouteInfo } = await routingPromise)
|
|
337
|
+
// //throwError('DevServer', 'useRootComponent = false not implemented yet')
|
|
338
|
+
// }
|
|
339
|
+
// // get routes (running the getRoutes function if needed)
|
|
340
|
+
// //const routes = (typeof appRoutes === 'function') ? appRoutes(reqRes) : appRoutes
|
|
341
|
+
// // load data, and do routing
|
|
342
|
+
// // const [globalData, matchedRouteInfo] = await Promise.all([
|
|
343
|
+
// // (globalDataFunc !== undefined) ? globalDataFunc(reqRes) : {},
|
|
344
|
+
// // routing(location, routes, serverDataLoading)
|
|
345
|
+
// // ])
|
|
346
|
+
// const redirected = this.handleRedirects(c, matchedRouteInfo)
|
|
347
|
+
// if (redirected) return // end early
|
|
348
|
+
// // make stores
|
|
349
|
+
// const { internalStore, stores, storeSubscriptions }
|
|
350
|
+
// = initStores(location, c, globalData, matchedRouteInfo, serverDataLoading)
|
|
351
|
+
// // create the instance
|
|
352
|
+
// const instance = new Instance(
|
|
353
|
+
// location, instanceConfig, c, appRoutes, routes, internalStore,
|
|
354
|
+
// stores, storeSubscriptions, globalData, matchedRouteInfo
|
|
355
|
+
// )
|
|
356
|
+
// let html: string
|
|
357
|
+
// if (RootComponentClass) {
|
|
358
|
+
// html = await renderRootToHtmlDev(
|
|
359
|
+
// this.compilationInfo, this.framework.clientImportAliases,
|
|
360
|
+
// RootComponentClass, instance, this.config, global.tungstenPublicEnv,
|
|
361
|
+
// '' // siteBasePathOverride
|
|
362
|
+
// )
|
|
363
|
+
// } else {
|
|
364
|
+
// html = await renderRootToHtmlDev(
|
|
365
|
+
// this.compilationInfo, this.framework.clientImportAliases,
|
|
366
|
+
// MatchedRoute, instance, this.config, global.tungstenPublicEnv,
|
|
367
|
+
// '' // siteBasePathOverride
|
|
368
|
+
// )
|
|
369
|
+
// // const { params, data } = matchedRouteInfo
|
|
370
|
+
// // let { content } = matchedRouteInfo
|
|
371
|
+
// // if (typeof content === 'function') {
|
|
372
|
+
// // content = content(data, params, {} /* props */, globalData, location)
|
|
373
|
+
// // //throwError('DevServer', 'route content is a function')
|
|
374
|
+
// // }
|
|
375
|
+
// // //console.log('content to render', content)
|
|
376
|
+
// // html = await renderContentToHtmlDev(
|
|
377
|
+
// // this.compilationInfo, this.framework.clientImportAliases,
|
|
378
|
+
// // content, instance, this.config, global.tungstenPublicEnv,
|
|
379
|
+
// // '' // siteBasePathOverride
|
|
380
|
+
// // )
|
|
381
|
+
// }
|
|
382
|
+
// //debug('html', html)
|
|
383
|
+
// res.setHeader('Content-Type', 'text/html')
|
|
384
|
+
// res.status((instance.matchedRouteInfo.key === '404') ? 404 : 200)
|
|
385
|
+
// res.send(html)
|
|
386
|
+
// } catch(e) {
|
|
387
|
+
// cliLog('error', e)
|
|
388
|
+
// res.setHeader('Content-Type', 'text/html')
|
|
389
|
+
// res.status(500)
|
|
390
|
+
// this.errorLog(e)
|
|
391
|
+
// res.send(this.errorPage(e))
|
|
392
|
+
// }
|
|
393
|
+
// }
|
|
394
|
+
// // private async handlePost(req: express.Request, res: express.Response): Promise<void> {
|
|
395
|
+
// // throw new TungstenError(`Err - Dev server received a post request. Not supported yet.`)
|
|
396
|
+
// // }
|
|
397
|
+
// errorLog = (error: unknown) => {
|
|
398
|
+
// log((typeof error === 'object' && error !== null && 'stack' in error) ? error.stack : error)
|
|
399
|
+
// }
|
|
400
|
+
// errorPage = (error: unknown) => {
|
|
401
|
+
// return `<!DOCTYPE html>
|
|
402
|
+
// </html>
|
|
403
|
+
// <head>
|
|
404
|
+
// <title>Error</title>
|
|
405
|
+
// <style>html { font-family: arial }</style>
|
|
406
|
+
// </head>
|
|
407
|
+
// <body>
|
|
408
|
+
// <h1>Application Error</h1>
|
|
409
|
+
// <section>
|
|
410
|
+
// <pre>${(typeof error === 'object' && error !== null && 'stack' in error) ? error.stack : error}</pre>
|
|
411
|
+
// </section>
|
|
412
|
+
// </body>
|
|
413
|
+
// </html>`
|
|
414
|
+
// }
|
|
415
|
+
// start = (): Promise<string> => {
|
|
416
|
+
// return new Promise( resolve => {
|
|
417
|
+
// this.server = this.app.listen(this.port, () => {
|
|
418
|
+
// cliNews(`Dev server ready at ${this.location}`)
|
|
419
|
+
// resolve(this.location ?? '')
|
|
420
|
+
// })
|
|
421
|
+
// })
|
|
422
|
+
// }
|
|
423
|
+
// stop = () => {
|
|
424
|
+
// if (this.server !== undefined) this.server.close()
|
|
425
|
+
// }
|
|
426
|
+
// //treeToHtml = treeToHtml
|
|
427
|
+
// }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProdServerHono.d.ts","sourceRoot":"","sources":["../../../src/Servers/hono/ProdServerHono.ts"],"names":[],"mappings":""}
|