Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
9aebd59c08 | |||
be7f4c503e | |||
e1e1d4bf65 | |||
20ecb86a9e | |||
83890d7cab | |||
4c87ea8273 | |||
4be625a0d9 | |||
c305ca517a | |||
23dccae01b | |||
d5f8d215a2 | |||
3d4f8d1bbe | |||
4724629efa | |||
ff9aea12c3 | |||
910b9a495e | |||
7fdf0a71a7 | |||
bf2c6660f2 | |||
49afc16422 | |||
bb6f239075 | |||
5bd5916696 | |||
62df38d083 | |||
d7fe947107 | |||
dd426a4ca4 | |||
2a2d4dabe4 | |||
830682d382 |
28
package.json
28
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@apiglobal/typedserver",
|
||||
"version": "2.0.44",
|
||||
"version": "2.0.56",
|
||||
"description": "easy serving of static files",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
@ -39,39 +39,39 @@
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest": "^2.0.12",
|
||||
"@apiglobal/typedrequest-interfaces": "^2.0.1",
|
||||
"@apiglobal/typedsocket": "^2.0.23",
|
||||
"@apiglobal/typedsocket": "^2.0.24",
|
||||
"@pushrocks/lik": "^6.0.2",
|
||||
"@pushrocks/smartchok": "^1.0.23",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartdelay": "^3.0.1",
|
||||
"@pushrocks/smartenv": "^5.0.5",
|
||||
"@pushrocks/smartfeed": "^1.0.11",
|
||||
"@pushrocks/smartfile": "^10.0.7",
|
||||
"@pushrocks/smartlog": "^3.0.1",
|
||||
"@pushrocks/smartlog-destination-devtools": "^1.0.10",
|
||||
"@pushrocks/smartmanifest": "^1.0.8",
|
||||
"@pushrocks/smartmanifest": "^2.0.2",
|
||||
"@pushrocks/smartmime": "^1.0.5",
|
||||
"@pushrocks/smartopen": "^2.0.0",
|
||||
"@pushrocks/smartpath": "^5.0.5",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smartrequest": "^2.0.11",
|
||||
"@pushrocks/smartrx": "^3.0.0",
|
||||
"@pushrocks/smartpromise": "^4.0.2",
|
||||
"@pushrocks/smartrequest": "^2.0.15",
|
||||
"@pushrocks/smartrx": "^3.0.2",
|
||||
"@pushrocks/smartsitemap": "^2.0.1",
|
||||
"@pushrocks/smarttime": "^4.0.1",
|
||||
"@pushrocks/webstore": "^2.0.5",
|
||||
"@tsclass/tsclass": "^4.0.34",
|
||||
"@pushrocks/webstore": "^2.0.8",
|
||||
"@tsclass/tsclass": "^4.0.42",
|
||||
"body-parser": "^1.20.2",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.18.2",
|
||||
"express-force-ssl": "^0.3.2",
|
||||
"lit": "^2.7.0"
|
||||
"lit": "^2.7.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
"@gitzone/tsbundle": "^2.0.6",
|
||||
"@gitzone/tsrun": "^1.2.39",
|
||||
"@gitzone/tsbuild": "^2.1.66",
|
||||
"@gitzone/tsbundle": "^2.0.8",
|
||||
"@gitzone/tsrun": "^1.2.42",
|
||||
"@gitzone/tstest": "^1.0.72",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.15.11"
|
||||
"@types/node": "^20.3.0"
|
||||
},
|
||||
"private": false,
|
||||
"browserslist": [
|
||||
|
945
pnpm-lock.yaml
generated
945
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiglobal/typedserver',
|
||||
version: '2.0.44',
|
||||
version: '2.0.56',
|
||||
description: 'easy serving of static files'
|
||||
}
|
||||
|
@ -10,3 +10,14 @@ export interface IReq_PushLatestServerChangeTime extends typedrequestInterfaces.
|
||||
};
|
||||
response: {}
|
||||
}
|
||||
|
||||
export interface IReq_GetLatestServerChangeTime extends typedrequestInterfaces.implementsTR<
|
||||
typedrequestInterfaces.ITypedRequest,
|
||||
IReq_GetLatestServerChangeTime
|
||||
> {
|
||||
method: 'getLatestServerChangeTime',
|
||||
request: {};
|
||||
response: {
|
||||
time: number;
|
||||
}
|
||||
}
|
||||
|
@ -101,16 +101,11 @@ export class Server {
|
||||
console.log('Using externally supplied http server');
|
||||
}
|
||||
this.httpServer.keepAliveTimeout = 600 * 1000;
|
||||
this.httpServer.headersTimeout = 600 * 1000;
|
||||
this.httpServer.headersTimeout = 20 * 1000;
|
||||
|
||||
// general request handlling
|
||||
this.expressAppInstance.use((req, res, next) => {
|
||||
req.on('error', () => {
|
||||
req.destroy();
|
||||
});
|
||||
req.on('timeout', () => {
|
||||
req.destroy();
|
||||
});
|
||||
req.setTimeout(60 * 1000);
|
||||
next();
|
||||
});
|
||||
|
||||
@ -140,6 +135,9 @@ export class Server {
|
||||
res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');
|
||||
res.setHeader('Cross-Origin-Embedder-Policy', 'unsafe-none');
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
res.setHeader('SERVEZONE_ROUTE', 'LOSSLESS_ORIGIN_CONTAINER');
|
||||
res.setHeader('Cache-Control', 'no-cache');
|
||||
res.setHeader('Expires', new Date(Date.now()).toUTCString());
|
||||
next();
|
||||
});
|
||||
|
||||
|
@ -129,7 +129,7 @@ export class TypedServer {
|
||||
<script async defer type="module" src="/typedserver/devtools"></script>
|
||||
<script>
|
||||
globalThis.typedserver = {
|
||||
lastReload: '${this.lastReload}',
|
||||
lastReload: ${this.lastReload},
|
||||
versionInfo: ${JSON.stringify({}, null, 2)},
|
||||
}
|
||||
</script>
|
||||
@ -176,6 +176,13 @@ export class TypedServer {
|
||||
this.server
|
||||
);
|
||||
|
||||
// lets setup typedrouter
|
||||
this.typedrouter.addTypedHandler<interfaces.IReq_GetLatestServerChangeTime>(new plugins.typedrequest.TypedHandler('getLatestServerChangeTime', async reqDataArg => {
|
||||
return {
|
||||
time: this.lastReload,
|
||||
}
|
||||
}))
|
||||
|
||||
// console.log('open url in browser');
|
||||
// await plugins.smartopen.openUrl(`http://testing.git.zone:${this.options.port}`);
|
||||
}
|
||||
@ -185,7 +192,7 @@ export class TypedServer {
|
||||
*/
|
||||
public async reload() {
|
||||
this.lastReload = Date.now();
|
||||
for (const connectionArg of await this.typedsocket.findAllTargetConnections(async () => true)) {
|
||||
for (const connectionArg of await this.typedsocket.findAllTargetConnectionsByTag('typedserver_frontend')) {
|
||||
const pushTime =
|
||||
this.typedsocket.createTypedRequest<interfaces.IReq_PushLatestServerChangeTime>(
|
||||
'pushLatestServerChangeTime',
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiglobal/typedserver',
|
||||
version: '2.0.44',
|
||||
version: '2.0.56',
|
||||
description: 'easy serving of static files'
|
||||
}
|
||||
|
@ -61,11 +61,15 @@ export class ReloadChecker {
|
||||
|
||||
public async checkReload(lastServerChange: number) {
|
||||
let reloadJustified = false;
|
||||
(await this.store.get(this.storeKey)) !== lastServerChange ? (reloadJustified = true) : null;
|
||||
let storedLastServerChange = await this.store.get(this.storeKey);
|
||||
if (storedLastServerChange && storedLastServerChange !== lastServerChange) {
|
||||
reloadJustified = true;
|
||||
} else {
|
||||
}
|
||||
|
||||
if (reloadJustified) {
|
||||
this.store.set(this.storeKey, lastServerChange);
|
||||
const reloadText = `about to reload ${
|
||||
const reloadText = `upgrading... ${
|
||||
globalThis.globalSw ? '(purging the sw cache first...)' : ''
|
||||
}`;
|
||||
this.infoscreen.setText(reloadText);
|
||||
@ -98,18 +102,29 @@ export class ReloadChecker {
|
||||
this.typedrouter,
|
||||
plugins.typedsocket.TypedSocket.useWindowLocationOriginUrl()
|
||||
);
|
||||
this.typedsocket.eventSubject.subscribe(eventArg => {
|
||||
this.typedsocket.addTag('typedserver_frontend', {});
|
||||
this.typedsocket.eventSubject.subscribe(async (eventArg) => {
|
||||
console.log(`typedsocket event subscription: ${eventArg}`);
|
||||
if (eventArg === 'disconnected' || eventArg === 'disconnecting' || eventArg === 'timedOut') {
|
||||
if (
|
||||
eventArg === 'disconnected' ||
|
||||
eventArg === 'disconnecting' ||
|
||||
eventArg === 'timedOut'
|
||||
) {
|
||||
this.backendConnectionLost = true;
|
||||
this.infoscreen.setText(`typedsocket ${eventArg}!`)
|
||||
this.infoscreen.setText(`typedsocket ${eventArg}!`);
|
||||
} else if (eventArg === 'connected' && this.backendConnectionLost) {
|
||||
this.backendConnectionLost = false;
|
||||
this.infoscreen.setSuccess('typedsocket connected!')
|
||||
this.infoscreen.setSuccess('typedsocket connected!');
|
||||
// lets check if a reload is necessary
|
||||
const getLatestServerChangeTime =
|
||||
this.typedsocket.createTypedRequest<interfaces.IReq_GetLatestServerChangeTime>(
|
||||
'getLatestServerChangeTime'
|
||||
);
|
||||
const response = await getLatestServerChangeTime.fire({});
|
||||
this.checkReload(response.time);
|
||||
}
|
||||
|
||||
});
|
||||
logger.log('success', `ReloadChecker connected through typedsocket!`)
|
||||
logger.log('success', `ReloadChecker connected through typedsocket!`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,10 +95,13 @@ export class TypedserverInfoscreen extends LitElement {
|
||||
|
||||
public async hide() {
|
||||
this.text = '';
|
||||
const mainbox = this.shadowRoot.querySelector('.mainbox');
|
||||
mainbox.classList.add('show');
|
||||
if (this.appended) {
|
||||
const mainbox = this.shadowRoot.querySelector('.mainbox');
|
||||
mainbox.classList.remove('show');
|
||||
}
|
||||
await plugins.smartdelay.delayFor(300);
|
||||
if (this.appended) {
|
||||
this.appended = false;
|
||||
document.body.removeChild(this);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user